MCPcopy Create free account
hub / github.com/CPChain/chain / TestTransactionCapClearsFromAll

Function TestTransactionCapClearsFromAll

core/tx_pool_test.go:1058–1087  ·  view source on GitHub ↗

Tests that if transactions start being capped, transactions are also removed from 'all'

(t *testing.T)

Source from the content-addressed store, hash-verified

1056
1057// Tests that if transactions start being capped, transactions are also removed from 'all'
1058func TestTransactionCapClearsFromAll(t *testing.T) {
1059 t.Parallel()
1060
1061 // Create the pool to test the limit enforcement with
1062 statedb, _ := state.New(common.Hash{}, state.NewDatabase(database.NewMemDatabase()))
1063 blockchain := &testBlockChain{statedb, 1000000, new(event.Feed)}
1064
1065 config := testTxPoolConfig
1066 config.AccountSlots = 2
1067 config.AccountQueue = 2
1068 config.GlobalSlots = 8
1069
1070 pool := NewTxPool(config, configs.TestChainConfig, blockchain)
1071 defer pool.Stop()
1072
1073 // Create a number of test accounts and fund them
1074 key, _ := crypto.GenerateKey()
1075 addr := crypto.PubkeyToAddress(key.PublicKey)
1076 pool.currentState.AddBalance(addr, big.NewInt(1000000))
1077
1078 txs := types.Transactions{}
1079 for j := 0; j < int(config.GlobalSlots)*2; j++ {
1080 txs = append(txs, transaction(uint64(j), 100000, key))
1081 }
1082 // Import the batch and verify that limits have been enforced
1083 pool.AddRemotes(txs)
1084 if err := validateTxPoolInternals(pool); err != nil {
1085 t.Fatalf("pool internal state corrupted: %v", err)
1086 }
1087}
1088
1089// Tests that if the transaction count belonging to multiple accounts go above
1090// some hard threshold, if they are under the minimum guaranteed slot count then

Callers

nothing calls this directly

Calls 6

StopMethod · 0.95
AddRemotesMethod · 0.95
NewTxPoolFunction · 0.85
transactionFunction · 0.85
validateTxPoolInternalsFunction · 0.85
AddBalanceMethod · 0.65

Tested by

no test coverage detected