@@ -285,6 +285,9 @@ func TestEthClient(t *testing.T) {
285285 "CallContract" : {
286286 func (t * testing.T ) { testCallContract (t , client ) },
287287 },
288+ "CallContractAtHash" : {
289+ func (t * testing.T ) { testCallContractAtHash (t , client ) },
290+ },
288291 "AtFunctions" : {
289292 func (t * testing.T ) { testAtFunctions (t , client ) },
290293 },
@@ -507,6 +510,33 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) {
507510 }
508511}
509512
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+
510540func testCallContract (t * testing.T , client * rpc.Client ) {
511541 ec := NewClient (client )
512542
0 commit comments