mirror of
https://github.com/tendermint/tendermint.git
synced 2025-12-23 06:15:19 +00:00
* Updated mocks * add reactor tests * add v1 reactor tests * Fix fuzz test for priority mempool * e2e adapted to mempool v1; prio pool is default now * Reverted default mempool to be fifo * Changed buf version * Added priority mempool to ci testnet * Fixed linter * Updated makefile * Aligned makefile changes to v0.34.x * Added go install for proto * Add log message to warn about prioritized mempool bug Signed-off-by: Thane Thomson <connect@thanethomson.com> * Changelog message Co-authored-by: Jasmina Malicevic <jasmina.dustinac@gmail.com> Co-authored-by: Callum Waters <cmwaters19@gmail.com> Co-authored-by: Sam Kleinman <garen@tychoish.com> Co-authored-by: Thane Thomson <connect@thanethomson.com>
36 lines
790 B
Go
36 lines
790 B
Go
package mempool
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCacheRemove(t *testing.T) {
|
|
cache := NewLRUTxCache(100)
|
|
numTxs := 10
|
|
|
|
txs := make([][]byte, numTxs)
|
|
for i := 0; i < numTxs; i++ {
|
|
// probability of collision is 2**-256
|
|
txBytes := make([]byte, 32)
|
|
_, err := rand.Read(txBytes)
|
|
require.NoError(t, err)
|
|
|
|
txs[i] = txBytes
|
|
cache.Push(txBytes)
|
|
|
|
// make sure its added to both the linked list and the map
|
|
require.Equal(t, i+1, len(cache.cacheMap))
|
|
require.Equal(t, i+1, cache.list.Len())
|
|
}
|
|
|
|
for i := 0; i < numTxs; i++ {
|
|
cache.Remove(txs[i])
|
|
// make sure its removed from both the map and the linked list
|
|
require.Equal(t, numTxs-(i+1), len(cache.cacheMap))
|
|
require.Equal(t, numTxs-(i+1), cache.list.Len())
|
|
}
|
|
}
|