upgrade to ethermint v0.21.0 #99
@ -10,6 +10,7 @@ import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@ -269,8 +270,9 @@ func TestEth_Pending_GetTransactionByBlockNumberAndIndex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEth_Pending_GetTransactionByHash(t *testing.T) {
|
||||
sleep := 0 * time.Second
|
||||
// negative case, check that it returns empty.
|
||||
rpcRes := Call(t, "eth_getTransactionByHash", []interface{}{"0xec5fa15e1368d6ac314f9f64118c5794f076f63c02e66f97ea5fe1de761a8973"})
|
||||
rpcRes := CallWithSleep(t, "eth_getTransactionByHash", []interface{}{"0xec5fa15e1368d6ac314f9f64118c5794f076f63c02e66f97ea5fe1de761a8973"}, sleep)
|
||||
var tx map[string]interface{}
|
||||
err := json.Unmarshal(rpcRes.Result, &tx)
|
||||
require.NoError(t, err)
|
||||
@ -281,17 +283,17 @@ func TestEth_Pending_GetTransactionByHash(t *testing.T) {
|
||||
param := makePendingTxParams(t)
|
||||
param[0]["data"] = data
|
||||
|
||||
txRes := Call(t, "eth_sendTransaction", param)
|
||||
txRes := CallWithSleep(t, "eth_sendTransaction", param, sleep)
|
||||
var txHash common.Hash
|
||||
err = txHash.UnmarshalJSON(txRes.Result)
|
||||
require.NoError(t, err)
|
||||
|
||||
rpcRes = Call(t, "eth_getTransactionByHash", []interface{}{txHash})
|
||||
rpcRes = CallWithSleep(t, "eth_getTransactionByHash", []interface{}{txHash}, sleep)
|
||||
var pendingTx map[string]interface{}
|
||||
err = json.Unmarshal(rpcRes.Result, &pendingTx)
|
||||
require.NoError(t, err)
|
||||
|
||||
txsRes := Call(t, "eth_getPendingTransactions", []interface{}{})
|
||||
txsRes := CallWithSleep(t, "eth_getPendingTransactions", []interface{}{}, sleep)
|
||||
var pendingTxs []map[string]interface{}
|
||||
err = json.Unmarshal(txsRes.Result, &pendingTxs)
|
||||
require.NoError(t, err)
|
||||
|
@ -63,12 +63,14 @@ func CreateRequest(method string, params interface{}) Request {
|
||||
}
|
||||
}
|
||||
|
||||
func Call(t *testing.T, method string, params interface{}) *Response {
|
||||
func CallWithSleep(t *testing.T, method string, params interface{}, sleep time.Duration) *Response {
|
||||
req, err := json.Marshal(CreateRequest(method, params))
|
||||
require.NoError(t, err)
|
||||
|
||||
var rpcRes *Response
|
||||
time.Sleep(1 * time.Second)
|
||||
if sleep > 0 {
|
||||
time.Sleep(sleep)
|
||||
}
|
||||
|
||||
httpReq, err := http.NewRequestWithContext(context.Background(), "POST", HOST, bytes.NewBuffer(req))
|
||||
if err != nil {
|
||||
@ -94,6 +96,10 @@ func Call(t *testing.T, method string, params interface{}) *Response {
|
||||
return rpcRes
|
||||
}
|
||||
|
||||
func Call(t *testing.T, method string, params interface{}) *Response {
|
||||
return CallWithSleep(t, method, params, time.Second)
|
||||
}
|
||||
|
||||
func CallWithError(method string, params interface{}) (*Response, error) {
|
||||
req, err := json.Marshal(CreateRequest(method, params))
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user