Skip to content

Commit 02ecc08

Browse files
committed
Use existing mock chain accessor
1 parent 7289c19 commit 02ecc08

File tree

1 file changed

+6
-159
lines changed

1 file changed

+6
-159
lines changed

execute/chainaccessor_wrapper_test.go

Lines changed: 6 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -3,167 +3,14 @@ package execute
33
import (
44
"context"
55
"testing"
6-
"time"
76

7+
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
88
"github.com/stretchr/testify/assert"
9-
"github.com/stretchr/testify/mock"
109
"github.com/stretchr/testify/require"
1110

12-
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
13-
"github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives"
11+
ccipocr3mocks "github.com/smartcontractkit/chainlink-ccip/mocks/chainlink_common/ccipocr3"
1412
)
1513

16-
// MockChainAccessor is a mock implementation of ChainAccessor for testing
17-
type MockChainAccessor struct {
18-
mock.Mock
19-
}
20-
21-
func (m *MockChainAccessor) MsgsBetweenSeqNums(
22-
ctx context.Context,
23-
chain cciptypes.ChainSelector,
24-
seqNumRange cciptypes.SeqNumRange,
25-
) ([]cciptypes.Message, error) {
26-
args := m.Called(ctx, chain, seqNumRange)
27-
return args.Get(0).([]cciptypes.Message), args.Error(1)
28-
}
29-
30-
func (m *MockChainAccessor) GetContractAddress(contractName string) ([]byte, error) {
31-
args := m.Called(contractName)
32-
if args.Get(0) == nil {
33-
return nil, args.Error(1)
34-
}
35-
return args.Get(0).([]byte), args.Error(1)
36-
}
37-
38-
func (m *MockChainAccessor) GetAllConfigsLegacy(
39-
ctx context.Context,
40-
destChainSelector cciptypes.ChainSelector,
41-
sourceChainSelectors []cciptypes.ChainSelector,
42-
) (cciptypes.ChainConfigSnapshot, map[cciptypes.ChainSelector]cciptypes.SourceChainConfig, error) {
43-
args := m.Called(ctx, destChainSelector, sourceChainSelectors)
44-
return args.Get(0).(cciptypes.ChainConfigSnapshot),
45-
args.Get(1).(map[cciptypes.ChainSelector]cciptypes.SourceChainConfig),
46-
args.Error(2)
47-
}
48-
49-
func (m *MockChainAccessor) GetChainFeeComponents(ctx context.Context) (cciptypes.ChainFeeComponents, error) {
50-
args := m.Called(ctx)
51-
return args.Get(0).(cciptypes.ChainFeeComponents), args.Error(1)
52-
}
53-
54-
func (m *MockChainAccessor) Sync(
55-
ctx context.Context,
56-
contractName string,
57-
contractAddress cciptypes.UnknownAddress,
58-
) error {
59-
args := m.Called(ctx, contractName, contractAddress)
60-
return args.Error(0)
61-
}
62-
63-
func (m *MockChainAccessor) CommitReportsGTETimestamp(
64-
ctx context.Context,
65-
ts time.Time,
66-
confidence primitives.ConfidenceLevel,
67-
limit int,
68-
) ([]cciptypes.CommitPluginReportWithMeta, error) {
69-
args := m.Called(ctx, ts, confidence, limit)
70-
return args.Get(0).([]cciptypes.CommitPluginReportWithMeta), args.Error(1)
71-
}
72-
73-
func (m *MockChainAccessor) ExecutedMessages(
74-
ctx context.Context,
75-
rangesPerChain map[cciptypes.ChainSelector][]cciptypes.SeqNumRange,
76-
confidence primitives.ConfidenceLevel,
77-
) (map[cciptypes.ChainSelector][]cciptypes.SeqNum, error) {
78-
args := m.Called(ctx, rangesPerChain, confidence)
79-
return args.Get(0).(map[cciptypes.ChainSelector][]cciptypes.SeqNum), args.Error(1)
80-
}
81-
82-
func (m *MockChainAccessor) NextSeqNum(ctx context.Context, sources []cciptypes.ChainSelector) (
83-
map[cciptypes.ChainSelector]cciptypes.SeqNum, error) {
84-
args := m.Called(ctx, sources)
85-
return args.Get(0).(map[cciptypes.ChainSelector]cciptypes.SeqNum), args.Error(1)
86-
}
87-
88-
func (m *MockChainAccessor) Nonces(
89-
ctx context.Context,
90-
addresses map[cciptypes.ChainSelector][]cciptypes.UnknownEncodedAddress,
91-
) (map[cciptypes.ChainSelector]map[string]uint64, error) {
92-
args := m.Called(ctx, addresses)
93-
return args.Get(0).(map[cciptypes.ChainSelector]map[string]uint64), args.Error(1)
94-
}
95-
96-
func (m *MockChainAccessor) GetChainFeePriceUpdate(
97-
ctx context.Context,
98-
selectors []cciptypes.ChainSelector,
99-
) (map[cciptypes.ChainSelector]cciptypes.TimestampedUnixBig, error) {
100-
args := m.Called(ctx, selectors)
101-
return args.Get(0).(map[cciptypes.ChainSelector]cciptypes.TimestampedUnixBig), args.Error(1)
102-
}
103-
104-
func (m *MockChainAccessor) GetLatestPriceSeqNr(ctx context.Context) (cciptypes.SeqNum, error) {
105-
args := m.Called(ctx)
106-
return args.Get(0).(cciptypes.SeqNum), args.Error(1)
107-
}
108-
109-
func (m *MockChainAccessor) LatestMessageTo(
110-
ctx context.Context,
111-
dest cciptypes.ChainSelector,
112-
) (cciptypes.SeqNum, error) {
113-
args := m.Called(ctx, dest)
114-
return args.Get(0).(cciptypes.SeqNum), args.Error(1)
115-
}
116-
117-
func (m *MockChainAccessor) GetExpectedNextSequenceNumber(
118-
ctx context.Context,
119-
dest cciptypes.ChainSelector,
120-
) (cciptypes.SeqNum, error) {
121-
args := m.Called(ctx, dest)
122-
return args.Get(0).(cciptypes.SeqNum), args.Error(1)
123-
}
124-
125-
func (m *MockChainAccessor) GetTokenPriceUSD(
126-
ctx context.Context,
127-
address cciptypes.UnknownAddress,
128-
) (cciptypes.TimestampedUnixBig, error) {
129-
args := m.Called(ctx, address)
130-
return args.Get(0).(cciptypes.TimestampedUnixBig), args.Error(1)
131-
}
132-
133-
func (m *MockChainAccessor) GetFeeQuoterDestChainConfig(
134-
ctx context.Context,
135-
dest cciptypes.ChainSelector,
136-
) (cciptypes.FeeQuoterDestChainConfig, error) {
137-
args := m.Called(ctx, dest)
138-
return args.Get(0).(cciptypes.FeeQuoterDestChainConfig), args.Error(1)
139-
}
140-
141-
func (m *MockChainAccessor) MessagesByTokenID(
142-
ctx context.Context,
143-
source, dest cciptypes.ChainSelector,
144-
tokens map[cciptypes.MessageTokenID]cciptypes.RampTokenAmount,
145-
) (map[cciptypes.MessageTokenID]cciptypes.Bytes, error) {
146-
args := m.Called(ctx, source, dest, tokens)
147-
return args.Get(0).(map[cciptypes.MessageTokenID]cciptypes.Bytes), args.Error(1)
148-
}
149-
150-
func (m *MockChainAccessor) GetFeedPricesUSD(
151-
ctx context.Context,
152-
tokens []cciptypes.UnknownEncodedAddress,
153-
tokenInfo map[cciptypes.UnknownEncodedAddress]cciptypes.TokenInfo,
154-
) (cciptypes.TokenPriceMap, error) {
155-
args := m.Called(ctx, tokens, tokenInfo)
156-
return args.Get(0).(cciptypes.TokenPriceMap), args.Error(1)
157-
}
158-
159-
func (m *MockChainAccessor) GetFeeQuoterTokenUpdates(
160-
ctx context.Context,
161-
tokensBytes []cciptypes.UnknownAddress,
162-
) (map[cciptypes.UnknownEncodedAddress]cciptypes.TimestampedUnixBig, error) {
163-
args := m.Called(ctx, tokensBytes)
164-
return args.Get(0).(map[cciptypes.UnknownEncodedAddress]cciptypes.TimestampedUnixBig), args.Error(1)
165-
}
166-
16714
func TestChainAccessorWrapper_PopulateTxHashEnabled(t *testing.T) {
16815
ctx := context.Background()
16916
chainSelector := cciptypes.ChainSelector(1)
@@ -186,8 +33,8 @@ func TestChainAccessorWrapper_PopulateTxHashEnabled(t *testing.T) {
18633
}
18734

18835
t.Run("TxHash is preserved when enabled", func(t *testing.T) {
189-
// Setup mock
190-
mockAccessor := new(MockChainAccessor)
36+
// Setup mock using auto-generated mock
37+
mockAccessor := ccipocr3mocks.NewMockChainAccessor(t)
19138
mockAccessor.On("MsgsBetweenSeqNums", ctx, chainSelector, seqNumRange).Return(messagesWithTxHash, nil)
19239

19340
// Create wrapper with flag enabled
@@ -204,8 +51,8 @@ func TestChainAccessorWrapper_PopulateTxHashEnabled(t *testing.T) {
20451
})
20552

20653
t.Run("TxHash is cleared when disabled", func(t *testing.T) {
207-
// Setup mock
208-
mockAccessor := new(MockChainAccessor)
54+
// Setup mock using auto-generated mock
55+
mockAccessor := ccipocr3mocks.NewMockChainAccessor(t)
20956
mockAccessor.On("MsgsBetweenSeqNums", ctx, chainSelector, seqNumRange).Return(messagesWithTxHash, nil)
21057

21158
// Create wrapper with flag disabled

0 commit comments

Comments
 (0)