github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/chain/core/tx_list_test.go (about) 1 package core 2 3 import ( 4 "math/rand" 5 "testing" 6 7 "github.com/neatio-net/neatio/chain/core/types" 8 "github.com/neatio-net/neatio/utilities/crypto" 9 ) 10 11 func TestStrictTxListAdd(t *testing.T) { 12 key, _ := crypto.GenerateKey() 13 14 txs := make(types.Transactions, 1024) 15 for i := 0; i < len(txs); i++ { 16 txs[i] = transaction(uint64(i), 0, key) 17 } 18 list := newTxList(true) 19 for _, v := range rand.Perm(len(txs)) { 20 list.Add(txs[v], DefaultTxPoolConfig.PriceBump) 21 } 22 if len(list.txs.items) != len(txs) { 23 t.Errorf("transaction count mismatch: have %d, want %d", len(list.txs.items), len(txs)) 24 } 25 for i, tx := range txs { 26 if list.txs.items[tx.Nonce()] != tx { 27 t.Errorf("item %d: transaction mismatch: have %v, want %v", i, list.txs.items[tx.Nonce()], tx) 28 } 29 } 30 }