2021-03-02 22:47:44 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-06-11 12:19:10 +00:00
|
|
|
"fmt"
|
2021-03-02 22:47:44 +00:00
|
|
|
"testing"
|
|
|
|
|
2021-06-29 10:00:22 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/internal/ethapi"
|
2021-06-11 12:19:10 +00:00
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
2021-03-02 22:47:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestEstimateGas(t *testing.T) {
|
2021-06-29 10:00:22 +00:00
|
|
|
db := rpcdaemontest.CreateTestKV(t)
|
2021-05-17 12:15:19 +00:00
|
|
|
api := NewEthAPI(NewBaseApi(nil), db, nil, nil, nil, 5000000)
|
2021-03-02 22:47:44 +00:00
|
|
|
var from = common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
|
|
|
|
var to = common.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e")
|
|
|
|
if _, err := api.EstimateGas(context.Background(), ethapi.CallArgs{
|
|
|
|
From: &from,
|
|
|
|
To: &to,
|
2021-03-31 04:32:52 +00:00
|
|
|
}, nil); err != nil {
|
2021-03-02 22:47:44 +00:00
|
|
|
t.Errorf("calling EstimateGas: %v", err)
|
|
|
|
}
|
|
|
|
}
|
2021-06-11 12:19:10 +00:00
|
|
|
|
|
|
|
func TestEthCallNonCanonical(t *testing.T) {
|
2021-06-29 10:00:22 +00:00
|
|
|
db := rpcdaemontest.CreateTestKV(t)
|
2021-06-11 12:19:10 +00:00
|
|
|
api := NewEthAPI(NewBaseApi(nil), db, nil, nil, nil, 5000000)
|
|
|
|
var from = common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
|
|
|
|
var to = common.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e")
|
|
|
|
if _, err := api.Call(context.Background(), ethapi.CallArgs{
|
|
|
|
From: &from,
|
|
|
|
To: &to,
|
|
|
|
}, rpc.BlockNumberOrHashWithHash(common.HexToHash("0x3fcb7c0d4569fddc89cbea54b42f163e0c789351d98810a513895ab44b47020b"), true), nil); err != nil {
|
|
|
|
if fmt.Sprintf("%v", err) != "hash 3fcb7c0d4569fddc89cbea54b42f163e0c789351d98810a513895ab44b47020b is not currently canonical" {
|
|
|
|
t.Errorf("wrong error: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|