eventbus: publish without contexts (#8369)

This commit is contained in:
Sam Kleinman
2022-04-18 16:28:31 -04:00
committed by GitHub
parent 889341152a
commit c372390fea
29 changed files with 256 additions and 280 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ func BenchmarkTxMempool_CheckTx(b *testing.B) {
// setup the cache and the mempool number for hitting GetEvictableTxs during the
// benchmark. 5000 is the current default mempool size in the TM config.
txmp := setup(ctx, b, client, 10000)
txmp := setup(b, client, 10000)
txmp.config.Size = 5000
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
+12 -12
View File
@@ -72,7 +72,7 @@ func (app *application) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
}
}
func setup(ctx context.Context, t testing.TB, app abciclient.Client, cacheSize int, options ...TxMempoolOption) *TxMempool {
func setup(t testing.TB, app abciclient.Client, cacheSize int, options ...TxMempoolOption) *TxMempool {
t.Helper()
logger := log.NewNopLogger()
@@ -131,7 +131,7 @@ func TestTxMempool_TxsAvailable(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 0)
txmp := setup(t, client, 0)
txmp.EnableTxsAvailable()
ensureNoTxFire := func() {
@@ -194,7 +194,7 @@ func TestTxMempool_Size(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 0)
txmp := setup(t, client, 0)
txs := checkTxs(ctx, t, txmp, 100, 0)
require.Equal(t, len(txs), txmp.Size())
require.Equal(t, int64(5690), txmp.SizeBytes())
@@ -227,7 +227,7 @@ func TestTxMempool_Flush(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 0)
txmp := setup(t, client, 0)
txs := checkTxs(ctx, t, txmp, 100, 0)
require.Equal(t, len(txs), txmp.Size())
require.Equal(t, int64(5690), txmp.SizeBytes())
@@ -261,7 +261,7 @@ func TestTxMempool_ReapMaxBytesMaxGas(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 0)
txmp := setup(t, client, 0)
tTxs := checkTxs(ctx, t, txmp, 100, 0) // all txs request 1 gas unit
require.Equal(t, len(tTxs), txmp.Size())
require.Equal(t, int64(5690), txmp.SizeBytes())
@@ -320,7 +320,7 @@ func TestTxMempool_ReapMaxTxs(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 0)
txmp := setup(t, client, 0)
tTxs := checkTxs(ctx, t, txmp, 100, 0)
require.Equal(t, len(tTxs), txmp.Size())
require.Equal(t, int64(5690), txmp.SizeBytes())
@@ -377,7 +377,7 @@ func TestTxMempool_CheckTxExceedsMaxSize(t *testing.T) {
t.Fatal(err)
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 0)
txmp := setup(t, client, 0)
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
tx := make([]byte, txmp.config.MaxTxBytes+1)
@@ -403,7 +403,7 @@ func TestTxMempool_CheckTxSamePeer(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 100)
txmp := setup(t, client, 100)
peerID := uint16(1)
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
@@ -427,7 +427,7 @@ func TestTxMempool_CheckTxSameSender(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 100)
txmp := setup(t, client, 100)
peerID := uint16(1)
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
@@ -458,7 +458,7 @@ func TestTxMempool_ConcurrentTxs(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 100)
txmp := setup(t, client, 100)
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
checkTxDone := make(chan struct{})
@@ -531,7 +531,7 @@ func TestTxMempool_ExpiredTxs_NumBlocks(t *testing.T) {
}
t.Cleanup(client.Wait)
txmp := setup(ctx, t, client, 500)
txmp := setup(t, client, 500)
txmp.height = 100
txmp.config.TTLNumBlocks = 10
@@ -612,7 +612,7 @@ func TestTxMempool_CheckTxPostCheckError(t *testing.T) {
postCheckFn := func(_ types.Tx, _ *abci.ResponseCheckTx) error {
return testCase.err
}
txmp := setup(ctx, t, client, 0, WithPostCheck(postCheckFn))
txmp := setup(t, client, 0, WithPostCheck(postCheckFn))
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
tx := make([]byte, txmp.config.MaxTxBytes-1)
_, err := rng.Read(tx)
+1 -1
View File
@@ -68,7 +68,7 @@ func setupReactors(ctx context.Context, t *testing.T, logger log.Logger, numNode
require.NoError(t, client.Start(ctx))
t.Cleanup(client.Wait)
mempool := setup(ctx, t, client, 0)
mempool := setup(t, client, 0)
rts.mempools[nodeID] = mempool
rts.peerChans[nodeID] = make(chan p2p.PeerUpdate, chBuf)