"github.com/bytom/protocol/bc"
"github.com/bytom/protocol/bc/types"
"github.com/bytom/protocol/state"
- "github.com/bytom/testutil"
"github.com/bytom/protocol/vm/vmutil"
+ "github.com/bytom/testutil"
)
func TestCheckBlockTime(t *testing.T) {
},
}
- parent := &state.BlockNode{}
+ parent := &state.BlockNode{Version: 1}
block := &bc.Block{
- BlockHeader: &bc.BlockHeader{},
+ BlockHeader: &bc.BlockHeader{Version: 1},
}
for i, c := range cases {
}{
{
block: &bc.Block{BlockHeader: &bc.BlockHeader{
- Version: 1,
+ Version: 2,
}},
parent: &state.BlockNode{
- Version: 2,
+ Version: 1,
},
err: errVersionRegression,
},
{
block: &bc.Block{BlockHeader: &bc.BlockHeader{
- Height: 20,
+ Version: 1,
+ Height: 20,
}},
parent: &state.BlockNode{
- Height: 18,
+ Version: 1,
+ Height: 18,
},
err: errMisorderedBlockHeight,
},
{
block: &bc.Block{BlockHeader: &bc.BlockHeader{
- Height: 20,
- Bits: 0,
+ Version: 1,
+ Height: 20,
+ Bits: 0,
}},
parent: &state.BlockNode{
- Height: 19,
- Bits: 2305843009214532812,
+ Version: 1,
+ Height: 19,
+ Bits: 2305843009214532812,
},
err: errBadBits,
},
{
block: &bc.Block{BlockHeader: &bc.BlockHeader{
+ Version: 1,
Height: 20,
PreviousBlockId: &bc.Hash{V0: 18},
}},
parent: &state.BlockNode{
- Height: 19,
- Hash: bc.Hash{V0: 19},
+ Version: 1,
+ Height: 19,
+ Hash: bc.Hash{V0: 19},
},
err: errMismatchedBlock,
},
block: &bc.Block{
ID: bc.Hash{V0: 0},
BlockHeader: &bc.BlockHeader{
+ Version: 1,
Height: 1,
Timestamp: 1523352601,
PreviousBlockId: &bc.Hash{V0: 0},
},
},
parent: &state.BlockNode{
+ Version: 1,
Height: 0,
Timestamp: 1523352600,
Hash: bc.Hash{V0: 0},
block: &bc.Block{
ID: bc.Hash{V0: 1},
BlockHeader: &bc.BlockHeader{
+ Version: 1,
Height: 1,
Timestamp: 1523352601,
PreviousBlockId: &bc.Hash{V0: 0},
},
},
parent: &state.BlockNode{
+ Version: 1,
Height: 0,
Timestamp: 1523352600,
Hash: bc.Hash{V0: 0},
block: &bc.Block{
ID: bc.Hash{V0: 1},
BlockHeader: &bc.BlockHeader{
- Height: 1,
- Timestamp: 1523352601,
- PreviousBlockId: &bc.Hash{V0: 0},
- Bits: 2305843009214532812,
+ Version: 1,
+ Height: 1,
+ Timestamp: 1523352601,
+ PreviousBlockId: &bc.Hash{V0: 0},
+ Bits: 2305843009214532812,
TransactionsRoot: &bc.Hash{V0: 1},
},
Transactions: []*bc.Tx{
types.MapTx(&types.TxData{
+ Version: 1,
SerializedSize: 1,
- Inputs: []*types.TxInput{types.NewCoinbaseInput(nil)},
- Outputs: []*types.TxOutput{types.NewTxOutput(*consensus.BTMAssetID, 41250000000, cp)},
+ Inputs: []*types.TxInput{types.NewCoinbaseInput(nil)},
+ Outputs: []*types.TxOutput{types.NewTxOutput(*consensus.BTMAssetID, 41250000000, cp)},
}),
},
},
parent: &state.BlockNode{
+ Version: 1,
Height: 0,
Timestamp: 1523352600,
Hash: bc.Hash{V0: 0},
block: &bc.Block{
ID: bc.Hash{V0: 1},
BlockHeader: &bc.BlockHeader{
- Height: 1,
- Timestamp: 1523352601,
- PreviousBlockId: &bc.Hash{V0: 0},
- Bits: 2305843009214532812,
- TransactionsRoot: &bc.Hash{V0: 6294987741126419124, V1: 12520373106916389157, V2: 5040806596198303681, V3: 1151748423853876189},
+ Version: 1,
+ Height: 1,
+ Timestamp: 1523352601,
+ PreviousBlockId: &bc.Hash{V0: 0},
+ Bits: 2305843009214532812,
+ TransactionsRoot: &bc.Hash{V0: 6294987741126419124, V1: 12520373106916389157, V2: 5040806596198303681, V3: 1151748423853876189},
TransactionStatusHash: &bc.Hash{V0: 1},
},
Transactions: []*bc.Tx{
types.MapTx(&types.TxData{
+ Version: 1,
SerializedSize: 1,
- Inputs: []*types.TxInput{types.NewCoinbaseInput(nil)},
- Outputs: []*types.TxOutput{types.NewTxOutput(*consensus.BTMAssetID, 41250000000, cp)},
+ Inputs: []*types.TxInput{types.NewCoinbaseInput(nil)},
+ Outputs: []*types.TxOutput{types.NewTxOutput(*consensus.BTMAssetID, 41250000000, cp)},
}),
},
},
parent: &state.BlockNode{
+ Version: 1,
Height: 0,
Timestamp: 1523352600,
Hash: bc.Hash{V0: 0},
valid bool
}{
{
- desc: "block version is 0",
- version: func() uint64 { return 0 },
- prevHeight: chain.BestBlockHeight,
- timestamp: func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
- prevHash: chain.BestBlockHash,
- bits: func() uint64 { return chain.BestBlockHeader().Bits },
- solve: true,
- valid: false,
- },
- {
- desc: "block version grater than prevBlock.Version",
- version: func() uint64 { return chain.BestBlockHeader().Version + 10 },
+ desc: "block version is 1",
+ version: func() uint64 { return 1 },
prevHeight: chain.BestBlockHeight,
timestamp: func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
prevHash: chain.BestBlockHash,