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

Function TestTransactionChainFork

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

Source from the content-addressed store, hash-verified

330}
331
332func TestTransactionChainFork(t *testing.T) {
333 t.Parallel()
334
335 pool, key := setupTxPool()
336 defer pool.Stop()
337
338 addr := crypto.PubkeyToAddress(key.PublicKey)
339 resetState := func() {
340 statedb, _ := state.New(common.Hash{}, state.NewDatabase(database.NewMemDatabase()))
341 statedb.AddBalance(addr, big.NewInt(100000000000000))
342
343 pool.chain = &testBlockChain{statedb, 1000000, new(event.Feed)}
344 pool.lockedReset(nil, nil)
345 }
346 resetState()
347
348 tx := transaction(0, 100000, key)
349 if _, err := pool.add(tx, false); err != nil {
350 t.Error("didn't expect error", err)
351 }
352 pool.removeTx(tx.Hash(), true)
353
354 // reset the pool's internal state
355 resetState()
356 if _, err := pool.add(tx, false); err != nil {
357 t.Error("didn't expect error", err)
358 }
359}
360
361func TestTransactionDoubleNonce(t *testing.T) {
362 t.Parallel()

Callers

nothing calls this directly

Calls 9

setupTxPoolFunction · 0.85
transactionFunction · 0.85
lockedResetMethod · 0.80
removeTxMethod · 0.80
StopMethod · 0.65
AddBalanceMethod · 0.65
ErrorMethod · 0.65
HashMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected