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

Method State

core/tx_pool_test.go:162–175  ·  view source on GitHub ↗

testChain.State() is used multiple times to reset the pending state. when simulate is true it will create a state that indicates that tx0 and tx1 are included in the chain.

()

Source from the content-addressed store, hash-verified

160// when simulate is true it will create a state that indicates
161// that tx0 and tx1 are included in the chain.
162func (c *testChain) State() (*state.StateDB, error) {
163 // delay "state change" by one. The tx pool fetches the
164 // state multiple times and by delaying it a bit we simulate
165 // a state change between those fetches.
166 stdb := c.statedb
167 if *c.trigger {
168 c.statedb, _ = state.New(common.Hash{}, state.NewDatabase(database.NewMemDatabase()))
169 // simulate that the new head block included tx0 and tx1
170 c.statedb.SetNonce(c.address, 2)
171 c.statedb.SetBalance(c.address, new(big.Int).SetUint64(configs.Cpc))
172 *c.trigger = false
173 }
174 return stdb, nil
175}
176
177// This test simulates a scenario where a new block is imported during a
178// state reset and tests whether the pending state is in sync with the

Callers

nothing calls this directly

Calls 2

SetNonceMethod · 0.65
SetBalanceMethod · 0.45

Tested by

no test coverage detected