upgrade to ethermint v0.21.0 #99

Closed
0xmuralik wants to merge 384 commits from murali/update-fork into main
2 changed files with 14 additions and 6 deletions
Showing only changes of commit afc09f9d59 - Show all commits

View File

@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"testing" "testing"
"time"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "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) { func TestEth_Pending_GetTransactionByHash(t *testing.T) {
sleep := 0 * time.Second
// negative case, check that it returns empty. // 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{} var tx map[string]interface{}
err := json.Unmarshal(rpcRes.Result, &tx) err := json.Unmarshal(rpcRes.Result, &tx)
require.NoError(t, err) require.NoError(t, err)
@ -281,17 +283,17 @@ func TestEth_Pending_GetTransactionByHash(t *testing.T) {
param := makePendingTxParams(t) param := makePendingTxParams(t)
param[0]["data"] = data param[0]["data"] = data
txRes := Call(t, "eth_sendTransaction", param) txRes := CallWithSleep(t, "eth_sendTransaction", param, sleep)
var txHash common.Hash var txHash common.Hash
err = txHash.UnmarshalJSON(txRes.Result) err = txHash.UnmarshalJSON(txRes.Result)
require.NoError(t, err) require.NoError(t, err)
rpcRes = Call(t, "eth_getTransactionByHash", []interface{}{txHash}) rpcRes = CallWithSleep(t, "eth_getTransactionByHash", []interface{}{txHash}, sleep)
var pendingTx map[string]interface{} var pendingTx map[string]interface{}
err = json.Unmarshal(rpcRes.Result, &pendingTx) err = json.Unmarshal(rpcRes.Result, &pendingTx)
require.NoError(t, err) require.NoError(t, err)
txsRes := Call(t, "eth_getPendingTransactions", []interface{}{}) txsRes := CallWithSleep(t, "eth_getPendingTransactions", []interface{}{}, sleep)
var pendingTxs []map[string]interface{} var pendingTxs []map[string]interface{}
err = json.Unmarshal(txsRes.Result, &pendingTxs) err = json.Unmarshal(txsRes.Result, &pendingTxs)
require.NoError(t, err) require.NoError(t, err)

View File

@ -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)) req, err := json.Marshal(CreateRequest(method, params))
require.NoError(t, err) require.NoError(t, err)
var rpcRes *Response 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)) httpReq, err := http.NewRequestWithContext(context.Background(), "POST", HOST, bytes.NewBuffer(req))
if err != nil { if err != nil {
@ -94,6 +96,10 @@ func Call(t *testing.T, method string, params interface{}) *Response {
return rpcRes 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) { func CallWithError(method string, params interface{}) (*Response, error) {
req, err := json.Marshal(CreateRequest(method, params)) req, err := json.Marshal(CreateRequest(method, params))
if err != nil { if err != nil {