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/consensus"
13 "github.com/bytom/protocol/bc"
14 "github.com/bytom/protocol/bc/legacy"
15 "github.com/bytom/protocol/state"
18 func TestNewInitBlock(t *testing.T) {
19 coinbaseTx, err := createCoinbaseTx(0, 1, []byte{})
23 merkleRoot, err := bc.MerkleRoot([]*bc.Tx{coinbaseTx.Tx})
28 if err := snap.ApplyTx(coinbaseTx.Tx); err != nil {
33 BlockHeader: legacy.BlockHeader{
36 PreviousBlockHash: bc.Hash{},
37 TimestampMS: bc.Millis(time.Now()),
38 BlockCommitment: legacy.BlockCommitment{
39 TransactionsMerkleRoot: merkleRoot,
40 AssetsMerkleRoot: snap.Tree.RootHash(),
42 Bits: uint64(2161727821138738707),
44 Transactions: []*legacy.Tx{coinbaseTx},
47 for i := uint64(0); i <= 10000000000000; i++ {
51 if consensus.CheckProofOfWork(&hash, b.Bits) {
56 rawBlock, err := b.MarshalText()
60 fmt.Println(string(rawBlock))