add gas price=0 unit test, comments (#528)
* add handler comment * add gas price=0 test Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
1f4f7fb017
commit
a54c2dc726
@ -60,9 +60,12 @@ func handleMsgEthereumTx(ctx sdk.Context, k Keeper, msg types.MsgEthereumTx) (*s
|
||||
Simulate: ctx.IsCheckTx(),
|
||||
}
|
||||
|
||||
// Prepare db for logs
|
||||
// TODO: block hash
|
||||
// since the txCount is used by the stateDB, and a simulated tx is run only on the node it's submitted to,
|
||||
// then this will cause the txCount/stateDB of the node that ran the simulated tx to be different than the
|
||||
// other nodes, causing a consensus error
|
||||
if !st.Simulate {
|
||||
// Prepare db for logs
|
||||
// TODO: block hash
|
||||
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
|
||||
k.TxCount++
|
||||
}
|
||||
@ -146,8 +149,8 @@ func handleMsgEthermint(ctx sdk.Context, k Keeper, msg types.MsgEthermint) (*sdk
|
||||
st.Recipient = &to
|
||||
}
|
||||
|
||||
// Prepare db for logs
|
||||
if !st.Simulate {
|
||||
// Prepare db for logs
|
||||
k.CommitStateDB.Prepare(ethHash, common.Hash{}, k.TxCount)
|
||||
k.TxCount++
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ func TestMsgEthermintValidation(t *testing.T) {
|
||||
{amount: sdk.NewInt(0), gasPrice: sdk.NewInt(100000), expectPass: true},
|
||||
{amount: sdk.NewInt(-1), gasPrice: sdk.NewInt(100000), expectPass: false},
|
||||
{amount: sdk.NewInt(100), gasPrice: sdk.NewInt(-1), expectPass: false},
|
||||
{amount: sdk.NewInt(100), gasPrice: sdk.NewInt(0), expectPass: false},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
@ -116,6 +117,7 @@ func TestMsgEthereumTxValidation(t *testing.T) {
|
||||
{msg: "pass", amount: big.NewInt(100), gasPrice: big.NewInt(100000), expectPass: true},
|
||||
{msg: "invalid amount", amount: big.NewInt(-1), gasPrice: big.NewInt(100000), expectPass: false},
|
||||
{msg: "invalid gas price", amount: big.NewInt(100), gasPrice: big.NewInt(-1), expectPass: false},
|
||||
{msg: "invalid gas price", amount: big.NewInt(100), gasPrice: big.NewInt(0), expectPass: false},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
|
Loading…
Reference in New Issue
Block a user