mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 16:59:26 +00:00
core/txpool/blobpool: verify that events are emittted correctly
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
e9d185f15b
commit
5c1272effc
1 changed files with 25 additions and 0 deletions
|
|
@ -1780,6 +1780,11 @@ func TestAdd(t *testing.T) {
|
|||
}
|
||||
verifyPoolInternals(t, pool)
|
||||
|
||||
// subscibe to pool events to verify they are emitted correctly
|
||||
txsCh := make(chan core.NewTxsEvent, 1)
|
||||
txsSub := pool.SubscribeTransactions(txsCh, false)
|
||||
defer txsSub.Unsubscribe()
|
||||
|
||||
// Add each transaction one by one, verifying the pool internals in between
|
||||
for j, add := range tt.adds {
|
||||
signed, _ := types.SignNewTx(keys[add.from], types.LatestSigner(params.MainnetChainConfig), add.tx)
|
||||
|
|
@ -1810,6 +1815,26 @@ func TestAdd(t *testing.T) {
|
|||
}
|
||||
// Verify the pool internals after each addition
|
||||
verifyPoolInternals(t, pool)
|
||||
// verify that if the tx was added, an event was emitted
|
||||
if add.err == nil {
|
||||
select {
|
||||
case ev := <-txsCh:
|
||||
if len(ev.Txs) != 1 {
|
||||
t.Errorf("test %d, tx %d: event txs length mismatch: have %d, want 1", i, j, len(ev.Txs))
|
||||
}
|
||||
if ev.Txs[0].Hash() != signed.Hash() {
|
||||
t.Errorf("test %d, tx %d: event tx mismatch: have %v, want %v", i, j, ev.Txs[0].Hash(), signed.Hash())
|
||||
}
|
||||
default:
|
||||
t.Errorf("test %d, tx %d: expected new tx event, none received", i, j)
|
||||
}
|
||||
} else {
|
||||
select {
|
||||
case ev := <-txsCh:
|
||||
t.Errorf("test %d, tx %d: unexpected new tx event with %d txs", i, j, len(ev.Txs))
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
verifyPoolInternals(t, pool)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue