Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix TestMempoolEthTxsAppGossipHandling #629

Merged
merged 4 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 5 additions & 11 deletions plugin/evm/gossiper_atomic_gossiping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,13 @@ func TestMempoolAtmTxsAppGossipHandlingDiscardedTx(t *testing.T) {

assert.False(mempool.has(txID))

// Gossip the transaction that conflicts with the originally
// discarded tx and ensure it is accepted into the mempool and gossipped
// to the network.
nodeID = ids.GenerateTestNodeID()
msg = message.AtomicTxGossip{
Tx: conflictingTx.SignedBytes(),
}
msgBytes, err = message.BuildGossipMessage(vm.networkCodec, msg)
assert.NoError(err)

vm.ctx.Lock.Unlock()

assert.NoError(vm.AppGossip(context.Background(), nodeID, msgBytes))
// Conflicting tx must be submitted over the API to be included in push gossip.
// (i.e., txs received via p2p are not included in push gossip)
// This test adds it directly to the mempool + gossiper to simulate that.
vm.mempool.AddTx(conflictingTx)
vm.atomicTxPushGossiper.Add(&GossipAtomicTx{conflictingTx})
time.Sleep(500 * time.Millisecond)

vm.ctx.Lock.Lock()
Expand Down
16 changes: 3 additions & 13 deletions plugin/evm/gossiper_eth_gossiping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"

"github.com/stretchr/testify/assert"

"github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/core/types"
"github.com/ava-labs/coreth/params"
"github.com/ava-labs/coreth/plugin/evm/message"
)

func fundAddressByGenesis(addrs []common.Address) (string, error) {
Expand Down Expand Up @@ -115,17 +113,9 @@ func TestMempoolEthTxsAppGossipHandling(t *testing.T) {
// prepare a tx
tx := getValidEthTxs(key, 1, common.Big1)[0]

// show that unknown coreth hashes is requested
txBytes, err := rlp.EncodeToBytes([]*types.Transaction{tx})
assert.NoError(err)
msg := message.EthTxsGossip{
Txs: txBytes,
}
msgBytes, err := message.BuildGossipMessage(vm.networkCodec, msg)
assert.NoError(err)

nodeID := ids.GenerateTestNodeID()
err = vm.AppGossip(context.Background(), nodeID, msgBytes)
// Txs must be submitted over the API to be included in push gossip.
// (i.e., txs received via p2p are not included in push gossip)
err = vm.eth.APIBackend.SendTx(context.Background(), tx)
assert.NoError(err)
assert.False(txRequested, "tx should not be requested")

Expand Down
1 change: 0 additions & 1 deletion plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ func GenesisVMWithClock(
*enginetest.Sender,
) {
vm := &VM{clock: clock}
vm.p2pSender = &enginetest.SenderStub{}
ctx, dbManager, genesisBytes, issuer, m := setupGenesis(t, genesisJSON)
appSender := &enginetest.Sender{T: t}
appSender.CantSendAppGossip = true
Expand Down
Loading