Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove completed discovery TODOs. #395

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions pkg/reader/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,6 @@ func (r *ccipChainReader) getAllOffRampSourceChainsConfig(
configs := make(map[cciptypes.ChainSelector]sourceChainConfig)

var resp selectorsAndConfigs
//var resp map[string]any
err := r.contractReaders[chain].ExtendedGetLatestValue(
ctx,
consts.ContractNameOffRamp,
Expand Down Expand Up @@ -1199,13 +1198,6 @@ type offRampDynamicChainConfig struct {
MessageInterceptor []byte `json:"messageInterceptor"`
}

//nolint:unused // it will be used soon // TODO: Remove nolint
type offRampDestChainConfig struct {
SequenceNumber uint64 `json:"sequenceNumber"`
AllowListEnabled bool `json:"allowListEnabled"`
Router []byte `json:"router"`
}

// getData returns data for a single reader.
func (r *ccipChainReader) getDestinationData(
ctx context.Context,
Expand Down
93 changes: 0 additions & 93 deletions pkg/reader/ccip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ func TestCCIPChainReader_DiscoverContracts_HappyPath_Round1(t *testing.T) {
lggr: lggr,
}

// TODO: allChains should be initialized to "append(onramps, destChain)" when that feature is implemented.
contractAddresses, err := ccipChainReader.DiscoverContracts(ctx)
require.NoError(t, err)

Expand Down Expand Up @@ -634,102 +633,12 @@ func TestCCIPChainReader_DiscoverContracts_HappyPath_Round2(t *testing.T) {
lggr: logger.Test(t),
}

// TODO: allChains should be initialized to "append(onramps, destChain)" when that feature is implemented.
contractAddresses, err := ccipChainReader.DiscoverContracts(ctx)
require.NoError(t, err)

require.Equal(t, expectedContractAddresses, contractAddresses)
}

// TODO: Remove this test when allChains is implemented.
// This test checks that onramps are not discovered if there are only dest readers available.
func TestCCIPChainReader_DiscoverContracts_HappyPath_OnlySupportDest(t *testing.T) {
ctx := tests.Context(t)
destChain := cciptypes.ChainSelector(1)
sourceChain := [2]cciptypes.ChainSelector{2, 3}
onramps := [2][]byte{{0x1}, {0x2}}
destNonceMgr := []byte{0x3}
destRMNRemote := []byte{0x4}
destFeeQuoter := []byte{0x5}
destRouter := []byte{0x6}

var expectedContractAddresses ContractAddresses
for i := range onramps {
expectedContractAddresses = expectedContractAddresses.Append(
consts.ContractNameOnRamp, sourceChain[i], onramps[i])
}
// All dest chain contracts should be discovered, they do not require source chain support.
expectedContractAddresses = expectedContractAddresses.Append(consts.ContractNameRouter, destChain, destRouter)
expectedContractAddresses = expectedContractAddresses.Append(consts.ContractNameFeeQuoter, destChain, destFeeQuoter)
expectedContractAddresses = expectedContractAddresses.Append(consts.ContractNameRMNRemote, destChain, destRMNRemote)
expectedContractAddresses = expectedContractAddresses.Append(consts.ContractNameNonceManager, destChain, destNonceMgr)

destExtended := reader_mocks.NewMockExtended(t)

// mock the call to get the nonce manager
destExtended.EXPECT().ExtendedGetLatestValue(
mock.Anything,
consts.ContractNameOffRamp,
consts.MethodNameOffRampGetStaticConfig,
primitives.Unconfirmed,
map[string]any{},
mock.Anything,
).Return(nil).Run(withReturnValueOverridden(func(returnVal interface{}) {
v := returnVal.(*offRampStaticChainConfig)
v.NonceManager = destNonceMgr
v.RmnRemote = destRMNRemote
}))
// mock the call to get the fee quoter
destExtended.EXPECT().ExtendedGetLatestValue(
mock.Anything,
consts.ContractNameOffRamp,
consts.MethodNameOffRampGetDynamicConfig,
primitives.Unconfirmed,
map[string]any{},
mock.Anything,
).Return(nil).Run(withReturnValueOverridden(func(returnVal interface{}) {
v := returnVal.(*offRampDynamicChainConfig)
v.FeeQuoter = destFeeQuoter
}))
destExtended.EXPECT().ExtendedGetLatestValue(
mock.Anything,
consts.ContractNameOffRamp,
consts.MethodNameOffRampGetAllSourceChainConfigs,
primitives.Unconfirmed,
map[string]any{},
mock.Anything,
).Return(nil).Run(withReturnValueOverridden(func(returnVal interface{}) {
v := returnVal.(*selectorsAndConfigs)
v.Selectors = []uint64{uint64(sourceChain[0]), uint64(sourceChain[1])}
v.SourceChainConfigs = []sourceChainConfig{
{
OnRamp: onramps[0],
Router: destRouter,
IsEnabled: true,
},
{
OnRamp: onramps[1],
Router: destRouter,
IsEnabled: true,
},
}
}))

// create the reader
ccipChainReader := &ccipChainReader{
destChain: destChain,
contractReaders: map[cciptypes.ChainSelector]contractreader.Extended{
destChain: destExtended,
},
lggr: logger.Test(t),
}

// TODO: allChains should be initialized to "append(onramps, destChain)" when that feature is implemented.
contractAddresses, err := ccipChainReader.DiscoverContracts(ctx)
require.NoError(t, err)
require.Equal(t, expectedContractAddresses, contractAddresses)
}

func TestCCIPChainReader_DiscoverContracts_GetAllSourceChainConfig_Errors(t *testing.T) {
ctx := tests.Context(t)
destChain := cciptypes.ChainSelector(1)
Expand Down Expand Up @@ -764,7 +673,6 @@ func TestCCIPChainReader_DiscoverContracts_GetAllSourceChainConfig_Errors(t *tes
lggr: logger.Test(t),
}

// TODO: allChains should be initialized to "append(onramps, destChain)" when that feature is implemented.
_, err := ccipChainReader.DiscoverContracts(ctx)
require.Error(t, err)
require.ErrorIs(t, err, getLatestValueErr)
Expand Down Expand Up @@ -811,7 +719,6 @@ func TestCCIPChainReader_DiscoverContracts_GetOfframpStaticConfig_Errors(t *test
lggr: logger.Test(t),
}

// TODO: allChains should be initialized to "append(onramps, destChain)" when that feature is implemented.
_, err := ccipChainReader.DiscoverContracts(ctx)
require.Error(t, err)
require.ErrorIs(t, err, getLatestValueErr)
Expand Down
Loading