|
|
|
@ -285,6 +285,9 @@ func TestEthClient(t *testing.T) { |
|
|
|
|
"CallContract": { |
|
|
|
|
func(t *testing.T) { testCallContract(t, client) }, |
|
|
|
|
}, |
|
|
|
|
"CallContractAtHash": { |
|
|
|
|
func(t *testing.T) { testCallContractAtHash(t, client) }, |
|
|
|
|
}, |
|
|
|
|
"AtFunctions": { |
|
|
|
|
func(t *testing.T) { testAtFunctions(t, client) }, |
|
|
|
|
}, |
|
|
|
@ -507,6 +510,33 @@ func testStatusFunctions(t *testing.T, client *rpc.Client) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func testCallContractAtHash(t *testing.T, client *rpc.Client) { |
|
|
|
|
ec := NewClient(client) |
|
|
|
|
|
|
|
|
|
// EstimateGas
|
|
|
|
|
msg := ethereum.CallMsg{ |
|
|
|
|
From: testAddr, |
|
|
|
|
To: &common.Address{}, |
|
|
|
|
Gas: 21000, |
|
|
|
|
Value: big.NewInt(1), |
|
|
|
|
} |
|
|
|
|
gas, err := ec.EstimateGas(context.Background(), msg) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("unexpected error: %v", err) |
|
|
|
|
} |
|
|
|
|
if gas != 21000 { |
|
|
|
|
t.Fatalf("unexpected gas price: %v", gas) |
|
|
|
|
} |
|
|
|
|
block, err := ec.HeaderByNumber(context.Background(), big.NewInt(1)) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("BlockByNumber error: %v", err) |
|
|
|
|
} |
|
|
|
|
// CallContract
|
|
|
|
|
if _, err := ec.CallContractAtHash(context.Background(), msg, block.Hash()); err != nil { |
|
|
|
|
t.Fatalf("unexpected error: %v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func testCallContract(t *testing.T, client *rpc.Client) { |
|
|
|
|
ec := NewClient(client) |
|
|
|
|
|
|
|
|
|