Skip to content

Commit e36b7da

Browse files
cloudgrayvladjdk
andauthored
test: fix mempool e2e test (#709)
* fix: mempool e2e test * chore: expand timeout for system test * chore: update CHANGELOG.md --------- Co-authored-by: Vlad J <vladjdk@gmail.com>
1 parent 720ba9c commit e36b7da

File tree

7 files changed

+130
-54
lines changed

7 files changed

+130
-54
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- [\#685](https://github.com/cosmos/evm/pull/685) Add EIP-7702 e2e test
5353
- [\#680](https://github.com/cosmos/evm/pull/680) Introduce a `StaticPrecompiles` builder
5454
- [\#701](https://github.com/cosmos/evm/pull/701) Add address codec support to ERC20 IBC callbacks to handle hex addresses in addition to bech32 addresses.
55+
- [\#702](https://github.com/cosmos/evm/pull/702) Fix mempool e2e test
5556
- [\#704](https://github.com/cosmos/evm/pull/704) Fix EIP-7702 test cases
5657

5758
### FEATURES

tests/systemtests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
WAIT_TIME ?= 20s
44

55
test:
6-
go test -mod=readonly -failfast -timeout=15m -tags='system_test' ./... --wait-time=$(WAIT_TIME) --verbose --binary evmd --chain-id local-4221
6+
go test -mod=readonly -failfast -timeout=25m -tags='system_test' ./... --wait-time=$(WAIT_TIME) --verbose --binary evmd --chain-id local-4221
77

tests/systemtests/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestTxsOrdering(t *testing.T) {
2121

2222
func TestTxsReplacement(t *testing.T) {
2323
mempool.TestTxsReplacement(t)
24+
mempool.TestTxsReplacementWithCosmosTx(t)
2425
mempool.TestMixedTxsReplacementEVMAndCosmos(t)
2526
mempool.TestMixedTxsReplacementLegacyAndDynamicFee(t)
2627
}

tests/systemtests/mempool/test_exceptions.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ func TestTxRebroadcasting(t *testing.T) {
1212
testCases := []struct {
1313
name string
1414
actions []func(s TestSuite)
15-
bypass bool
1615
}{
1716
{
1817
name: "ordering of pending txs %s",
@@ -77,10 +76,6 @@ func TestTxRebroadcasting(t *testing.T) {
7776
for _, tc := range testCases {
7877
testName := fmt.Sprintf(tc.name, to.Description)
7978
t.Run(testName, func(t *testing.T) {
80-
if tc.bypass {
81-
return
82-
}
83-
8479
s.BeforeEachCase(t)
8580
for _, action := range tc.actions {
8681
action(s)
@@ -96,7 +91,6 @@ func TestMinimumGasPricesZero(t *testing.T) {
9691
testCases := []struct {
9792
name string
9893
actions []func(s TestSuite)
99-
bypass bool
10094
}{
10195
{
10296
name: "sequencial pending txs %s",
@@ -138,10 +132,6 @@ func TestMinimumGasPricesZero(t *testing.T) {
138132
for _, tc := range testCases {
139133
testName := fmt.Sprintf(tc.name, to.Description)
140134
t.Run(testName, func(t *testing.T) {
141-
if tc.bypass {
142-
return
143-
}
144-
145135
s.BeforeEachCase(t)
146136
for _, action := range tc.actions {
147137
action(s)

tests/systemtests/mempool/test_ordering.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ func TestTxsOrdering(t *testing.T) {
1313
testCases := []struct {
1414
name string
1515
actions []func(s TestSuite)
16-
bypass bool
1716
}{
1817
{
1918
name: "ordering of pending txs %s",
@@ -66,10 +65,6 @@ func TestTxsOrdering(t *testing.T) {
6665
for _, tc := range testCases {
6766
testName := fmt.Sprintf(tc.name, to.Description)
6867
t.Run(testName, func(t *testing.T) {
69-
if tc.bypass {
70-
return
71-
}
72-
7368
s.BeforeEachCase(t)
7469
for _, action := range tc.actions {
7570
action(s)

tests/systemtests/mempool/test_replacement.go

Lines changed: 115 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,42 @@ func TestTxsReplacement(t *testing.T) {
1313
testCases := []struct {
1414
name string
1515
actions []func(s TestSuite)
16-
bypass bool
1716
}{
1817
{
1918
name: "single pending tx submitted to same nodes %s",
2019
actions: []func(s TestSuite){
2120
func(s TestSuite) {
2221
_, err := s.SendTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
2322
require.NoError(t, err, "failed to send tx")
24-
tx2, err := s.SendTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
23+
tx2, err := s.SendTx(t, s.Node(1), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
2524
require.NoError(t, err, "failed to send tx")
2625

2726
s.SetExpPendingTxs(tx2)
2827
},
2928
},
30-
bypass: true,
3129
},
3230
{
3331
name: "multiple pending txs submitted to same nodes %s",
3432
actions: []func(s TestSuite){
3533
func(s TestSuite) {
3634
_, err := s.SendTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
3735
require.NoError(t, err, "failed to send tx")
38-
tx2, err := s.SendTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
36+
tx2, err := s.SendTx(t, s.Node(1), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
3937
require.NoError(t, err, "failed to send tx")
4038

41-
_, err = s.SendTx(t, s.Node(1), "acc0", 1, s.BaseFee(), nil)
39+
_, err = s.SendTx(t, s.Node(0), "acc0", 1, s.BaseFee(), nil)
4240
require.NoError(t, err, "failed to send tx")
4341
tx4, err := s.SendTx(t, s.Node(1), "acc0", 1, s.BaseFeeX2(), big.NewInt(1))
4442
require.NoError(t, err, "failed to send tx")
4543

46-
_, err = s.SendTx(t, s.Node(2), "acc0", 2, s.BaseFee(), nil)
44+
_, err = s.SendTx(t, s.Node(0), "acc0", 2, s.BaseFee(), nil)
4745
require.NoError(t, err, "failed to send tx")
48-
tx6, err := s.SendTx(t, s.Node(2), "acc0", 2, s.BaseFeeX2(), big.NewInt(1))
46+
tx6, err := s.SendTx(t, s.Node(1), "acc0", 2, s.BaseFeeX2(), big.NewInt(1))
4947
require.NoError(t, err, "failed to send tx")
5048

5149
s.SetExpPendingTxs(tx2, tx4, tx6)
5250
},
5351
},
54-
bypass: true,
5552
},
5653
{
5754
name: "single queued tx %s",
@@ -116,11 +113,6 @@ func TestTxsReplacement(t *testing.T) {
116113
TxType: suite.TxTypeEVM,
117114
IsDynamicFeeTx: true,
118115
},
119-
{
120-
Description: "Cosmos LegacyTx",
121-
TxType: suite.TxTypeCosmos,
122-
IsDynamicFeeTx: false,
123-
},
124116
}
125117

126118
s := suite.NewSystemTestSuite(t)
@@ -131,10 +123,105 @@ func TestTxsReplacement(t *testing.T) {
131123
for _, tc := range testCases {
132124
testName := fmt.Sprintf(tc.name, to.Description)
133125
t.Run(testName, func(t *testing.T) {
134-
if tc.bypass {
135-
return
126+
s.BeforeEachCase(t)
127+
for _, action := range tc.actions {
128+
action(s)
129+
s.AfterEachAction(t)
136130
}
131+
s.AfterEachCase(t)
132+
})
133+
}
134+
}
135+
}
136+
137+
func TestTxsReplacementWithCosmosTx(t *testing.T) {
138+
testCases := []struct {
139+
name string
140+
actions []func(s TestSuite)
141+
}{
142+
{
143+
name: "single pending tx submitted to same nodes %s",
144+
actions: []func(s TestSuite){
145+
func(s TestSuite) {
146+
s.AwaitNBlocks(t, 2)
147+
148+
// NOTE: Currently EVMD cannot handle tx reordering correctly when cosmos tx is used.
149+
// It is because of CheckTxHandler cannot handle errors from SigVerificationDecorator properly.
150+
// After modifying CheckTxHandler, we can also modify this test case
151+
// : high prio cosmos tx should replace low prio evm tx.
152+
tx1, err := s.SendTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
153+
require.NoError(t, err, "failed to send tx")
154+
_, err = s.SendTx(t, s.Node(1), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
155+
require.NoError(t, err, "failed to send tx")
156+
157+
s.SetExpPendingTxs(tx1)
158+
},
159+
},
160+
},
161+
{
162+
name: "multiple pending txs submitted to same nodes %s",
163+
actions: []func(s TestSuite){
164+
func(s TestSuite) {
165+
s.AwaitNBlocks(t, 2)
166+
167+
// NOTE: Currently EVMD cannot handle tx reordering correctly when cosmos tx is used.
168+
// It is because of CheckTxHandler cannot handle errors from SigVerificationDecorator properly.
169+
// After modifying CheckTxHandler, we can also modify this test case
170+
// : high prio cosmos tx should replace low prio evm tx.
171+
tx1, err := s.SendTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
172+
require.NoError(t, err, "failed to send tx")
173+
_, err = s.SendTx(t, s.Node(1), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
174+
require.NoError(t, err, "failed to send tx")
175+
176+
tx3, err := s.SendTx(t, s.Node(0), "acc0", 1, s.BaseFee(), nil)
177+
require.NoError(t, err, "failed to send tx")
178+
_, err = s.SendTx(t, s.Node(1), "acc0", 1, s.BaseFeeX2(), big.NewInt(1))
179+
require.NoError(t, err, "failed to send tx")
180+
181+
tx5, err := s.SendTx(t, s.Node(0), "acc0", 2, s.BaseFee(), nil)
182+
require.NoError(t, err, "failed to send tx")
183+
_, err = s.SendTx(t, s.Node(1), "acc0", 2, s.BaseFeeX2(), big.NewInt(1))
184+
require.NoError(t, err, "failed to send tx")
137185

186+
s.SetExpPendingTxs(tx1, tx3, tx5)
187+
},
188+
},
189+
},
190+
{
191+
name: "single queued tx %s",
192+
actions: []func(s TestSuite){
193+
func(s TestSuite) {
194+
// Cosmos txs are not queued in local mempool
195+
_, err := s.SendTx(t, s.Node(0), "acc0", 1, s.BaseFee(), nil)
196+
require.NoError(t, err, "failed to send tx")
197+
_, err = s.SendTx(t, s.Node(0), "acc0", 1, s.BaseFeeX2(), big.NewInt(1))
198+
require.NoError(t, err, "failed to send tx")
199+
},
200+
func(s TestSuite) {
201+
txHash, err := s.SendTx(t, s.Node(1), "acc0", 0, s.BaseFee(), nil)
202+
require.NoError(t, err, "failed to send tx")
203+
204+
s.SetExpPendingTxs(txHash)
205+
},
206+
},
207+
},
208+
}
209+
210+
testOptions := []*suite.TestOptions{
211+
{
212+
Description: "Cosmos LegacyTx",
213+
TxType: suite.TxTypeCosmos,
214+
},
215+
}
216+
217+
s := suite.NewSystemTestSuite(t)
218+
s.SetupTest(t)
219+
220+
for _, to := range testOptions {
221+
s.SetOptions(to)
222+
for _, tc := range testCases {
223+
testName := fmt.Sprintf(tc.name, to.Description)
224+
t.Run(testName, func(t *testing.T) {
138225
s.BeforeEachCase(t)
139226
for _, action := range tc.actions {
140227
action(s)
@@ -150,63 +237,63 @@ func TestMixedTxsReplacementEVMAndCosmos(t *testing.T) {
150237
testCases := []struct {
151238
name string
152239
actions []func(s TestSuite)
153-
bypass bool
154240
}{
155241
{
156242
name: "single pending tx (low prio evm tx first) %s",
157243
actions: []func(s TestSuite){
158244
func(s TestSuite) {
159-
_, err := s.SendEthTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
245+
s.AwaitNBlocks(t, 2)
246+
247+
tx1, err := s.SendEthTx(t, s.Node(0), "acc0", 0, s.BaseFee(), s.BaseFee())
160248
require.NoError(t, err, "failed to send tx")
161-
tx2, err := s.SendCosmosTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
249+
250+
baseFeeX20 := new(big.Int).Mul(s.BaseFeeX2(), big.NewInt(1000000000000000000))
251+
_, err = s.SendCosmosTx(t, s.Node(1), "acc0", 0, baseFeeX20, nil)
162252
require.NoError(t, err, "failed to send tx")
163253

164-
s.SetExpPendingTxs(tx2)
254+
s.SetExpPendingTxs(tx1)
165255
},
166256
},
167-
bypass: true,
168257
},
169258
{
170259
name: "single pending tx (high prio evm tx first) %s",
171260
actions: []func(s TestSuite){
172261
func(s TestSuite) {
173-
tx1, err := s.SendEthTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
262+
tx1, err := s.SendEthTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), s.BaseFeeX2())
174263
require.NoError(t, err, "failed to send tx")
175-
_, err = s.SendCosmosTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
264+
_, err = s.SendCosmosTx(t, s.Node(1), "acc0", 0, s.BaseFee(), nil)
176265
require.NoError(t, err, "failed to send tx")
177266

178267
s.SetExpPendingTxs(tx1)
179268
},
180269
},
181-
bypass: true,
182270
},
183271
{
184272
name: "single pending tx (low prio cosmos tx first) %s",
185273
actions: []func(s TestSuite){
186274
func(s TestSuite) {
187275
_, err := s.SendCosmosTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
188276
require.NoError(t, err, "failed to send tx")
189-
tx2, err := s.SendEthTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
277+
tx2, err := s.SendEthTx(t, s.Node(1), "acc0", 0, s.BaseFeeX2(), s.BaseFeeX2())
190278
require.NoError(t, err, "failed to send tx")
191279

192280
s.SetExpPendingTxs(tx2)
193281
},
194282
},
195-
bypass: true,
196283
},
197284
{
198285
name: "single pending tx (high prio cosmos tx first) %s",
199286
actions: []func(s TestSuite){
200287
func(s TestSuite) {
201-
tx1, err := s.SendCosmosTx(t, s.Node(0), "acc0", 0, s.BaseFeeX2(), big.NewInt(1))
288+
baseFeeX20 := new(big.Int).Mul(s.BaseFeeX2(), big.NewInt(10))
289+
tx1, err := s.SendCosmosTx(t, s.Node(0), "acc0", 0, baseFeeX20, nil)
202290
require.NoError(t, err, "failed to send tx")
203291
_, err = s.SendEthTx(t, s.Node(0), "acc0", 0, s.BaseFee(), nil)
204292
require.NoError(t, err, "failed to send tx")
205293

206294
s.SetExpPendingTxs(tx1)
207295
},
208296
},
209-
bypass: true,
210297
},
211298
{
212299
name: "single queued tx (low prio evm tx first) %s",
@@ -256,7 +343,7 @@ func TestMixedTxsReplacementEVMAndCosmos(t *testing.T) {
256343
func(s TestSuite) {
257344
_, err := s.SendCosmosTx(t, s.Node(0), "acc0", 1, s.BaseFee(), nil)
258345
require.NoError(t, err, "failed to send tx")
259-
tx2, err := s.SendEthTx(t, s.Node(0), "acc0", 1, s.BaseFeeX2(), big.NewInt(1))
346+
tx2, err := s.SendEthTx(t, s.Node(0), "acc0", 1, s.BaseFeeX2(), s.BaseFeeX2())
260347
require.NoError(t, err, "failed to send tx")
261348

262349
// CosmosTx is not queued in local mempool
@@ -312,10 +399,6 @@ func TestMixedTxsReplacementEVMAndCosmos(t *testing.T) {
312399
for _, tc := range testCases {
313400
testName := fmt.Sprintf(tc.name, to.Description)
314401
t.Run(testName, func(t *testing.T) {
315-
if tc.bypass {
316-
return
317-
}
318-
319402
s.BeforeEachCase(t)
320403
for _, action := range tc.actions {
321404
action(s)
@@ -331,7 +414,6 @@ func TestMixedTxsReplacementLegacyAndDynamicFee(t *testing.T) {
331414
testCases := []struct {
332415
name string
333416
actions []func(s TestSuite)
334-
bypass bool
335417
}{
336418
{
337419
name: "dynamic fee tx should not replace legacy tx",
@@ -410,10 +492,6 @@ func TestMixedTxsReplacementLegacyAndDynamicFee(t *testing.T) {
410492

411493
for _, tc := range testCases {
412494
t.Run(tc.name, func(t *testing.T) {
413-
if tc.bypass {
414-
return
415-
}
416-
417495
s.BeforeEachCase(t)
418496
for _, action := range tc.actions {
419497
action(s)

tests/systemtests/suite/types.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const (
88
NodeArgsApiEnable = "--api.enable=true"
99
NodeArgsJsonrpcApi = "--json-rpc.api=eth,txpool,personal,net,debug,web3"
1010
NodeArgsJsonrpcAllowUnprotectedTxs = "--json-rpc.allow-unprotected-txs=true"
11+
NodeArgsMinimumGasPrice = "--minimum-gas-prices=0.000001atest"
1112
)
1213

1314
// TestOptions defines the options for a test case.
@@ -40,10 +41,20 @@ func DefaultNodeArgs() []string {
4041
NodeArgsChainID,
4142
NodeArgsApiEnable,
4243
NodeArgsJsonrpcAllowUnprotectedTxs,
44+
NodeArgsMinimumGasPrice,
4345
}
4446
}
4547

4648
// MinimumGasPriceZeroArgs returns the node arguments with minimum gas price set to zero.
4749
func MinimumGasPriceZeroArgs() []string {
48-
return append(DefaultNodeArgs(), "--minimum-gas-prices=0stake")
50+
defaultArgs := DefaultNodeArgs()
51+
// Remove the default minimum gas price argument
52+
var args []string
53+
for _, arg := range defaultArgs {
54+
if arg != NodeArgsMinimumGasPrice {
55+
args = append(args, arg)
56+
}
57+
}
58+
// Add the zero minimum gas price argument
59+
return append(DefaultNodeArgs(), "--minimum-gas-prices=0atest")
4960
}

0 commit comments

Comments
 (0)