@@ -151,11 +151,20 @@ func TestCCIPChainReader_Sync_HappyPath_BindsContractsSuccessfully(t *testing.T)
151151 s1Onramp := []byte {0x1 }
152152 s2Onramp := []byte {0x2 }
153153 destNonceMgr := []byte {0x3 }
154+ offRamp := []byte {0x4 }
154155
155156 mockAddrCodec := internal .NewMockAddressCodecHex (t )
156157 destNonceMgrAddrStr , err := mockAddrCodec .AddressBytesToString (destNonceMgr , destChain )
157158 require .NoError (t , err )
159+ offRampAddrStr , err := mockAddrCodec .AddressBytesToString (offRamp , destChain )
160+ require .NoError (t , err )
158161 destExtended := reader_mocks .NewMockExtended (t )
162+ destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
163+ {
164+ Name : consts .ContractNameOffRamp ,
165+ Address : offRampAddrStr ,
166+ },
167+ }).Return (nil )
159168 destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
160169 {
161170 Name : consts .ContractNameNonceManager ,
@@ -187,17 +196,26 @@ func TestCCIPChainReader_Sync_HappyPath_BindsContractsSuccessfully(t *testing.T)
187196 defer source1Extended .AssertExpectations (t )
188197 defer source2Extended .AssertExpectations (t )
189198
190- ccipReader := & ccipChainReader {
191- contractReaders : map [cciptypes.ChainSelector ]contractreader.Extended {
199+ cw := writer_mocks .NewMockContractWriter (t )
200+ contractWriters := make (map [cciptypes.ChainSelector ]types.ContractWriter )
201+ contractWriters [destChain ] = cw
202+ contractWriters [sourceChain1 ] = cw
203+ contractWriters [sourceChain2 ] = cw
204+
205+ ccipReader , err := newCCIPChainReaderInternal (
206+ ctx ,
207+ logger .Test (t ),
208+ map [cciptypes.ChainSelector ]contractreader.ContractReaderFacade {
192209 destChain : destExtended ,
193210 sourceChain1 : source1Extended ,
194211 sourceChain2 : source2Extended ,
195212 },
196- donAddressBook : addressbook .NewBook (),
197- destChain : destChain ,
198- lggr : logger .Test (t ),
199- addrCodec : mockAddrCodec ,
200- }
213+ contractWriters ,
214+ destChain ,
215+ offRamp ,
216+ mockAddrCodec ,
217+ )
218+ require .NoError (t , err )
201219
202220 contracts := ContractAddresses {
203221 consts .ContractNameOnRamp : {
@@ -211,6 +229,8 @@ func TestCCIPChainReader_Sync_HappyPath_BindsContractsSuccessfully(t *testing.T)
211229
212230 err = ccipReader .Sync (ctx , contracts )
213231 require .NoError (t , err )
232+ err = ccipReader .Close ()
233+ require .NoError (t , err )
214234}
215235
216236func TestCCIPChainReader_Sync_HappyPath_SkipsEmptyAddress (t * testing.T ) {
@@ -219,6 +239,7 @@ func TestCCIPChainReader_Sync_HappyPath_SkipsEmptyAddress(t *testing.T) {
219239 sourceChain1 := cciptypes .ChainSelector (2 )
220240 sourceChain2 := cciptypes .ChainSelector (3 )
221241 s1Onramp := []byte {0x1 }
242+ offRamp := []byte {0x4 }
222243
223244 // empty address, should get skipped
224245 s2Onramp := []byte {}
@@ -228,6 +249,14 @@ func TestCCIPChainReader_Sync_HappyPath_SkipsEmptyAddress(t *testing.T) {
228249 mockAddrCodec := internal .NewMockAddressCodecHex (t )
229250 destNonceMgrAddrStr , err := mockAddrCodec .AddressBytesToString (destNonceMgr , destChain )
230251 require .NoError (t , err )
252+ offRampAddrStr , err := mockAddrCodec .AddressBytesToString (offRamp , destChain )
253+ require .NoError (t , err )
254+ destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
255+ {
256+ Name : consts .ContractNameOffRamp ,
257+ Address : offRampAddrStr ,
258+ },
259+ }).Return (nil )
231260 destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
232261 {
233262 Name : consts .ContractNameNonceManager ,
@@ -252,17 +281,26 @@ func TestCCIPChainReader_Sync_HappyPath_SkipsEmptyAddress(t *testing.T) {
252281 defer source1Extended .AssertExpectations (t )
253282 defer source2Extended .AssertExpectations (t )
254283
255- ccipReader := & ccipChainReader {
256- contractReaders : map [cciptypes.ChainSelector ]contractreader.Extended {
284+ cw := writer_mocks .NewMockContractWriter (t )
285+ contractWriters := make (map [cciptypes.ChainSelector ]types.ContractWriter )
286+ contractWriters [destChain ] = cw
287+ contractWriters [sourceChain1 ] = cw
288+ contractWriters [sourceChain2 ] = cw
289+
290+ ccipReader , err := newCCIPChainReaderInternal (
291+ ctx ,
292+ logger .Test (t ),
293+ map [cciptypes.ChainSelector ]contractreader.ContractReaderFacade {
257294 destChain : destExtended ,
258295 sourceChain1 : source1Extended ,
259296 sourceChain2 : source2Extended ,
260297 },
261- donAddressBook : addressbook .NewBook (),
262- destChain : destChain ,
263- lggr : logger .Test (t ),
264- addrCodec : mockAddrCodec ,
265- }
298+ contractWriters ,
299+ destChain ,
300+ offRamp ,
301+ mockAddrCodec ,
302+ )
303+ require .NoError (t , err )
266304
267305 contracts := ContractAddresses {
268306 consts .ContractNameOnRamp : {
@@ -276,6 +314,8 @@ func TestCCIPChainReader_Sync_HappyPath_SkipsEmptyAddress(t *testing.T) {
276314
277315 err = ccipReader .Sync (ctx , contracts )
278316 require .NoError (t , err )
317+ err = ccipReader .Close ()
318+ require .NoError (t , err )
279319}
280320
281321func TestCCIPChainReader_Sync_HappyPath_DontSupportAllChains (t * testing.T ) {
@@ -286,11 +326,20 @@ func TestCCIPChainReader_Sync_HappyPath_DontSupportAllChains(t *testing.T) {
286326 s1Onramp := []byte {0x1 }
287327 s2Onramp := []byte {0x2 }
288328 destNonceMgr := []byte {0x3 }
329+ offRamp := []byte {0x4 }
289330 destExtended := reader_mocks .NewMockExtended (t )
290331 mockAddrCodec := internal .NewMockAddressCodecHex (t )
291332
292333 destNonceMgrAddrStr , err := mockAddrCodec .AddressBytesToString (destNonceMgr , destChain )
293334 require .NoError (t , err )
335+ offRampAddrStr , err := mockAddrCodec .AddressBytesToString (offRamp , destChain )
336+ require .NoError (t , err )
337+ destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
338+ {
339+ Name : consts .ContractNameOffRamp ,
340+ Address : offRampAddrStr ,
341+ },
342+ }).Return (nil )
294343 destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
295344 {
296345 Name : consts .ContractNameNonceManager ,
@@ -312,16 +361,24 @@ func TestCCIPChainReader_Sync_HappyPath_DontSupportAllChains(t *testing.T) {
312361 defer destExtended .AssertExpectations (t )
313362 defer source2Extended .AssertExpectations (t )
314363
315- ccipReader := & ccipChainReader {
316- contractReaders : map [cciptypes.ChainSelector ]contractreader.Extended {
364+ cw := writer_mocks .NewMockContractWriter (t )
365+ contractWriters := make (map [cciptypes.ChainSelector ]types.ContractWriter )
366+ contractWriters [destChain ] = cw
367+ contractWriters [sourceChain2 ] = cw
368+
369+ ccipReader , err := newCCIPChainReaderInternal (
370+ ctx ,
371+ logger .Test (t ),
372+ map [cciptypes.ChainSelector ]contractreader.ContractReaderFacade {
317373 destChain : destExtended ,
318374 sourceChain2 : source2Extended ,
319375 },
320- donAddressBook : addressbook .NewBook (),
321- destChain : destChain ,
322- lggr : logger .Test (t ),
323- addrCodec : mockAddrCodec ,
324- }
376+ contractWriters ,
377+ destChain ,
378+ offRamp ,
379+ mockAddrCodec ,
380+ )
381+ require .NoError (t , err )
325382
326383 contracts := ContractAddresses {
327384 consts .ContractNameOnRamp : {
@@ -335,6 +392,8 @@ func TestCCIPChainReader_Sync_HappyPath_DontSupportAllChains(t *testing.T) {
335392
336393 err = ccipReader .Sync (ctx , contracts )
337394 require .NoError (t , err )
395+ err = ccipReader .Close ()
396+ require .NoError (t , err )
338397}
339398
340399func TestCCIPChainReader_Sync_BindError (t * testing.T ) {
@@ -345,11 +404,20 @@ func TestCCIPChainReader_Sync_BindError(t *testing.T) {
345404 s1Onramp := []byte {0x1 }
346405 s2Onramp := []byte {0x2 }
347406 destNonceMgr := []byte {0x3 }
407+ offRamp := []byte {0x4 }
348408
349409 mockAddrCodec := internal .NewMockAddressCodecHex (t )
350410 destNonceMgrAddrStr , err := mockAddrCodec .AddressBytesToString (destNonceMgr , destChain )
351411 require .NoError (t , err )
412+ offRampAddrStr , err := mockAddrCodec .AddressBytesToString (offRamp , destChain )
413+ require .NoError (t , err )
352414 destExtended := reader_mocks .NewMockExtended (t )
415+ destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
416+ {
417+ Name : consts .ContractNameOffRamp ,
418+ Address : offRampAddrStr ,
419+ },
420+ }).Return (nil )
353421 destExtended .EXPECT ().Bind (mock .Anything , []types.BoundContract {
354422 {
355423 Name : consts .ContractNameNonceManager ,
@@ -382,17 +450,26 @@ func TestCCIPChainReader_Sync_BindError(t *testing.T) {
382450 defer source1Extended .AssertExpectations (t )
383451 defer source2Extended .AssertExpectations (t )
384452
385- ccipReader := & ccipChainReader {
386- contractReaders : map [cciptypes.ChainSelector ]contractreader.Extended {
453+ cw := writer_mocks .NewMockContractWriter (t )
454+ contractWriters := make (map [cciptypes.ChainSelector ]types.ContractWriter )
455+ contractWriters [destChain ] = cw
456+ contractWriters [sourceChain1 ] = cw
457+ contractWriters [sourceChain2 ] = cw
458+
459+ ccipReader , err := newCCIPChainReaderInternal (
460+ ctx ,
461+ logger .Test (t ),
462+ map [cciptypes.ChainSelector ]contractreader.ContractReaderFacade {
387463 destChain : destExtended ,
388464 sourceChain1 : source1Extended ,
389465 sourceChain2 : source2Extended ,
390466 },
391- donAddressBook : addressbook .NewBook (),
392- destChain : destChain ,
393- lggr : logger .Test (t ),
394- addrCodec : mockAddrCodec ,
395- }
467+ contractWriters ,
468+ destChain ,
469+ offRamp ,
470+ mockAddrCodec ,
471+ )
472+ require .NoError (t , err )
396473
397474 contracts := ContractAddresses {
398475 consts .ContractNameOnRamp : {
@@ -407,6 +484,8 @@ func TestCCIPChainReader_Sync_BindError(t *testing.T) {
407484 err = ccipReader .Sync (ctx , contracts )
408485 require .Error (t , err )
409486 require .ErrorIs (t , err , expectedErr )
487+ err = ccipReader .Close ()
488+ require .NoError (t , err )
410489}
411490
412491// The round1 version returns NoBindingFound errors for onramp contracts to simulate
0 commit comments