mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-18 05:56:37 +00:00
internal: dry
This commit is contained in:
parent
107f54a05d
commit
144ccf1c60
1 changed files with 9 additions and 30 deletions
|
|
@ -1190,9 +1190,7 @@ func (s *Suite) testBadBlobTx(t *utesting.T, tx *types.Transaction, badTx *types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Suite) TestDuplicateTxs(t *utesting.T) {
|
func (s *Suite) testDuplicateTxs(t *utesting.T, sendFunc func(*utesting.T, []*types.Transaction) error) {
|
||||||
t.Log(`This test sends a TransactionsMsg containing duplicate transactions and expects the node to disconnect.`)
|
|
||||||
|
|
||||||
// Nudge client out of syncing mode to accept pending txs.
|
// Nudge client out of syncing mode to accept pending txs.
|
||||||
if err := s.engine.sendForkchoiceUpdated(); err != nil {
|
if err := s.engine.sendForkchoiceUpdated(); err != nil {
|
||||||
t.Fatalf("failed to send next block: %v", err)
|
t.Fatalf("failed to send next block: %v", err)
|
||||||
|
|
@ -1214,37 +1212,18 @@ func (s *Suite) TestDuplicateTxs(t *utesting.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
txs := []*types.Transaction{tx, tx}
|
txs := []*types.Transaction{tx, tx}
|
||||||
if err := s.sendDuplicateTxsInOneMsg(t, txs); err != nil {
|
if err := sendFunc(t, txs); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
s.chain.IncNonce(from, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Suite) TestDuplicateTxs(t *utesting.T) {
|
||||||
|
t.Log(`This test sends a TransactionsMsg containing duplicate transactions and expects the node to disconnect.`)
|
||||||
|
s.testDuplicateTxs(t, s.sendDuplicateTxsInOneMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Suite) TestDuplicatePooledTxs(t *utesting.T) {
|
func (s *Suite) TestDuplicatePooledTxs(t *utesting.T) {
|
||||||
t.Log(`This test announces transaction hashes to the node, then sends a PooledTransactionsMsg containing duplicate transactions and expects the node to disconnect.`)
|
t.Log(`This test announces transaction hashes to the node, then sends a PooledTransactionsMsg containing duplicate transactions and expects the node to disconnect.`)
|
||||||
|
s.testDuplicateTxs(t, s.sendDuplicatePooledTxsInOneMsg)
|
||||||
// Nudge client out of syncing mode to accept pending txs.
|
|
||||||
if err := s.engine.sendForkchoiceUpdated(); err != nil {
|
|
||||||
t.Fatalf("failed to send next block: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
from, nonce := s.chain.GetSender(1)
|
|
||||||
inner := &types.DynamicFeeTx{
|
|
||||||
ChainID: s.chain.config.ChainID,
|
|
||||||
Nonce: nonce,
|
|
||||||
GasTipCap: common.Big1,
|
|
||||||
GasFeeCap: s.chain.Head().BaseFee(),
|
|
||||||
Gas: 75000,
|
|
||||||
To: &common.Address{0xbb},
|
|
||||||
Value: common.Big1,
|
|
||||||
}
|
|
||||||
tx, err := s.chain.SignTx(from, types.NewTx(inner))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed to sign tx: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the same transaction twice in the PooledTransactionsMsg.
|
|
||||||
txs := []*types.Transaction{tx, tx}
|
|
||||||
if err := s.sendDuplicatePooledTxsInOneMsg(t, txs); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue