Documentation ¶
Overview ¶
Package chain contains functions creating new test blockchain instances. Different configurations can be used, but all chains created here use well-known keys. Most of the time, a single-node chain is the best choice to use unless you specifically need multiple validators and a large committee.
Index ¶
- Constants
- func NewMulti(t testing.TB) (*core.Blockchain, neotest.Signer, neotest.Signer)
- func NewMultiWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, neotest.Signer, neotest.Signer)
- func NewMultiWithCustomConfigAndStore(t testing.TB, f func(*config.Blockchain), st storage.Store, run bool) (*core.Blockchain, neotest.Signer, neotest.Signer)
- func NewMultiWithCustomConfigAndStoreNoCheck(t testing.TB, f func(*config.Blockchain), st storage.Store) (*core.Blockchain, neotest.Signer, neotest.Signer, error)
- func NewSingle(t testing.TB) (*core.Blockchain, neotest.Signer)
- func NewSingleWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, neotest.Signer)
- func NewSingleWithCustomConfigAndStore(t testing.TB, f func(cfg *config.Blockchain), st storage.Store, run bool) (*core.Blockchain, neotest.Signer)
Constants ¶
const ( // MaxTraceableBlocks is the default MaxTraceableBlocks setting used for test chains. // We don't need a lot of traceable blocks for tests. MaxTraceableBlocks = 1000 // TimePerBlock is the default TimePerBlock setting used for test chains (1s). // Usually blocks are created by tests bypassing this setting. TimePerBlock = time.Second )
Variables ¶
This section is empty.
Functions ¶
func NewMulti ¶
NewMulti creates a new blockchain instance with four validators and six committee members. Otherwise, it does not differ much from NewSingle. The second value returned contains the validators Signer, the third -- the committee one.
func NewMultiWithCustomConfig ¶ added in v0.98.1
func NewMultiWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, neotest.Signer, neotest.Signer)
NewMultiWithCustomConfig is similar to NewMulti, except it allows to override the default configuration.
func NewMultiWithCustomConfigAndStore ¶ added in v0.99.0
func NewMultiWithCustomConfigAndStore(t testing.TB, f func(*config.Blockchain), st storage.Store, run bool) (*core.Blockchain, neotest.Signer, neotest.Signer)
NewMultiWithCustomConfigAndStore is similar to NewMultiWithCustomConfig, but also allows to override backend Store being used. The last parameter controls if Run method is called on the Blockchain instance. If not, it is its caller's responsibility to do that before using the chain and to properly Close the chain when done.
func NewMultiWithCustomConfigAndStoreNoCheck ¶ added in v0.99.0
func NewMultiWithCustomConfigAndStoreNoCheck(t testing.TB, f func(*config.Blockchain), st storage.Store) (*core.Blockchain, neotest.Signer, neotest.Signer, error)
NewMultiWithCustomConfigAndStoreNoCheck is similar to NewMultiWithCustomConfig, but do not perform Blockchain run and do not check Blockchain constructor error.
func NewSingle ¶
NewSingle creates a new blockchain instance with a single validator and setups cleanup functions. The configuration used is with netmode.UnitTestNet magic and TimePerBlock/MaxTraceableBlocks options defined by constants in this package. MemoryStore is used as the backend storage, so all of the chain contents is always in RAM. The Signer returned is the validator (and the committee at the same time).
func NewSingleWithCustomConfig ¶ added in v0.98.1
func NewSingleWithCustomConfig(t testing.TB, f func(*config.Blockchain)) (*core.Blockchain, neotest.Signer)
NewSingleWithCustomConfig is similar to NewSingle, but allows to override the default configuration.
func NewSingleWithCustomConfigAndStore ¶ added in v0.98.1
func NewSingleWithCustomConfigAndStore(t testing.TB, f func(cfg *config.Blockchain), st storage.Store, run bool) (*core.Blockchain, neotest.Signer)
NewSingleWithCustomConfigAndStore is similar to NewSingleWithCustomConfig, but also allows to override backend Store being used. The last parameter controls if Run method is called on the Blockchain instance. If not, it is its caller's responsibility to do that before using the chain and to properly Close the chain when done.
Types ¶
This section is empty.