@@ -16,6 +16,7 @@ import (
16
16
"github.com/smartcontractkit/chainlink/deployment"
17
17
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
18
18
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
19
+ mlt "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers/messagelimitationstest"
19
20
testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip"
20
21
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/v1_2_0/router"
21
22
)
@@ -46,44 +47,47 @@ func Test_CCIPMessageLimitations(t *testing.T) {
46
47
require .NoError (t , err )
47
48
t .Logf ("0->1 destination config: %+v" , chain0DestConfig )
48
49
49
- testMsgs := []struct {
50
- name string
51
- fromChain uint64
52
- toChain uint64
53
- msg router.ClientEVM2AnyMessage
54
- expRevert bool
55
- }{
50
+ testSetup := mlt .NewTestSetup (
51
+ t ,
52
+ onChainState ,
53
+ chains [0 ],
54
+ chains [1 ],
55
+ srcToken .Address (),
56
+ chain0DestConfig ,
57
+ false , // testRouter
58
+ true , // validateResp
59
+ mlt .WithDeployedEnv (testEnv ),
60
+ )
61
+
62
+ tcs := []mlt.TestCase {
56
63
{
57
- name : "hit limit on data" ,
58
- fromChain : chains [0 ],
59
- toChain : chains [1 ],
60
- msg : router.ClientEVM2AnyMessage {
61
- Receiver : common .LeftPadBytes (onChainState .Chains [chains [1 ]].Receiver .Address ().Bytes (), 32 ),
62
- Data : []byte (strings .Repeat ("0" , int (chain0DestConfig .MaxDataBytes ))),
64
+ TestSetup : testSetup ,
65
+ Name : "hit limit on data" ,
66
+ Msg : router.ClientEVM2AnyMessage {
67
+ Receiver : common .LeftPadBytes (onChainState .Chains [testSetup .DestChain ].Receiver .Address ().Bytes (), 32 ),
68
+ Data : []byte (strings .Repeat ("0" , int (testSetup .SrcFeeQuoterDestChainConfig .MaxDataBytes ))),
63
69
FeeToken : common .HexToAddress ("0x0" ),
64
70
},
65
71
},
66
72
{
67
- name : "hit limit on tokens" ,
68
- fromChain : chains [0 ],
69
- toChain : chains [1 ],
70
- msg : router.ClientEVM2AnyMessage {
71
- Receiver : common .LeftPadBytes (onChainState .Chains [chains [1 ]].Receiver .Address ().Bytes (), 32 ),
73
+ TestSetup : testSetup ,
74
+ Name : "hit limit on tokens" ,
75
+ Msg : router.ClientEVM2AnyMessage {
76
+ Receiver : common .LeftPadBytes (onChainState .Chains [testSetup .DestChain ].Receiver .Address ().Bytes (), 32 ),
72
77
TokenAmounts : slices .Repeat ([]router.ClientEVMTokenAmount {
73
- {Token : srcToken . Address () , Amount : big .NewInt (1 )},
74
- }, int (chain0DestConfig .MaxNumberOfTokensPerMsg )),
78
+ {Token : testSetup . SrcToken , Amount : big .NewInt (1 )},
79
+ }, int (testSetup . SrcFeeQuoterDestChainConfig .MaxNumberOfTokensPerMsg )),
75
80
FeeToken : common .HexToAddress ("0x0" ),
76
81
},
77
82
},
78
83
{
79
- name : "hit limit on gas limit" ,
80
- fromChain : chains [0 ],
81
- toChain : chains [1 ],
82
- msg : router.ClientEVM2AnyMessage {
83
- Receiver : common .LeftPadBytes (onChainState .Chains [chains [1 ]].Receiver .Address ().Bytes (), 32 ),
84
- Data : []byte (strings .Repeat ("0" , int (chain0DestConfig .MaxDataBytes ))),
84
+ TestSetup : testSetup ,
85
+ Name : "hit limit on gas limit" ,
86
+ Msg : router.ClientEVM2AnyMessage {
87
+ Receiver : common .LeftPadBytes (onChainState .Chains [testSetup .DestChain ].Receiver .Address ().Bytes (), 32 ),
88
+ Data : []byte (strings .Repeat ("0" , int (testSetup .SrcFeeQuoterDestChainConfig .MaxDataBytes ))),
85
89
FeeToken : common .HexToAddress ("0x0" ),
86
- ExtraArgs : testhelpers .MakeEVMExtraArgsV2 (uint64 (chain0DestConfig .MaxPerMsgGasLimit ), true ),
90
+ ExtraArgs : testhelpers .MakeEVMExtraArgsV2 (uint64 (testSetup . SrcFeeQuoterDestChainConfig .MaxPerMsgGasLimit ), true ),
87
91
},
88
92
},
89
93
//{ // TODO: exec plugin never executed this message. CCIP-4471
@@ -101,45 +105,42 @@ func Test_CCIPMessageLimitations(t *testing.T) {
101
105
// },
102
106
//},
103
107
{
104
- name : "exceeding maxDataBytes" ,
105
- fromChain : chains [0 ],
106
- toChain : chains [1 ],
107
- msg : router.ClientEVM2AnyMessage {
108
- Receiver : common .LeftPadBytes (onChainState .Chains [chains [1 ]].Receiver .Address ().Bytes (), 32 ),
109
- Data : []byte (strings .Repeat ("0" , int (chain0DestConfig .MaxDataBytes )+ 1 )),
108
+ TestSetup : testSetup ,
109
+ Name : "exceeding maxDataBytes" ,
110
+ Msg : router.ClientEVM2AnyMessage {
111
+ Receiver : common .LeftPadBytes (onChainState .Chains [testSetup .DestChain ].Receiver .Address ().Bytes (), 32 ),
112
+ Data : []byte (strings .Repeat ("0" , int (testSetup .SrcFeeQuoterDestChainConfig .MaxDataBytes )+ 1 )),
110
113
TokenAmounts : []router.ClientEVMTokenAmount {},
111
114
FeeToken : common .HexToAddress ("0x0" ),
112
115
ExtraArgs : nil ,
113
116
},
114
- expRevert : true ,
117
+ ExpRevert : true ,
115
118
},
116
119
{
117
- name : "exceeding number of tokens" ,
118
- fromChain : chains [0 ],
119
- toChain : chains [1 ],
120
- msg : router.ClientEVM2AnyMessage {
121
- Receiver : common .LeftPadBytes (onChainState .Chains [chains [1 ]].Receiver .Address ().Bytes (), 32 ),
120
+ TestSetup : testSetup ,
121
+ Name : "exceeding number of tokens" ,
122
+ Msg : router.ClientEVM2AnyMessage {
123
+ Receiver : common .LeftPadBytes (onChainState .Chains [testSetup .DestChain ].Receiver .Address ().Bytes (), 32 ),
122
124
Data : []byte ("abc" ),
123
125
TokenAmounts : slices .Repeat ([]router.ClientEVMTokenAmount {
124
- {Token : srcToken . Address () , Amount : big .NewInt (1 )},
125
- }, int (chain0DestConfig .MaxNumberOfTokensPerMsg )+ 1 ),
126
+ {Token : testSetup . SrcToken , Amount : big .NewInt (1 )},
127
+ }, int (testSetup . SrcFeeQuoterDestChainConfig .MaxNumberOfTokensPerMsg )+ 1 ),
126
128
FeeToken : common .HexToAddress ("0x0" ),
127
129
ExtraArgs : nil ,
128
130
},
129
- expRevert : true ,
131
+ ExpRevert : true ,
130
132
},
131
133
{
132
- name : "exceeding gas limit" ,
133
- fromChain : chains [0 ],
134
- toChain : chains [1 ],
135
- msg : router.ClientEVM2AnyMessage {
136
- Receiver : common .LeftPadBytes (onChainState .Chains [chains [1 ]].Receiver .Address ().Bytes (), 32 ),
134
+ TestSetup : testSetup ,
135
+ Name : "exceeding gas limit" ,
136
+ Msg : router.ClientEVM2AnyMessage {
137
+ Receiver : common .LeftPadBytes (onChainState .Chains [testSetup .DestChain ].Receiver .Address ().Bytes (), 32 ),
137
138
Data : []byte ("abc" ),
138
139
TokenAmounts : []router.ClientEVMTokenAmount {},
139
140
FeeToken : common .HexToAddress ("0x0" ),
140
- ExtraArgs : testhelpers .MakeEVMExtraArgsV2 (uint64 (chain0DestConfig .MaxPerMsgGasLimit )+ 1 , true ),
141
+ ExtraArgs : testhelpers .MakeEVMExtraArgsV2 (uint64 (testSetup . SrcFeeQuoterDestChainConfig .MaxPerMsgGasLimit )+ 1 , true ),
141
142
},
142
- expRevert : true ,
143
+ ExpRevert : true ,
143
144
},
144
145
}
145
146
@@ -148,36 +149,22 @@ func Test_CCIPMessageLimitations(t *testing.T) {
148
149
// Send a message from each chain to every other chain.
149
150
expectedSeqNum := make (map [testhelpers.SourceDestPair ]uint64 )
150
151
expectedSeqNumExec := make (map [testhelpers.SourceDestPair ][]uint64 )
151
- for _ , msg := range testMsgs {
152
- t .Logf ("Sending msg: %s" , msg .name )
153
- require .NotEqual (t , msg .fromChain , msg .toChain , "fromChain and toChain cannot be the same" )
154
- startBlocks [msg .toChain ] = nil
155
- msgSentEvent , err := testhelpers .DoSendRequest (
156
- t , testEnv .Env , onChainState ,
157
- testhelpers .WithSourceChain (msg .fromChain ),
158
- testhelpers .WithDestChain (msg .toChain ),
159
- testhelpers .WithTestRouter (false ),
160
- testhelpers .WithEvm2AnyMessage (msg .msg ))
161
-
162
- if msg .expRevert {
163
- t .Logf ("Message reverted as expected" )
164
- require .Error (t , err )
165
- require .Contains (t , err .Error (), "execution reverted" )
166
- continue
167
- }
168
- require .NoError (t , err )
152
+ for _ , tc := range tcs {
153
+ startBlocks [tc .DestChain ] = nil
169
154
170
- t . Logf ( "Message not reverted as expected" )
155
+ tco := mlt . Run ( tc )
171
156
172
- expectedSeqNum [testhelpers.SourceDestPair {
173
- SourceChainSelector : msg .fromChain ,
174
- DestChainSelector : msg .toChain ,
175
- }] = msgSentEvent .SequenceNumber
157
+ if tco .MsgSentEvent != nil {
158
+ expectedSeqNum [testhelpers.SourceDestPair {
159
+ SourceChainSelector : tc .SrcChain ,
160
+ DestChainSelector : tc .DestChain ,
161
+ }] = tco .MsgSentEvent .SequenceNumber
176
162
177
- expectedSeqNumExec [testhelpers.SourceDestPair {
178
- SourceChainSelector : msg .fromChain ,
179
- DestChainSelector : msg .toChain ,
180
- }] = []uint64 {msgSentEvent .SequenceNumber }
163
+ expectedSeqNumExec [testhelpers.SourceDestPair {
164
+ SourceChainSelector : tc .SrcChain ,
165
+ DestChainSelector : tc .DestChain ,
166
+ }] = []uint64 {tco .MsgSentEvent .SequenceNumber }
167
+ }
181
168
}
182
169
183
170
// Wait for all commit reports to land.
0 commit comments