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/crypto/sha3pool"
14 "github.com/bytom/protocol/bc"
15 "github.com/bytom/protocol/bc/legacy"
16 "github.com/bytom/protocol/state"
19 func TestNewInitBlock(t *testing.T) {
20 coinbaseTx, err := createCoinbaseTx(nil, 0, 1)
24 merkleRoot, err := bc.MerkleRoot([]*bc.Tx{coinbaseTx.Tx})
29 if err := snap.ApplyTx(coinbaseTx.Tx); err != nil {
34 sha3pool.Sum256(seed[:], make([]byte, 32))
37 BlockHeader: legacy.BlockHeader{
40 PreviousBlockHash: bc.Hash{},
41 TimestampMS: bc.Millis(time.Now()),
42 BlockCommitment: legacy.BlockCommitment{
43 TransactionsMerkleRoot: merkleRoot,
44 AssetsMerkleRoot: snap.Tree.RootHash(),
46 Bits: uint64(2161727821138738707),
47 Seed: bc.NewHash(seed),
49 Transactions: []*legacy.Tx{coinbaseTx},
52 for i := uint64(0); i <= 10000000000000; i++ {
56 if consensus.CheckProofOfWork(&hash, b.Bits) {
61 rawBlock, err := b.MarshalText()
65 fmt.Println(string(rawBlock))