MCPcopy Index your code
hub / github.com/chain/Core / newTestChain

Function newTestChain

protocol/block_test.go:217–237  ·  view source on GitHub ↗

newTestChain returns a new Chain using memstore for storage, along with an initial block b1 (with a 0/0 multisig program). It commits b1 before returning.

(tb testing.TB, ts time.Time)

Source from the content-addressed store, hash-verified

215// along with an initial block b1 (with a 0/0 multisig program).
216// It commits b1 before returning.
217func newTestChain(tb testing.TB, ts time.Time) (c *Chain, b1 *legacy.Block) {
218 ctx := context.Background()
219
220 var err error
221
222 b1, err = NewInitialBlock(nil, 0, ts)
223 if err != nil {
224 testutil.FatalErr(tb, err)
225 }
226 c, err = NewChain(ctx, b1.Hash(), memstore.New(), nil)
227 if err != nil {
228 testutil.FatalErr(tb, err)
229 }
230 // TODO(tessr): consider adding MaxIssuanceWindow to NewChain
231 c.MaxIssuanceWindow = 48 * time.Hour
232 err = c.CommitAppliedBlock(ctx, b1, state.Empty())
233 if err != nil {
234 testutil.FatalErr(tb, err)
235 }
236 return c, b1
237}
238
239func makeEmptyBlock(tb testing.TB, c *Chain) {
240 ctx := context.Background()

Calls 4

NewInitialBlockFunction · 0.85
CommitAppliedBlockMethod · 0.80
NewChainFunction · 0.70
HashMethod · 0.45

Tested by

no test coverage detected