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)
| 215 | // along with an initial block b1 (with a 0/0 multisig program). |
| 216 | // It commits b1 before returning. |
| 217 | func 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 | |
| 239 | func makeEmptyBlock(tb testing.TB, c *Chain) { |
| 240 | ctx := context.Background() |
no test coverage detected