Skip to content

Commit

Permalink
Completes tests comparing capability registry views
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzaldysanchez committed Nov 20, 2024
1 parent a582991 commit e354c59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
6 changes: 0 additions & 6 deletions deployment/common/changeset/capability_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ func HydrateCapabilityRegistry(v v1_0.CapabilityRegistryView, env deployment.Env
}

nopsParams := v.NopsToNopsParams()
for _, nop := range v.Nops {
nopsParams = append(nopsParams, capabilities_registry.CapabilitiesRegistryNodeOperator{
Admin: nop.Admin,
Name: nop.Name,
})
}
tx, err := deployedContract.Contract.AddNodeOperators(chain.DeployerKey, nopsParams)
if _, err = deployment.ConfirmIfNoError(chain, tx, keystone.DecodeErr(capabilities_registry.CapabilitiesRegistryABI, err)); err != nil {
return nil, fmt.Errorf("failed to add node operators: %w", err)
Expand Down
23 changes: 22 additions & 1 deletion deployment/common/changeset/capability_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
"os"
"testing"

chainsel "github.com/smartcontractkit/chain-selectors"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"

chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink/deployment/common/view/v1_0"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/capabilities_registry"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

Expand All @@ -31,4 +33,23 @@ func TestHydrateCapabilityRegistry(t *testing.T) {
hydrated, err := HydrateCapabilityRegistry(capabilityRegistryView, env, cfg)
require.NoError(t, err)
require.NotNil(t, hydrated)

chainSelector, err := chainsel.SelectorFromChainId(chainID)
require.NoError(t, err)
chain, ok := env.Chains[chainSelector]
require.True(t, ok)
capabilityRegistry, err := capabilities_registry.NewCapabilitiesRegistry(hydrated.Address, chain.Client)
require.NoError(t, err)
require.NotNil(t, capabilityRegistry)
capView, err := v1_0.GenerateCapabilityRegistryView(capabilityRegistry)
require.NoError(t, err)

// Setting address/owner values to be the same in order to compare the views
capView.Address = capabilityRegistryView.Address
capView.Owner = capabilityRegistryView.Owner
b1, err := capabilityRegistryView.MarshalJSON()
require.NoError(t, err)
b2, err := capView.MarshalJSON()
require.NoError(t, err)
require.Equal(t, string(b1), string(b2))
}

0 comments on commit e354c59

Please sign in to comment.