@@ -285,6 +285,9 @@ func TestEthClient(t *testing.T) {
285
285
"CallContract" : {
286
286
func (t * testing.T ) { testCallContract (t , client ) },
287
287
},
288
+ "CallContractAtHash" : {
289
+ func (t * testing.T ) { testCallContractAtHash (t , client ) },
290
+ },
288
291
"AtFunctions" : {
289
292
func (t * testing.T ) { testAtFunctions (t , client ) },
290
293
},
@@ -507,6 +510,33 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
507
510
}
508
511
}
509
512
513
+ func testCallContractAtHash (t * testing.T , client * rpc.Client ) {
514
+ ec := NewClient (client )
515
+
516
+ // EstimateGas
517
+ msg := ethereum.CallMsg {
518
+ From : testAddr ,
519
+ To : & common.Address {},
520
+ Gas : 21000 ,
521
+ Value : big .NewInt (1 ),
522
+ }
523
+ gas , err := ec .EstimateGas (context .Background (), msg )
524
+ if err != nil {
525
+ t .Fatalf ("unexpected error: %v" , err )
526
+ }
527
+ if gas != 21000 {
528
+ t .Fatalf ("unexpected gas price: %v" , gas )
529
+ }
530
+ block , err := ec .HeaderByNumber (context .Background (), big .NewInt (1 ))
531
+ if err != nil {
532
+ t .Fatalf ("BlockByNumber error: %v" , err )
533
+ }
534
+ // CallContract
535
+ if _ , err := ec .CallContractAtHash (context .Background (), msg , block .Hash ()); err != nil {
536
+ t .Fatalf ("unexpected error: %v" , err )
537
+ }
538
+ }
539
+
510
540
func testCallContract (t * testing.T , client * rpc.Client ) {
511
541
ec := NewClient (client )
512
542
0 commit comments