(t *testing.T)
| 432 | } |
| 433 | |
| 434 | func TestTransactionNonceRecovery(t *testing.T) { |
| 435 | t.Parallel() |
| 436 | |
| 437 | const n = 10 |
| 438 | pool, key := setupTxPool() |
| 439 | defer pool.Stop() |
| 440 | |
| 441 | addr := crypto.PubkeyToAddress(key.PublicKey) |
| 442 | pool.currentState.SetNonce(addr, n) |
| 443 | pool.currentState.AddBalance(addr, big.NewInt(100000000000000)) |
| 444 | pool.lockedReset(nil, nil) |
| 445 | |
| 446 | tx := transaction(n, 100000, key) |
| 447 | if err := pool.AddRemote(tx); err != nil { |
| 448 | t.Error(err) |
| 449 | } |
| 450 | // simulate some weird re-order of transactions and missing nonce(s) |
| 451 | pool.currentState.SetNonce(addr, n-1) |
| 452 | pool.lockedReset(nil, nil) |
| 453 | if fn := pool.pendingState.GetNonce(addr); fn != n-1 { |
| 454 | t.Errorf("expected nonce to be %d, got %d", n-1, fn) |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | // Tests that if an account runs out of funds, any pending and queued transactions |
| 459 | // are dropped. |
nothing calls this directly
no test coverage detected