@@ -46,12 +46,11 @@ func TestBlockNumber(t *testing.T) {
46
46
blockNumber , err := testConfig .provider .BlockNumber (context .Background ())
47
47
require .NoError (t , err , "BlockNumber should not return an error" )
48
48
49
- if diff , err := spy .Compare (blockNumber , false ); err != nil || diff != "FullMatch" {
50
- t .Fatal ("expecting to match" , err )
51
- }
52
- if blockNumber <= 3000 {
53
- t .Fatal ("Block number should be > 3000, instead: " , blockNumber )
54
- }
49
+ diff , err := spy .Compare (blockNumber , false )
50
+ require .NoError (t , err , "expecting to match" )
51
+ require .Equal (t , "FullMatch" , diff , "expecting to match, instead %s" , diff )
52
+
53
+ require .False (t , blockNumber <= 3000 , fmt .Sprintf ("Block number should be > 3000, instead: %d" , blockNumber ))
55
54
}
56
55
}
57
56
@@ -90,15 +89,13 @@ func TestBlockHashAndNumber(t *testing.T) {
90
89
blockHashAndNumber , err := testConfig .provider .BlockHashAndNumber (context .Background ())
91
90
require .NoError (t , err , "BlockHashAndNumber should not return an error" )
92
91
93
- if diff , err := spy .Compare (blockHashAndNumber , false ); err != nil || diff != "FullMatch" {
94
- t .Fatal ("expecting to match" , err )
95
- }
96
- if blockHashAndNumber .BlockNumber < 3000 {
97
- t .Fatal ("Block number should be > 3000, instead: " , blockHashAndNumber .BlockNumber )
98
- }
99
- if ! strings .HasPrefix (blockHashAndNumber .BlockHash .String (), "0x" ) {
100
- t .Fatal ("current block hash should return a string starting with 0x" )
101
- }
92
+ diff , err := spy .Compare (blockHashAndNumber , false )
93
+ require .NoError (t , err , "expecting to match" )
94
+ require .Equal (t , "FullMatch" , diff , "expecting to match, instead %s" , diff )
95
+
96
+ require .False (t , blockHashAndNumber .BlockNumber <= 3000 , "Block number should be > 3000, instead: %d" , blockHashAndNumber .BlockNumber )
97
+
98
+ require .True (t , strings .HasPrefix (blockHashAndNumber .BlockHash .String (), "0x" ), "current block hash should return a string starting with 0x" )
102
99
}
103
100
}
104
101
@@ -238,13 +235,10 @@ func TestBlockWithTxHashes(t *testing.T) {
238
235
if test .ExpectedErr != nil {
239
236
continue
240
237
}
241
- if ! strings .HasPrefix (block .BlockHash .String (), "0x" ) {
242
- t .Fatal ("Block Hash should start with \" 0x\" , instead" , block .BlockHash )
243
- }
244
238
245
- if len (block .Transactions ) == 0 {
246
- t . Fatal ( "the number of transaction should not be 0" )
247
- }
239
+ require . True ( t , strings . HasPrefix (block .BlockHash . String (), "0x" ), "Block Hash should start with \" 0x \" , instead: %s" , block . BlockHash )
240
+ require . NotEmpty ( t , block . Transactions , "the number of transactions should not be 0" )
241
+
248
242
if test .ExpectedBlockWithTxHashes != nil {
249
243
if (* test .ExpectedBlockWithTxHashes ).BlockHash == & felt .Zero {
250
244
continue
@@ -315,13 +309,8 @@ func TestBlockWithTxsAndInvokeTXNV0(t *testing.T) {
315
309
_ , err = spy .Compare (blockWithTxs , false )
316
310
require .NoError (t , err , "expecting to match" )
317
311
318
- if ! strings .HasPrefix (blockWithTxs .BlockHash .String (), "0x" ) {
319
- t .Fatal ("Block Hash should start with \" 0x\" , instead" , blockWithTxs .BlockHash )
320
- }
321
-
322
- if len (blockWithTxs .Transactions ) == 0 {
323
- t .Fatal ("the number of transaction should not be 0" )
324
- }
312
+ require .True (t , strings .HasPrefix (blockWithTxs .BlockHash .String (), "0x" ), "Block Hash should start with \" 0x\" , instead: %s" , blockWithTxs .BlockHash )
313
+ require .NotEmpty (t , blockWithTxs .Transactions , "the number of transactions should not be 0" )
325
314
326
315
if test .want != nil {
327
316
if (* test .want ).BlockHash == & felt .Zero {
@@ -789,26 +778,20 @@ func TestBlockWithTxsAndDeployOrDeclare(t *testing.T) {
789
778
require .NoError (t , err , "Expected to compare the BlockWithTxs." )
790
779
791
780
if diff != "FullMatch" {
792
- if _ , err := spy .Compare (blockWithTxs , false ); err != nil {
793
- t .Fatal (err )
794
- }
795
- }
796
- if ! strings .HasPrefix (blockWithTxs .BlockHash .String (), "0x" ) {
797
- t .Fatal ("Block Hash should start with \" 0x\" , instead" , blockWithTxs .BlockHash )
781
+ _ , err = spy .Compare (blockWithTxs , false )
782
+ require .NoError (t , err , "Unable to compare the count." )
798
783
}
799
784
800
- if len (blockWithTxs .Transactions ) == 0 {
801
- t . Fatal ( "the number of transaction should not be 0" )
802
- }
785
+ require . True ( t , strings . HasPrefix (blockWithTxs .BlockHash . String (), "0x" ), "Block Hash should start with \" 0x \" , instead: %s" , blockWithTxs . BlockHash )
786
+ require . NotEmpty ( t , blockWithTxs . Transactions , "the number of transactions should not be 0" )
787
+
803
788
if test .ExpectedBlockWithTxs != nil {
804
789
if test .ExpectedBlockWithTxs .BlockHash == & felt .Zero {
805
790
continue
806
791
}
807
- if ! cmp .Equal (test .ExpectedBlockWithTxs .Transactions [test .LookupTxnPositionInExpected ], blockWithTxs .Transactions [test .LookupTxnPositionInOriginal ]) {
808
- t .Fatalf ("the expected transaction blocks to match, instead: %s" , cmp .Diff (test .ExpectedBlockWithTxs .Transactions [test .LookupTxnPositionInExpected ], blockWithTxs .Transactions [test .LookupTxnPositionInOriginal ]))
809
- }
792
+ require .True (t , cmp .Equal (test .ExpectedBlockWithTxs .Transactions [test .LookupTxnPositionInExpected ], blockWithTxs .Transactions [test .LookupTxnPositionInOriginal ]),
793
+ "the expected transaction blocks to match, instead: %s" , cmp .Diff (test .ExpectedBlockWithTxs .Transactions [test .LookupTxnPositionInExpected ], blockWithTxs .Transactions [test .LookupTxnPositionInOriginal ]))
810
794
}
811
-
812
795
}
813
796
}
814
797
0 commit comments