1 // Copyright (c) 2014-2016 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
12 "github.com/bytom/protocol/bc"
13 "github.com/bytom/protocol/bc/legacy"
14 "github.com/bytom/protocol/state"
17 func TestNewInitBlock(t *testing.T) {
18 coinbaseTx, err := createCoinbaseTx(0, 0, []byte{})
22 merkleRoot, err := bc.MerkleRoot([]*bc.Tx{coinbaseTx.Tx})
27 if err := snap.ApplyTx(coinbaseTx.Tx); err != nil {
32 BlockHeader: legacy.BlockHeader{
35 PreviousBlockHash: bc.Hash{},
36 TimestampMS: bc.Millis(time.Now()),
37 BlockCommitment: legacy.BlockCommitment{
38 TransactionsMerkleRoot: merkleRoot,
39 AssetsMerkleRoot: snap.Tree.RootHash(),
41 Bits: uint64(3314649325747331761),
44 Transactions: []*legacy.Tx{coinbaseTx},
47 rawBlock, err := b.MarshalText()
51 fmt.Println(string(rawBlock))