6 "github.com/vapor/consensus"
7 "github.com/vapor/protocol/bc"
8 "github.com/vapor/protocol/bc/types"
9 "github.com/vapor/protocol/state"
12 func TestCheckBlockTime(t *testing.T) {
19 blockTime: 1520000001,
20 parentTime: 1520000000,
24 blockTime: 1510000000,
25 parentTime: 1520000000,
29 blockTime: 9999999999,
30 parentTime: 1520000000,
35 parent := &state.BlockNode{}
37 BlockHeader: &bc.BlockHeader{},
40 for i, c := range cases {
41 parent.Timestamp = c.parentTime
42 block.Timestamp = c.blockTime
43 if err := checkBlockTime(block, parent); rootErr(err) != c.err {
44 t.Errorf("case %d got error %s, want %s", i, err, c.err)
49 func TestCheckCoinbaseAmount(t *testing.T) {
57 types.NewTx(types.TxData{
58 Inputs: []*types.TxInput{types.NewCoinbaseInput(nil)},
59 Outputs: []*types.TxOutput{types.NewTxOutput(*consensus.BTMAssetID, 5000, nil)},
67 types.NewTx(types.TxData{
68 Inputs: []*types.TxInput{types.NewCoinbaseInput(nil)},
69 Outputs: []*types.TxOutput{types.NewTxOutput(*consensus.BTMAssetID, 5000, nil)},
73 err: ErrWrongCoinbaseTransaction,
78 err: ErrWrongCoinbaseTransaction,
82 block := new(types.Block)
83 for i, c := range cases {
84 block.Transactions = c.txs
85 if err := checkCoinbaseAmount(types.MapBlock(block), c.amount); rootErr(err) != c.err {
86 t.Errorf("case %d got error %s, want %s", i, err, c.err)