@@ -354,7 +354,7 @@ func TestBlockWithTxsAndInvokeTXNV0(t *testing.T) {
354
354
// TestBlockWithTxsAndInvokeTXNV1 tests the BlockWithTxsAndInvokeTXNV1 function.
355
355
//
356
356
// The function tests the BlockWithTxsAndInvokeTXNV1 function by setting up a test configuration and a test set type.
357
- // It then initializes a fullBlockSepolia30436 variable with a Block struct and invokes the BlockWithTxs function with different test scenarios.
357
+ // It then initializes a fullBlockSepolia64159 variable with a Block struct and invokes the BlockWithTxs function with different test scenarios.
358
358
// The function compares the expected error with the actual error and checks if the BlockWithTxs function returns the correct block data.
359
359
// It also verifies the block hash, the number of transactions in the block, and the details of a specific transaction.
360
360
//
@@ -374,35 +374,42 @@ func TestBlockWithTxsAndInvokeTXNV1(t *testing.T) {
374
374
want * Block
375
375
}
376
376
377
- var fullBlockSepolia30436 = Block {
377
+ var fullBlockSepolia64159 = Block {
378
378
BlockHeader : BlockHeader {
379
- BlockHash : utils .TestHexToFelt (t , "0x10d2059db6d261fee740b515ed8b9c50955f03dd43c4729b24dc63278641926 " ),
380
- ParentHash : utils .TestHexToFelt (t , "0x2adc07a26d70e72a16775e26c45074f0216bc2e86e35bfe53743968480e4c1b " ),
379
+ BlockHash : utils .TestHexToFelt (t , "0x6df565874b2ea6a02d346a23f9efb0b26abbf5708b51bb12587f88a49052964 " ),
380
+ ParentHash : utils .TestHexToFelt (t , "0x1406ec9385293905d6c20e9c5aa0bbf9f63f87d39cf12fcdfef3ed0d056c0f5 " ),
381
381
SequencerAddress : utils .TestHexToFelt (t , "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8" ),
382
- BlockNumber : 30436 ,
383
- NewRoot : utils .TestHexToFelt (t , "0x4bbb6bec9488d70d9c9e96862cf50e22331a5e8d7b33a56712f56cd04c16e06 " ),
384
- Timestamp : 1661450764 ,
382
+ BlockNumber : 64159 ,
383
+ NewRoot : utils .TestHexToFelt (t , "0x310be818a18de0d6f6c1391f467d0dbd1a2753e6dde876449448465f8e617f0 " ),
384
+ Timestamp : 1714901729 ,
385
385
},
386
386
Status : "ACCEPTED_ON_L1" ,
387
387
Transactions : []BlockTransaction {
388
388
389
389
BlockInvokeTxnV1 {
390
- TransactionHash : utils .TestHexToFelt (t , "0x10d2059db6d261fee740b515ed8b9c50955f03dd43c4729b24dc63278641926 " ),
390
+ TransactionHash : utils .TestHexToFelt (t , "0x5f14364b746abcfdfc0280877ff6d18c311d363e62264d7f218c5da2d396acc " ),
391
391
InvokeTxnV1 : InvokeTxnV1 {
392
- Type : "INVOKE" ,
393
- Nonce : utils .TestHexToFelt (t , "0x12562" ),
394
- MaxFee : utils .TestHexToFelt (t , "0x470de4df820000" ),
395
- Version : TransactionV1 ,
392
+ Type : "INVOKE" ,
393
+ Version : TransactionV1 ,
394
+ Nonce : utils .TestHexToFelt (t , "0x33" ),
395
+ MaxFee : utils .TestHexToFelt (t , "0x1bad55a98e1c1" ),
396
+ SenderAddress : utils .TestHexToFelt (t , "0x3543d2f0290e39a08cfdf2245f14aec7dca60672b7c7458375f3cb3834e1067" ),
396
397
Signature : []* felt.Felt {
397
- utils .TestHexToFelt (t , "0x7fb440b1dee35c5259bf10d55782bc973434d195bb5c8b95ac7d3d8e2a8a0e4" ),
398
- utils .TestHexToFelt (t , "0x3e16f111f8a22cb484b09d2554fca1e669cd540c5ad7cf2b9878071a9b95693" ),
398
+ utils .TestHexToFelt (t , "0x1" ),
399
+ utils .TestHexToFelt (t , "0x7bc0a22005a54ec6a005c1e89ab0201cbd0819621edd9fe4d5ef177a4ff33dd" ),
400
+ utils .TestHexToFelt (t , "0x13089e5f38de4ea98e9275be7fadc915946be15c14a8fed7c55202818527bea" ),
399
401
},
400
- SenderAddress : utils .TestHexToFelt (t , "0x35acd6dd6c5045d18ca6d0192af46b335a5402c02d41f46e4e77ea2c951d9a3" ),
401
402
Calldata : []* felt.Felt {
402
403
utils .TestHexToFelt (t , "0x1" ),
403
- utils .TestHexToFelt (t , "0x3fe8e4571772bbe0065e271686bd655efd1365a5d6858981e582f82f2c10313" ),
404
- utils .TestHexToFelt (t , "0x2468d193cd15b621b24c2a602b8dbcfa5eaa14f88416c40c09d7fd12592cb4b" ),
405
- utils .TestHexToFelt (t , "0x0" ),
404
+ utils .TestHexToFelt (t , "0x517567ac7026ce129c950e6e113e437aa3c83716cd61481c6bb8c5057e6923e" ),
405
+ utils .TestHexToFelt (t , "0xcaffbd1bd76bd7f24a3fa1d69d1b2588a86d1f9d2359b13f6a84b7e1cbd126" ),
406
+ utils .TestHexToFelt (t , "0x6" ),
407
+ utils .TestHexToFelt (t , "0x5265706f73736573734275696c64696e67" ),
408
+ utils .TestHexToFelt (t , "0x4" ),
409
+ utils .TestHexToFelt (t , "0x5" ),
410
+ utils .TestHexToFelt (t , "0x1b48" ),
411
+ utils .TestHexToFelt (t , "0x1" ),
412
+ utils .TestHexToFelt (t , "0xe52" ),
406
413
},
407
414
},
408
415
},
@@ -413,70 +420,37 @@ func TestBlockWithTxsAndInvokeTXNV1(t *testing.T) {
413
420
"mock" : {},
414
421
"testnet" : {
415
422
{
416
- BlockID : WithBlockTag ("latest" ),
417
- ExpectedError : nil ,
418
- },
419
- {
420
- BlockID : WithBlockHash (utils .TestHexToFelt (t , "0x2488a7149327b4dcd200f05a131911bd44f946021539648642eaa7d6e82f289" )),
421
- LookupTxnPositionInExpected : 0 ,
422
- LookupTxnPositionInOriginal : 0 ,
423
+ BlockID : WithBlockNumber (64159 ),
423
424
ExpectedError : nil ,
424
- want : & fullBlockSepolia30436 ,
425
- },
426
- {
427
- BlockID : WithBlockNumber (30436 ),
425
+ want : & fullBlockSepolia64159 ,
428
426
LookupTxnPositionInExpected : 0 ,
429
- LookupTxnPositionInOriginal : 0 ,
430
- ExpectedError : nil ,
431
- want : & fullBlockSepolia30436 ,
427
+ LookupTxnPositionInOriginal : 4 ,
432
428
},
433
429
},
434
430
"mainnet" : {},
435
431
}[testEnv ]
436
432
433
+ require := require .New (t )
437
434
for _ , test := range testSet {
438
435
spy := NewSpy (testConfig .provider .c )
439
436
testConfig .provider .c = spy
440
437
blockWithTxsInterface , err := testConfig .provider .BlockWithTxs (context .Background (), test .BlockID )
441
- if err != test .ExpectedError {
442
- t .Fatal ("BlockWithTxHashes match the expected error:" , err )
443
- }
444
- if test .ExpectedError != nil && blockWithTxsInterface == nil {
445
- continue
446
- }
438
+ require .NoError (err , "Unable to fetch the given block." )
439
+
447
440
blockWithTxs , ok := blockWithTxsInterface .(* Block )
448
- if ! ok {
449
- t .Fatalf ("expecting *rpv02.Block, instead %T" , blockWithTxsInterface )
450
- }
451
- _ , err = spy .Compare (blockWithTxs , false )
452
- if err != nil {
453
- t .Fatal ("expecting to match" , err )
454
- }
455
- if ! strings .HasPrefix (blockWithTxs .BlockHash .String (), "0x" ) {
456
- t .Fatal ("Block Hash should start with \" 0x\" , instead" , blockWithTxs .BlockHash )
457
- }
441
+ require .True (ok , "Failed to assert the Interface as *Block." )
442
+ require .Equal (blockWithTxs .BlockHash .String ()[:2 ], "0x" , "Block Hash should start with \" 0x\" ." )
443
+ require .NotEqual (len (blockWithTxs .Transactions ), 0 , "The number of transaction should not be 0." )
458
444
459
- if len (blockWithTxs .Transactions ) == 0 {
460
- t .Fatal ("the number of transaction should not be 0" )
461
- }
445
+ invokeV1Want , ok := (* test .want ).Transactions [test .LookupTxnPositionInExpected ].(BlockInvokeTxnV1 )
446
+ require .True (ok , "Expected invoke v1 transaction." )
462
447
463
- if test .want != nil {
464
- if (* test .want ).BlockHash == & felt .Zero {
465
- continue
466
- }
448
+ invokeV1Block , ok := blockWithTxs .Transactions [test .LookupTxnPositionInOriginal ].(BlockInvokeTxnV1 )
449
+ require .True (ok , "Expected invoke v1 transaction." )
467
450
468
- invokeV1Want , ok := (* test .want ).Transactions [test .LookupTxnPositionInExpected ].(BlockInvokeTxnV1 )
469
- if ! ok {
470
- t .Fatal ("expected invoke v1 transaction" )
471
- }
472
- invokeV1Block , ok := blockWithTxs .Transactions [test .LookupTxnPositionInOriginal ].(BlockInvokeTxnV1 )
473
- if ! ok {
474
- t .Fatal ("expected invoke v1 transaction" )
475
- }
476
- require .Equal (t , invokeV1Want .TransactionHash , invokeV1Block .TransactionHash , "expected equal TransactionHash" )
477
- require .Equal (t , invokeV1Want .InvokeTxnV1 .MaxFee , invokeV1Block .InvokeTxnV1 .MaxFee , "expected equal maxfee" )
478
- require .Equal (t , invokeV1Want .InvokeTxnV1 .SenderAddress , invokeV1Block .InvokeTxnV1 .SenderAddress , "expected equal senders addresses" )
479
- }
451
+ require .Equal (invokeV1Want .TransactionHash .String (), invokeV1Block .TransactionHash .String (), "Expected equal TransactionHash." )
452
+ require .Equal (invokeV1Want .InvokeTxnV1 .MaxFee .String (), invokeV1Block .InvokeTxnV1 .MaxFee .String (), "Expected equal maxfee." )
453
+ require .Equal (invokeV1Want .InvokeTxnV1 .Calldata [1 ].String (), invokeV1Block .InvokeTxnV1 .Calldata [1 ].String (), "Expected equal calldatas." )
480
454
}
481
455
}
482
456
0 commit comments