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

Function TestTransactionNonceRecovery

core/tx_pool_test.go:434–456  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

432}
433
434func 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.

Callers

nothing calls this directly

Calls 9

setupTxPoolFunction · 0.85
transactionFunction · 0.85
lockedResetMethod · 0.80
AddRemoteMethod · 0.80
StopMethod · 0.65
SetNonceMethod · 0.65
AddBalanceMethod · 0.65
ErrorMethod · 0.65
GetNonceMethod · 0.65

Tested by

no test coverage detected