Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

RPC tests are failing if FeeMarket Base Fee is enabled by default #770

Merged
merged 5 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/rpc/rpc_pending_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestEth_Pending_GetTransactionCount(t *testing.T) {
t.Logf("Current nonce is %d", currentNonce)
require.Equal(t, prePendingNonce, currentNonce)

param := makePendingTxParams()
param := makePendingTxParams(t)
txRes := Call(t, "eth_sendTransaction", param)
require.Nil(t, txRes.Error)

Expand Down Expand Up @@ -278,7 +278,7 @@ func TestEth_Pending_GetTransactionByHash(t *testing.T) {

// create a transaction.
data := "0x608060405234801561001057600080fd5b5061011e806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806302eb691b14602d575b600080fd5b603360ab565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101560715780820151818401526020810190506058565b50505050905090810190601f168015609d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60606040518060400160405280600d81526020017f617261736b61776173686572650000000000000000000000000000000000000081525090509056fea264697066735822122060917c5c2fab8c058a17afa6d3c1d23a7883b918ea3c7157131ea5b396e1aa7564736f6c63430007050033"
param := makePendingTxParams()
param := makePendingTxParams(t)
param[0]["data"] = data

txRes := Call(t, "eth_sendTransaction", param)
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestEth_Pending_GetTransactionByHash(t *testing.T) {

func TestEth_Pending_SendTransaction_PendingNonce(t *testing.T) {
currNonce := GetNonce(t, "latest")
param := makePendingTxParams()
param := makePendingTxParams(t)

// first transaction
txRes1 := Call(t, "eth_sendTransaction", param)
Expand All @@ -331,13 +331,15 @@ func TestEth_Pending_SendTransaction_PendingNonce(t *testing.T) {
require.Greater(t, uint64(pendingNonce3), uint64(pendingNonce2))
}

func makePendingTxParams() []map[string]string {
func makePendingTxParams(t *testing.T) []map[string]string {
gasPrice := GetGasPrice(t)

param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["to"] = addrA
param[0]["value"] = "0xA"
param[0]["gasLimit"] = "0x5208"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice
return param
}
26 changes: 17 additions & 9 deletions tests/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func TestEth_SendTransaction_Transfer(t *testing.T) {
}

func TestEth_SendTransaction_ContractDeploy(t *testing.T) {
param := makeTestContractDeployParam(true)
param := makeTestContractDeployParam(t, true)
rpcRes, err := callWithError("eth_sendTransaction", param)
require.NoError(t, err)

Expand All @@ -422,7 +422,7 @@ func TestEth_SendTransaction_ContractDeploy(t *testing.T) {
}

func TestEth_SendTransaction_ContractDeploy_no_gas_param(t *testing.T) {
param := makeTestContractDeployParam(false)
param := makeTestContractDeployParam(t, false)
_, err := callWithError("eth_sendTransaction", param)
// server returns internal error.
require.Error(t, err)
Expand Down Expand Up @@ -503,12 +503,14 @@ func TestEth_GetFilterChanges_WrongID(t *testing.T) {

// sendTestTransaction sends a dummy transaction
func sendTestTransaction(t *testing.T) hexutil.Bytes {
gasPrice := GetGasPrice(t)

param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["to"] = "0x1122334455667788990011223344556677889900"
param[0]["value"] = "0x1"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice
rpcRes := call(t, "eth_sendTransaction", param)

var hash hexutil.Bytes
Expand All @@ -529,6 +531,8 @@ func TestEth_GetTransactionReceipt(t *testing.T) {

// deployTestERC20Contract deploys a contract that emits an event in the constructor
func deployTestERC20Contract(t *testing.T) common.Address {
gasPrice := GetGasPrice(t)

param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
Expand All @@ -539,7 +543,7 @@ func deployTestERC20Contract(t *testing.T) common.Address {
param[0]["data"] = hexutil.Encode(data)

param[0]["gas"] = "0x200000"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice

rpcRes := call(t, "eth_sendTransaction", param)

Expand All @@ -559,6 +563,7 @@ func deployTestERC20Contract(t *testing.T) common.Address {
// sendTestERC20Transaction sends a typical erc20 transfer transaction
func sendTestERC20Transaction(t *testing.T, contract common.Address, amount *big.Int) hexutil.Bytes {
// transfer
gasPrice := GetGasPrice(t)
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
Expand All @@ -567,7 +572,7 @@ func sendTestERC20Transaction(t *testing.T, contract common.Address, amount *big
require.NoError(t, err)
param[0]["data"] = hexutil.Encode(data)
param[0]["gas"] = "0x50000"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice

rpcRes := call(t, "eth_sendTransaction", param)

Expand Down Expand Up @@ -607,12 +612,13 @@ func TestEth_GetTransactionReceipt_ERC20Transfer(t *testing.T) {

// deployTestContract deploys a contract that emits an event in the constructor
func deployTestContract(t *testing.T) (hexutil.Bytes, map[string]interface{}) {
gasPrice := GetGasPrice(t)
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["data"] = "0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029"
param[0]["gas"] = "0x200000"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice

rpcRes := call(t, "eth_sendTransaction", param)

Expand Down Expand Up @@ -744,13 +750,14 @@ func deployTestContractWithFunction(t *testing.T) hexutil.Bytes {
// }

bytecode := "0x608060405234801561001057600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a260d08061004d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063eb8ac92114602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8160008190555080827ff3ca124a697ba07e8c5e80bebcfcc48991fc16a63170e8a9206e30508960d00360405160405180910390a3505056fea265627a7a723158201d94d2187aaf3a6790527b615fcc40970febf0385fa6d72a2344848ebd0df3e964736f6c63430005110032"
gasPrice := GetGasPrice(t)

param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["data"] = bytecode
param[0]["gas"] = "0x200000"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice

rpcRes := call(t, "eth_sendTransaction", param)

Expand Down Expand Up @@ -1028,14 +1035,15 @@ func makeEthTxParam() []map[string]string {
return param
}

func makeTestContractDeployParam(withGas bool) []map[string]string {
func makeTestContractDeployParam(t *testing.T, withGas bool) []map[string]string {
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = "0x" + fmt.Sprintf("%x", from)
param[0]["data"] = "0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029"
if withGas {
gasPrice := GetGasPrice(t)
param[0]["gas"] = "0x200000"
param[0]["gasPrice"] = "0x1"
param[0]["gasPrice"] = gasPrice
}

return param
Expand Down
9 changes: 9 additions & 0 deletions tests/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ func GetNonce(t *testing.T, block string) hexutil.Uint64 {
return nonce
}

func GetGasPrice(t *testing.T) string {
gasRes := Call(t, "eth_gasPrice", []interface{}{})

var gasPrice string
err := json.Unmarshal(gasRes.Result, &gasPrice)
require.NoError(t, err)
return gasPrice
}

func UnlockAllAccounts(t *testing.T) {
var accts []common.Address
rpcRes := Call(t, "eth_accounts", []map[string]string{})
Expand Down
2 changes: 1 addition & 1 deletion x/feemarket/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewParams(noBaseFee bool, baseFeeChangeDenom, elasticityMultiplier uint32,
// DefaultParams returns default evm parameters
func DefaultParams() Params {
return Params{
NoBaseFee: true,
NoBaseFee: false,
BaseFeeChangeDenominator: params.BaseFeeChangeDenominator,
ElasticityMultiplier: params.ElasticityMultiplier,
InitialBaseFee: params.InitialBaseFee,
Expand Down