Tests that even if the transaction count belonging to a single account goes above some threshold, as long as the transactions are executable, they are accepted.
(t *testing.T)
| 918 | // above some threshold, as long as the transactions are executable, they are |
| 919 | // accepted. |
| 920 | func TestTransactionPendingLimiting(t *testing.T) { |
| 921 | t.Parallel() |
| 922 | |
| 923 | // Create a test account and fund it |
| 924 | pool, key := setupTxPool() |
| 925 | defer pool.Stop() |
| 926 | |
| 927 | account, _ := deriveSender(transaction(0, 0, key)) |
| 928 | pool.currentState.AddBalance(account, big.NewInt(1000000)) |
| 929 | |
| 930 | // Keep track of transaction events to ensure all executables get announced |
| 931 | events := make(chan NewTxsEvent, testTxPoolConfig.AccountQueue+5) |
| 932 | sub := pool.txFeed.Subscribe(events) |
| 933 | defer sub.Unsubscribe() |
| 934 | |
| 935 | // Keep queuing up transactions and make sure all above a limit are dropped |
| 936 | for i := uint64(0); i < testTxPoolConfig.AccountQueue+5; i++ { |
| 937 | if err := pool.AddRemote(transaction(i, 100000, key)); err != nil { |
| 938 | t.Fatalf("tx %d: failed to add transaction: %v", i, err) |
| 939 | } |
| 940 | if pool.pending[account].Len() != int(i)+1 { |
| 941 | t.Errorf("tx %d: pending pool size mismatch: have %d, want %d", i, pool.pending[account].Len(), i+1) |
| 942 | } |
| 943 | if len(pool.queue) != 0 { |
| 944 | t.Errorf("tx %d: queue size mismatch: have %d, want %d", i, pool.queue[account].Len(), 0) |
| 945 | } |
| 946 | } |
| 947 | if pool.all.Count() != int(testTxPoolConfig.AccountQueue+5) { |
| 948 | t.Errorf("total transaction mismatch: have %d, want %d", pool.all.Count(), testTxPoolConfig.AccountQueue+5) |
| 949 | } |
| 950 | if err := validateEvents(events, int(testTxPoolConfig.AccountQueue+5)); err != nil { |
| 951 | t.Fatalf("event firing failed: %v", err) |
| 952 | } |
| 953 | if err := validateTxPoolInternals(pool); err != nil { |
| 954 | t.Fatalf("pool internal state corrupted: %v", err) |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | // Tests that the transaction limits are enforced the same way irrelevant whether |
| 959 | // the transactions are added one by one or in batches. |
nothing calls this directly
no test coverage detected