erigon-pulse/cmd/rpcdaemon/commands/eth_call_test.go
2021-06-29 14:40:23 +07:00

41 lines
1.4 KiB
Go

package commands
import (
"context"
"fmt"
"testing"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/internal/ethapi"
"github.com/ledgerwatch/erigon/rpc"
)
func TestEstimateGas(t *testing.T) {
db := rpcdaemontest.CreateTestKV(t)
api := NewEthAPI(NewBaseApi(nil), db, nil, nil, nil, 5000000)
var from = common.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
var to = common.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e")
if _, err := api.EstimateGas(context.Background(), ethapi.CallArgs{
From: &from,
To: &to,
}, nil); err != nil {
t.Errorf("calling EstimateGas: %v", err)
}
}
func TestEthCallNonCanonical(t *testing.T) {
db := rpcdaemontest.CreateTestKV(t)
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)
}
}
}