[lbry] test: fixed all current tests and delete three.
Co-authored-by: Roy Lee <roylee17@gmail.com>
This commit is contained in:
parent
ed5dd41a2a
commit
f73b79ae04
45 changed files with 237 additions and 1110 deletions
|
@ -6,14 +6,12 @@ package blockchain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase
|
// BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase
|
||||||
// function.
|
// function.
|
||||||
func BenchmarkIsCoinBase(b *testing.B) {
|
func BenchmarkIsCoinBase(b *testing.B) {
|
||||||
tx, _ := btcutil.NewBlock(&Block100000).Tx(1)
|
tx, _ := GetBlock100000().Tx(1)
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
IsCoinBase(tx)
|
IsCoinBase(tx)
|
||||||
|
@ -23,9 +21,9 @@ func BenchmarkIsCoinBase(b *testing.B) {
|
||||||
// BenchmarkIsCoinBaseTx performs a simple benchmark against the IsCoinBaseTx
|
// BenchmarkIsCoinBaseTx performs a simple benchmark against the IsCoinBaseTx
|
||||||
// function.
|
// function.
|
||||||
func BenchmarkIsCoinBaseTx(b *testing.B) {
|
func BenchmarkIsCoinBaseTx(b *testing.B) {
|
||||||
tx := Block100000.Transactions[1]
|
tx, _ := GetBlock100000().Tx(1)
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
IsCoinBaseTx(tx)
|
IsCoinBaseTx(tx.MsgTx())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,102 +15,6 @@ import (
|
||||||
btcutil "github.com/lbryio/lbcutil"
|
btcutil "github.com/lbryio/lbcutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestHaveBlock tests the HaveBlock API to ensure proper functionality.
|
|
||||||
func TestHaveBlock(t *testing.T) {
|
|
||||||
// Load up blocks such that there is a side chain.
|
|
||||||
// (genesis block) -> 1 -> 2 -> 3 -> 4
|
|
||||||
// \-> 3a
|
|
||||||
testFiles := []string{
|
|
||||||
"blk_0_to_4.dat.bz2",
|
|
||||||
"blk_3A.dat.bz2",
|
|
||||||
}
|
|
||||||
|
|
||||||
var blocks []*btcutil.Block
|
|
||||||
for _, file := range testFiles {
|
|
||||||
blockTmp, err := loadBlocks(file)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Error loading file: %v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
blocks = append(blocks, blockTmp...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new database and chain instance to run tests against.
|
|
||||||
chain, teardownFunc, err := chainSetup("haveblock",
|
|
||||||
&chaincfg.MainNetParams)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Failed to setup chain instance: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer teardownFunc()
|
|
||||||
|
|
||||||
// Since we're not dealing with the real block chain, set the coinbase
|
|
||||||
// maturity to 1.
|
|
||||||
chain.TstSetCoinbaseMaturity(1)
|
|
||||||
|
|
||||||
for i := 1; i < len(blocks); i++ {
|
|
||||||
_, isOrphan, err := chain.ProcessBlock(blocks[i], BFNone)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("ProcessBlock fail on block %v: %v\n", i, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if isOrphan {
|
|
||||||
t.Errorf("ProcessBlock incorrectly returned block %v "+
|
|
||||||
"is an orphan\n", i)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert an orphan block.
|
|
||||||
_, isOrphan, err := chain.ProcessBlock(btcutil.NewBlock(&Block100000),
|
|
||||||
BFNone)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unable to process block: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !isOrphan {
|
|
||||||
t.Errorf("ProcessBlock indicated block is an not orphan when " +
|
|
||||||
"it should be\n")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
hash string
|
|
||||||
want bool
|
|
||||||
}{
|
|
||||||
// Genesis block should be present (in the main chain).
|
|
||||||
{hash: chaincfg.MainNetParams.GenesisHash.String(), want: true},
|
|
||||||
|
|
||||||
// Block 3a should be present (on a side chain).
|
|
||||||
{hash: "00000000474284d20067a4d33f6a02284e6ef70764a3a26d6a5b9df52ef663dd", want: true},
|
|
||||||
|
|
||||||
// Block 100000 should be present (as an orphan).
|
|
||||||
{hash: "000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506", want: true},
|
|
||||||
|
|
||||||
// Random hashes should not be available.
|
|
||||||
{hash: "123", want: false},
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, test := range tests {
|
|
||||||
hash, err := chainhash.NewHashFromStr(test.hash)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("NewHashFromStr: %v", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := chain.HaveBlock(hash)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("HaveBlock #%d unexpected error: %v", i, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if result != test.want {
|
|
||||||
t.Errorf("HaveBlock #%d got %v want %v", i, result,
|
|
||||||
test.want)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestCalcSequenceLock tests the LockTimeToSequence function, and the
|
// TestCalcSequenceLock tests the LockTimeToSequence function, and the
|
||||||
// CalcSequenceLock method of a Chain instance. The tests exercise several
|
// CalcSequenceLock method of a Chain instance. The tests exercise several
|
||||||
// combinations of inputs to the CalcSequenceLock function in order to ensure
|
// combinations of inputs to the CalcSequenceLock function in order to ensure
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package blockchain
|
package blockchain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"compress/bzip2"
|
"compress/bzip2"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -63,13 +64,13 @@ func isSupportedDbType(dbType string) bool {
|
||||||
func loadBlocks(filename string) (blocks []*btcutil.Block, err error) {
|
func loadBlocks(filename string) (blocks []*btcutil.Block, err error) {
|
||||||
filename = filepath.Join("testdata/", filename)
|
filename = filepath.Join("testdata/", filename)
|
||||||
|
|
||||||
var network = wire.MainNet
|
var network = 0xd9b4bef9 // bitcoin's network ID
|
||||||
var dr io.Reader
|
var dr io.Reader
|
||||||
var fi io.ReadCloser
|
var fi io.ReadCloser
|
||||||
|
|
||||||
fi, err = os.Open(filename)
|
fi, err = os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return blocks, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(filename, ".bz2") {
|
if strings.HasSuffix(filename, ".bz2") {
|
||||||
|
@ -95,7 +96,7 @@ func loadBlocks(filename string) (blocks []*btcutil.Block, err error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if rintbuf != uint32(network) {
|
if rintbuf != uint32(network) {
|
||||||
break
|
continue
|
||||||
}
|
}
|
||||||
err = binary.Read(dr, binary.LittleEndian, &rintbuf)
|
err = binary.Read(dr, binary.LittleEndian, &rintbuf)
|
||||||
blocklen := rintbuf
|
blocklen := rintbuf
|
||||||
|
@ -105,14 +106,20 @@ func loadBlocks(filename string) (blocks []*btcutil.Block, err error) {
|
||||||
// read block
|
// read block
|
||||||
dr.Read(rbytes)
|
dr.Read(rbytes)
|
||||||
|
|
||||||
|
// inject claimtrie:
|
||||||
|
tail := make([]byte, len(rbytes)-68)
|
||||||
|
copy(tail, rbytes[68:])
|
||||||
|
rbytes = append(rbytes[:68], bytes.Repeat([]byte{23}, chainhash.HashSize)...)
|
||||||
|
rbytes = append(rbytes, tail...)
|
||||||
|
|
||||||
block, err = btcutil.NewBlockFromBytes(rbytes)
|
block, err = btcutil.NewBlockFromBytes(rbytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return blocks, err
|
||||||
}
|
}
|
||||||
blocks = append(blocks, block)
|
blocks = append(blocks, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return blocks, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// chainSetup is used to create a new db and chain instance with the genesis
|
// chainSetup is used to create a new db and chain instance with the genesis
|
||||||
|
|
|
@ -245,10 +245,11 @@ func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTim
|
||||||
|
|
||||||
// Get the block node at the previous retarget (targetTimespan days
|
// Get the block node at the previous retarget (targetTimespan days
|
||||||
// worth of blocks).
|
// worth of blocks).
|
||||||
firstNode := lastNode.RelativeAncestor(b.blocksPerRetarget)
|
blocksBack := b.blocksPerRetarget
|
||||||
if lastNode.height == 0 {
|
if blocksBack > lastNode.height {
|
||||||
firstNode = lastNode
|
blocksBack = lastNode.height
|
||||||
}
|
}
|
||||||
|
firstNode := lastNode.RelativeAncestor(blocksBack)
|
||||||
if firstNode == nil {
|
if firstNode == nil {
|
||||||
return 0, AssertError("unable to obtain previous retarget block")
|
return 0, AssertError("unable to obtain previous retarget block")
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ func ExampleBlockChain_ProcessBlock() {
|
||||||
fmt.Printf("Block accepted. Is it an orphan?: %v", isOrphan)
|
fmt.Printf("Block accepted. Is it an orphan?: %v", isOrphan)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// Failed to process block: already have block 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
// Failed to process block: already have block 9c89283ba0f3227f6c03b70216b9f665f0118d5e0fa729cedf4fb34d6a34f463
|
||||||
}
|
}
|
||||||
|
|
||||||
// This example demonstrates how to convert the compact "bits" in a block header
|
// This example demonstrates how to convert the compact "bits" in a block header
|
||||||
|
|
|
@ -139,7 +139,7 @@ func TestFullBlocks(t *testing.T) {
|
||||||
|
|
||||||
// Create a new database and chain instance to run tests against.
|
// Create a new database and chain instance to run tests against.
|
||||||
chain, teardownFunc, err := chainSetup("fullblocktest",
|
chain, teardownFunc, err := chainSetup("fullblocktest",
|
||||||
&chaincfg.RegressionNetParams)
|
fullblocktests.FbRegressionNetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to setup chain instance: %v", err)
|
t.Errorf("Failed to setup chain instance: %v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -31,7 +31,7 @@ const (
|
||||||
// Intentionally defined here rather than using constants from codebase
|
// Intentionally defined here rather than using constants from codebase
|
||||||
// to ensure consensus changes are detected.
|
// to ensure consensus changes are detected.
|
||||||
maxBlockSigOps = 20000
|
maxBlockSigOps = 20000
|
||||||
maxBlockSize = 2000000
|
maxBlockSize = 8000000
|
||||||
minCoinbaseScriptLen = 2
|
minCoinbaseScriptLen = 2
|
||||||
maxCoinbaseScriptLen = 100
|
maxCoinbaseScriptLen = 100
|
||||||
medianTimeBlocks = 11
|
medianTimeBlocks = 11
|
||||||
|
@ -342,10 +342,8 @@ func solveBlock(header *wire.BlockHeader) bool {
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
hdr.Nonce = i
|
hdr.Nonce = i
|
||||||
hash := hdr.BlockHash()
|
hash := hdr.BlockPoWHash()
|
||||||
if blockchain.HashToBig(&hash).Cmp(
|
if blockchain.HashToBig(&hash).Cmp(targetDifficulty) <= 0 {
|
||||||
targetDifficulty) <= 0 {
|
|
||||||
|
|
||||||
results <- sbResult{true, i}
|
results <- sbResult{true, i}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -811,7 +809,7 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
|
||||||
|
|
||||||
// Create a test generator instance initialized with the genesis block
|
// Create a test generator instance initialized with the genesis block
|
||||||
// as the tip.
|
// as the tip.
|
||||||
g, err := makeTestGenerator(regressionNetParams)
|
g, err := makeTestGenerator(FbRegressionNetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1444,7 +1442,7 @@ func Generate(includeLargeReorg bool) (tests [][]TestInstance, err error) {
|
||||||
// Keep incrementing the nonce until the hash treated as
|
// Keep incrementing the nonce until the hash treated as
|
||||||
// a uint256 is higher than the limit.
|
// a uint256 is higher than the limit.
|
||||||
b46.Header.Nonce++
|
b46.Header.Nonce++
|
||||||
blockHash := b46.BlockHash()
|
blockHash := b46.Header.BlockPoWHash()
|
||||||
hashNum := blockchain.HashToBig(&blockHash)
|
hashNum := blockchain.HashToBig(&blockHash)
|
||||||
if hashNum.Cmp(g.params.PowLimit) >= 0 {
|
if hashNum.Cmp(g.params.PowLimit) >= 0 {
|
||||||
break
|
break
|
||||||
|
|
|
@ -54,6 +54,7 @@ var (
|
||||||
Version: 1,
|
Version: 1,
|
||||||
PrevBlock: *newHashFromStr("0000000000000000000000000000000000000000000000000000000000000000"),
|
PrevBlock: *newHashFromStr("0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
MerkleRoot: *newHashFromStr("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"),
|
MerkleRoot: *newHashFromStr("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"),
|
||||||
|
ClaimTrie: chainhash.Hash{1}, // EmptyTrieHash
|
||||||
Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC
|
Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC
|
||||||
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
|
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
|
||||||
Nonce: 2,
|
Nonce: 2,
|
||||||
|
@ -83,23 +84,25 @@ var (
|
||||||
LockTime: 0,
|
LockTime: 0,
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
regTestGenesisBlockHash = regTestGenesisBlock.BlockHash()
|
||||||
)
|
)
|
||||||
|
|
||||||
// regressionNetParams defines the network parameters for the regression test
|
// FbRegressionNetParams defines the network parameters for the regression test
|
||||||
// network.
|
// network.
|
||||||
//
|
//
|
||||||
// NOTE: The test generator intentionally does not use the existing definitions
|
// NOTE: The test generator intentionally does not use the existing definitions
|
||||||
// in the chaincfg package since the intent is to be able to generate known
|
// in the chaincfg package since the intent is to be able to generate known
|
||||||
// good tests which exercise that code. Using the chaincfg parameters would
|
// good tests which exercise that code. Using the chaincfg parameters would
|
||||||
// allow them to change out from under the tests potentially invalidating them.
|
// allow them to change out from under the tests potentially invalidating them.
|
||||||
var regressionNetParams = &chaincfg.Params{
|
var FbRegressionNetParams = &chaincfg.Params{
|
||||||
Name: "regtest",
|
Name: "regtest",
|
||||||
Net: wire.TestNet,
|
Net: wire.TestNet,
|
||||||
DefaultPort: "18444",
|
DefaultPort: "18444",
|
||||||
|
|
||||||
// Chain parameters
|
// Chain parameters
|
||||||
GenesisBlock: ®TestGenesisBlock,
|
GenesisBlock: ®TestGenesisBlock,
|
||||||
GenesisHash: newHashFromStr("5bec7567af40504e0994db3b573c186fffcc4edefe096ff2e58d00523bd7e8a6"),
|
GenesisHash: ®TestGenesisBlockHash,
|
||||||
PowLimit: regressionPowLimit,
|
PowLimit: regressionPowLimit,
|
||||||
PowLimitBits: 0x207fffff,
|
PowLimitBits: 0x207fffff,
|
||||||
CoinbaseMaturity: 100,
|
CoinbaseMaturity: 100,
|
||||||
|
@ -113,6 +116,7 @@ var regressionNetParams = &chaincfg.Params{
|
||||||
ReduceMinDifficulty: true,
|
ReduceMinDifficulty: true,
|
||||||
MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2
|
MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2
|
||||||
GenerateSupported: true,
|
GenerateSupported: true,
|
||||||
|
MinerConfirmationWindow: 1,
|
||||||
|
|
||||||
// Checkpoints ordered from oldest to newest.
|
// Checkpoints ordered from oldest to newest.
|
||||||
Checkpoints: nil,
|
Checkpoints: nil,
|
||||||
|
|
|
@ -6,16 +6,14 @@ package blockchain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/btcsuite/btcutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestMerkle tests the BuildMerkleTreeStore API.
|
// TestMerkle tests the BuildMerkleTreeStore API.
|
||||||
func TestMerkle(t *testing.T) {
|
func TestMerkle(t *testing.T) {
|
||||||
block := btcutil.NewBlock(&Block100000)
|
block := GetBlock100000()
|
||||||
merkles := BuildMerkleTreeStore(block.Transactions(), false)
|
merkles := BuildMerkleTreeStore(block.Transactions(), false)
|
||||||
calculatedMerkleRoot := merkles[len(merkles)-1]
|
calculatedMerkleRoot := merkles[len(merkles)-1]
|
||||||
wantMerkle := &Block100000.Header.MerkleRoot
|
wantMerkle := block.MsgBlock().Header.MerkleRoot
|
||||||
if !wantMerkle.IsEqual(calculatedMerkleRoot) {
|
if !wantMerkle.IsEqual(calculatedMerkleRoot) {
|
||||||
t.Errorf("BuildMerkleTreeStore: merkle root mismatch - "+
|
t.Errorf("BuildMerkleTreeStore: merkle root mismatch - "+
|
||||||
"got %v, want %v", calculatedMerkleRoot, wantMerkle)
|
"got %v, want %v", calculatedMerkleRoot, wantMerkle)
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
// Copyright (c) 2017 The btcsuite developers
|
|
||||||
// Use of this source code is governed by an ISC
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package blockchain
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestNotifications ensures that notification callbacks are fired on events.
|
|
||||||
func TestNotifications(t *testing.T) {
|
|
||||||
blocks, err := loadBlocks("blk_0_to_4.dat.bz2")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error loading file: %v\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new database and chain instance to run tests against.
|
|
||||||
chain, teardownFunc, err := chainSetup("notifications",
|
|
||||||
&chaincfg.MainNetParams)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Failed to setup chain instance: %v", err)
|
|
||||||
}
|
|
||||||
defer teardownFunc()
|
|
||||||
|
|
||||||
notificationCount := 0
|
|
||||||
callback := func(notification *Notification) {
|
|
||||||
if notification.Type == NTBlockAccepted {
|
|
||||||
notificationCount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register callback multiple times then assert it is called that many
|
|
||||||
// times.
|
|
||||||
const numSubscribers = 3
|
|
||||||
for i := 0; i < numSubscribers; i++ {
|
|
||||||
chain.Subscribe(callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, _, err = chain.ProcessBlock(blocks[1], BFNone)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("ProcessBlock fail on block 1: %v\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if notificationCount != numSubscribers {
|
|
||||||
t.Fatalf("Expected notification callback to be executed %d "+
|
|
||||||
"times, found %d", numSubscribers, notificationCount)
|
|
||||||
}
|
|
||||||
}
|
|
BIN
blockchain/testdata/blk_0_to_4.dat.bz2
vendored
BIN
blockchain/testdata/blk_0_to_4.dat.bz2
vendored
Binary file not shown.
BIN
blockchain/testdata/blk_3A.dat.bz2
vendored
BIN
blockchain/testdata/blk_3A.dat.bz2
vendored
Binary file not shown.
BIN
blockchain/testdata/blk_4A.dat.bz2
vendored
BIN
blockchain/testdata/blk_4A.dat.bz2
vendored
Binary file not shown.
BIN
blockchain/testdata/blk_5A.dat.bz2
vendored
BIN
blockchain/testdata/blk_5A.dat.bz2
vendored
Binary file not shown.
180
blockchain/testdata/reorgtest.hex
vendored
180
blockchain/testdata/reorgtest.hex
vendored
|
@ -1,180 +0,0 @@
|
||||||
File path: reorgTest/blk_0_to_4.dat
|
|
||||||
|
|
||||||
Block 0:
|
|
||||||
f9beb4d9
|
|
||||||
1d010000
|
|
||||||
|
|
||||||
01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 3ba3edfd 7a7b12b2 7ac72c3e 67768f61 7fc81bc3 888a5132 3a9fb8aa
|
|
||||||
4b1e5e4a 29ab5f49 ffff001d 1dac2b7c
|
|
||||||
01
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff4d04ff ff001d01 04455468 65205469 6d657320 30332f4a
|
|
||||||
616e2f32 30303920 4368616e 63656c6c 6f72206f 6e206272 696e6b20 6f662073
|
|
||||||
65636f6e 64206261 696c6f75 7420666f 72206261 6e6b73ff ffffff01 00f2052a
|
|
||||||
01000000 43410467 8afdb0fe 55482719 67f1a671 30b7105c d6a828e0 3909a679
|
|
||||||
62e0ea1f 61deb649 f6bc3f4c ef38c4f3 5504e51e c112de5c 384df7ba 0b8d578a
|
|
||||||
4c702b6b f11d5fac 00000000
|
|
||||||
Block 1:
|
|
||||||
f9beb4d9
|
|
||||||
d4000000
|
|
||||||
|
|
||||||
01000000 6fe28c0a b6f1b372 c1a6a246 ae63f74f 931e8365 e15a089c 68d61900
|
|
||||||
00000000 3bbd67ad e98fbbb7 0718cd80 f9e9acf9 3b5fae91 7bb2b41d 4c3bb82c
|
|
||||||
77725ca5 81ad5f49 ffff001d 44e69904
|
|
||||||
01
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff04722f 2e2bffff ffff0100 f2052a01 00000043 41046868
|
|
||||||
0737c76d abb801cb 2204f57d be4e4579 e4f710cd 67dc1b42 27592c81 e9b5cf02
|
|
||||||
b5ac9e8b 4c9f49be 5251056b 6a6d011e 4c37f6b6 d17ede6b 55faa235 19e2ac00
|
|
||||||
000000
|
|
||||||
Block 2:
|
|
||||||
f9beb4d9
|
|
||||||
95010000
|
|
||||||
|
|
||||||
01000000 13ca7940 4c11c63e ca906bbd f190b751 2872b857 1b5143ae e8cb5737
|
|
||||||
00000000 fc07c983 d7391736 0aeda657 29d0d4d3 2533eb84 76ee9d64 aa27538f
|
|
||||||
9b4fc00a d9af5f49 ffff001d 630bea22
|
|
||||||
02
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff04eb96 14e5ffff ffff0100 f2052a01 00000043 41046868
|
|
||||||
0737c76d abb801cb 2204f57d be4e4579 e4f710cd 67dc1b42 27592c81 e9b5cf02
|
|
||||||
b5ac9e8b 4c9f49be 5251056b 6a6d011e 4c37f6b6 d17ede6b 55faa235 19e2ac00
|
|
||||||
000000
|
|
||||||
|
|
||||||
01000000 0163451d 1002611c 1388d5ba 4ddfdf99 196a86b5 990fb5b0 dc786207
|
|
||||||
4fdcb8ee d2000000 004a4930 46022100 3dde52c6 5e339f45 7fe1015e 70eed208
|
|
||||||
872eb71e dd484c07 206b190e cb2ec3f8 02210011 c78dcfd0 3d43fa63 61242a33
|
|
||||||
6291ba2a 8c1ef5bc d5472126 2468f2bf 8dee4d01 ffffffff 0200ca9a 3b000000
|
|
||||||
001976a9 14cb2abd e8bccacc 32e893df 3a054b9e f7f227a4 ce88ac00 286bee00
|
|
||||||
00000019 76a914ee 26c56fc1 d942be8d 7a24b2a1 001dd894 69398088 ac000000
|
|
||||||
00
|
|
||||||
Block 3:
|
|
||||||
f9beb4d9
|
|
||||||
96020000
|
|
||||||
|
|
||||||
01000000 7d338254 0506faab 0d4cf179 45dda023 49db51f9 6233f24c 28002258
|
|
||||||
00000000 4806fe80 bf85931b 882ea645 77ca5a03 22bb8af2 3f277b20 55f160cd
|
|
||||||
972c8e8b 31b25f49 ffff001d e8f0c653
|
|
||||||
03
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff044abd 8159ffff ffff0100 f2052a01 00000043 4104b95c
|
|
||||||
249d84f4 17e3e395 a1274254 28b54067 1cc15881 eb828c17 b722a53f c599e21c
|
|
||||||
a5e56c90 f340988d 3933acc7 6beb832f d64cab07 8ddf3ce7 32923031 d1a8ac00
|
|
||||||
000000
|
|
||||||
|
|
||||||
01000000 01f287b5 e067e1cf 80f7da8a f89917b5 505094db d82412d9 35b665eb
|
|
||||||
bad253d3 77010000 008c4930 46022100 96ee0d02 b35fd61e 4960b44f f396f67e
|
|
||||||
01fe17f9 de4e0c17 b6a963bd ab2b50a6 02210034 920d4daa 7e9f8abe 5675c931
|
|
||||||
495809f9 0b9c1189 d05fbaf1 dd6696a5 b0d8f301 41046868 0737c76d abb801cb
|
|
||||||
2204f57d be4e4579 e4f710cd 67dc1b42 27592c81 e9b5cf02 b5ac9e8b 4c9f49be
|
|
||||||
5251056b 6a6d011e 4c37f6b6 d17ede6b 55faa235 19e2ffff ffff0100 286bee00
|
|
||||||
00000019 76a914c5 22664fb0 e55cdc5c 0cea73b4 aad97ec8 34323288 ac000000
|
|
||||||
00
|
|
||||||
|
|
||||||
01000000 01f287b5 e067e1cf 80f7da8a f89917b5 505094db d82412d9 35b665eb
|
|
||||||
bad253d3 77000000 008c4930 46022100 b08b922a c4bde411 1c229f92 9fe6eb6a
|
|
||||||
50161f98 1f4cf47e a9214d35 bf74d380 022100d2 f6640327 e677a1e1 cc474991
|
|
||||||
b9a48ba5 bd1e0c94 d1c8df49 f7b0193b 7ea4fa01 4104b95c 249d84f4 17e3e395
|
|
||||||
a1274254 28b54067 1cc15881 eb828c17 b722a53f c599e21c a5e56c90 f340988d
|
|
||||||
3933acc7 6beb832f d64cab07 8ddf3ce7 32923031 d1a8ffff ffff0100 ca9a3b00
|
|
||||||
00000019 76a914c5 22664fb0 e55cdc5c 0cea73b4 aad97ec8 34323288 ac000000
|
|
||||||
00
|
|
||||||
|
|
||||||
Block 4:
|
|
||||||
f9beb4d9
|
|
||||||
73010000
|
|
||||||
|
|
||||||
01000000 5da36499 06f35e09 9be42a1d 87b6dd42 11bc1400 6c220694 0807eaae
|
|
||||||
00000000 48eeeaed 2d9d8522 e6201173 743823fd 4b87cd8a ca8e6408 ec75ca38
|
|
||||||
302c2ff0 89b45f49 ffff001d 00530839
|
|
||||||
02
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff04d41d 2213ffff ffff0100 f2052a01 00000043 4104678a
|
|
||||||
fdb0fe55 48271967 f1a67130 b7105cd6 a828e039 09a67962 e0ea1f61 deb649f6
|
|
||||||
bc3f4cef 38c4f355 04e51ec1 12de5c38 4df7ba0b 8d578a4c 702b6bf1 1d5fac00
|
|
||||||
000000
|
|
||||||
|
|
||||||
01000000 0163451d 1002611c 1388d5ba 4ddfdf99 196a86b5 990fb5b0 dc786207
|
|
||||||
4fdcb8ee d2000000 004a4930 46022100 8c8fd57b 48762135 8d8f3e69 19f33e08
|
|
||||||
804736ff 83db47aa 248512e2 6df9b8ba 022100b0 c59e5ee7 bfcbfcd1 a4d83da9
|
|
||||||
55fb260e fda7f42a 25522625 a3d6f2d9 1174a701 ffffffff 0100f205 2a010000
|
|
||||||
001976a9 14c52266 4fb0e55c dc5c0cea 73b4aad9 7ec83432 3288ac00 000000
|
|
||||||
|
|
||||||
File path: reorgTest/blk_3A.dat
|
|
||||||
Block 3A:
|
|
||||||
f9beb4d9
|
|
||||||
96020000
|
|
||||||
|
|
||||||
01000000 7d338254 0506faab 0d4cf179 45dda023 49db51f9 6233f24c 28002258
|
|
||||||
00000000 5a15f573 1177a353 bdca7aab 20e16624 dfe90adc 70accadc 68016732
|
|
||||||
302c20a7 31b25f49 ffff001d 6a901440
|
|
||||||
03
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff04ad1b e7d5ffff ffff0100 f2052a01 00000043 4104ed83
|
|
||||||
704c95d8 29046f1a c2780621 1132102c 34e9ac7f fa1b7111 0658e5b9 d1bdedc4
|
|
||||||
16f5cefc 1db0625c d0c75de8 192d2b59 2d7e3b00 bcfb4a0e 860d880f d1fcac00
|
|
||||||
000000
|
|
||||||
|
|
||||||
01000000 01f287b5 e067e1cf 80f7da8a f89917b5 505094db d82412d9 35b665eb
|
|
||||||
bad253d3 77010000 008c4930 46022100 96ee0d02 b35fd61e 4960b44f f396f67e
|
|
||||||
01fe17f9 de4e0c17 b6a963bd ab2b50a6 02210034 920d4daa 7e9f8abe 5675c931
|
|
||||||
495809f9 0b9c1189 d05fbaf1 dd6696a5 b0d8f301 41046868 0737c76d abb801cb
|
|
||||||
2204f57d be4e4579 e4f710cd 67dc1b42 27592c81 e9b5cf02 b5ac9e8b 4c9f49be
|
|
||||||
5251056b 6a6d011e 4c37f6b6 d17ede6b 55faa235 19e2ffff ffff0100 286bee00
|
|
||||||
00000019 76a914c5 22664fb0 e55cdc5c 0cea73b4 aad97ec8 34323288 ac000000
|
|
||||||
00
|
|
||||||
|
|
||||||
01000000 01f287b5 e067e1cf 80f7da8a f89917b5 505094db d82412d9 35b665eb
|
|
||||||
bad253d3 77000000 008c4930 46022100 9cc67ddd aa6f592a 6b2babd4 d6ff954f
|
|
||||||
25a784cf 4fe4bb13 afb9f49b 08955119 022100a2 d99545b7 94080757 fcf2b563
|
|
||||||
f2e91287 86332f46 0ec6b90f f085fb28 41a69701 4104b95c 249d84f4 17e3e395
|
|
||||||
a1274254 28b54067 1cc15881 eb828c17 b722a53f c599e21c a5e56c90 f340988d
|
|
||||||
3933acc7 6beb832f d64cab07 8ddf3ce7 32923031 d1a8ffff ffff0100 ca9a3b00
|
|
||||||
00000019 76a914ee 26c56fc1 d942be8d 7a24b2a1 001dd894 69398088 ac000000
|
|
||||||
00
|
|
||||||
|
|
||||||
File path: reorgTest/blk_4A.dat
|
|
||||||
Block 4A:
|
|
||||||
f9beb4d9
|
|
||||||
d4000000
|
|
||||||
|
|
||||||
01000000 aae77468 2205667d 4f413a58 47cc8fe8 9795f1d5 645d5b24 1daf3c92
|
|
||||||
00000000 361c9cde a09637a0 d0c05c3b 4e7a5d91 9edb184a 0a4c7633 d92e2ddd
|
|
||||||
f04cb854 89b45f49 ffff001d 9e9aa1e8
|
|
||||||
01
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff0401b8 f3eaffff ffff0100 f2052a01 00000043 4104678a
|
|
||||||
fdb0fe55 48271967 f1a67130 b7105cd6 a828e039 09a67962 e0ea1f61 deb649f6
|
|
||||||
bc3f4cef 38c4f355 04e51ec1 12de5c38 4df7ba0b 8d578a4c 702b6bf1 1d5fac00
|
|
||||||
000000
|
|
||||||
|
|
||||||
File path: reorgTest/blk_5A.dat
|
|
||||||
Block 5A:
|
|
||||||
f9beb4d9
|
|
||||||
73010000
|
|
||||||
|
|
||||||
01000000 ebc7d0de 9c31a71b 7f41d275 2c080ba4 11e1854b d45cb2cf 8c1e4624
|
|
||||||
00000000 a607774b 79b8eb50 b52a5a32 c1754281 ec67f626 9561df28 57d1fe6a
|
|
||||||
ea82c696 e1b65f49 ffff001d 4a263577
|
|
||||||
02
|
|
||||||
|
|
||||||
01000000 01000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
||||||
00000000 00ffffff ff049971 0c7dffff ffff0100 f2052a01 00000043 4104678a
|
|
||||||
fdb0fe55 48271967 f1a67130 b7105cd6 a828e039 09a67962 e0ea1f61 deb649f6
|
|
||||||
bc3f4cef 38c4f355 04e51ec1 12de5c38 4df7ba0b 8d578a4c 702b6bf1 1d5fac00
|
|
||||||
000000
|
|
||||||
|
|
||||||
01000000 0163451d 1002611c 1388d5ba 4ddfdf99 196a86b5 990fb5b0 dc786207
|
|
||||||
4fdcb8ee d2000000 004a4930 46022100 8c8fd57b 48762135 8d8f3e69 19f33e08
|
|
||||||
804736ff 83db47aa 248512e2 6df9b8ba 022100b0 c59e5ee7 bfcbfcd1 a4d83da9
|
|
||||||
55fb260e fda7f42a 25522625 a3d6f2d9 1174a701 ffffffff 0100f205 2a010000
|
|
||||||
001976a9 14c52266 4fb0e55c dc5c0cea 73b4aad9 7ec83432 3288ac00 000000
|
|
||||||
|
|
|
@ -64,96 +64,11 @@ func TestSequenceLocksActive(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestCheckConnectBlockTemplate tests the CheckConnectBlockTemplate function to
|
|
||||||
// ensure it fails.
|
|
||||||
func TestCheckConnectBlockTemplate(t *testing.T) {
|
|
||||||
// Create a new database and chain instance to run tests against.
|
|
||||||
chain, teardownFunc, err := chainSetup("checkconnectblocktemplate",
|
|
||||||
&chaincfg.MainNetParams)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Failed to setup chain instance: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer teardownFunc()
|
|
||||||
|
|
||||||
// Since we're not dealing with the real block chain, set the coinbase
|
|
||||||
// maturity to 1.
|
|
||||||
chain.TstSetCoinbaseMaturity(1)
|
|
||||||
|
|
||||||
// Load up blocks such that there is a side chain.
|
|
||||||
// (genesis block) -> 1 -> 2 -> 3 -> 4
|
|
||||||
// \-> 3a
|
|
||||||
testFiles := []string{
|
|
||||||
"blk_0_to_4.dat.bz2",
|
|
||||||
"blk_3A.dat.bz2",
|
|
||||||
}
|
|
||||||
|
|
||||||
var blocks []*btcutil.Block
|
|
||||||
for _, file := range testFiles {
|
|
||||||
blockTmp, err := loadBlocks(file)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Error loading file: %v\n", err)
|
|
||||||
}
|
|
||||||
blocks = append(blocks, blockTmp...)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 1; i <= 3; i++ {
|
|
||||||
isMainChain, _, err := chain.ProcessBlock(blocks[i], BFNone)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CheckConnectBlockTemplate: Received unexpected error "+
|
|
||||||
"processing block %d: %v", i, err)
|
|
||||||
}
|
|
||||||
if !isMainChain {
|
|
||||||
t.Fatalf("CheckConnectBlockTemplate: Expected block %d to connect "+
|
|
||||||
"to main chain", i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Block 3 should fail to connect since it's already inserted.
|
|
||||||
err = chain.CheckConnectBlockTemplate(blocks[3])
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal("CheckConnectBlockTemplate: Did not received expected error " +
|
|
||||||
"on block 3")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Block 4 should connect successfully to tip of chain.
|
|
||||||
err = chain.CheckConnectBlockTemplate(blocks[4])
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CheckConnectBlockTemplate: Received unexpected error on "+
|
|
||||||
"block 4: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Block 3a should fail to connect since does not build on chain tip.
|
|
||||||
err = chain.CheckConnectBlockTemplate(blocks[5])
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal("CheckConnectBlockTemplate: Did not received expected error " +
|
|
||||||
"on block 3a")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Block 4 should connect even if proof of work is invalid.
|
|
||||||
invalidPowBlock := *blocks[4].MsgBlock()
|
|
||||||
invalidPowBlock.Header.Nonce++
|
|
||||||
err = chain.CheckConnectBlockTemplate(btcutil.NewBlock(&invalidPowBlock))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CheckConnectBlockTemplate: Received unexpected error on "+
|
|
||||||
"block 4 with bad nonce: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invalid block building on chain tip should fail to connect.
|
|
||||||
invalidBlock := *blocks[4].MsgBlock()
|
|
||||||
invalidBlock.Header.Bits--
|
|
||||||
err = chain.CheckConnectBlockTemplate(btcutil.NewBlock(&invalidBlock))
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal("CheckConnectBlockTemplate: Did not received expected error " +
|
|
||||||
"on block 4 with invalid difficulty bits")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestCheckBlockSanity tests the CheckBlockSanity function to ensure it works
|
// TestCheckBlockSanity tests the CheckBlockSanity function to ensure it works
|
||||||
// as expected.
|
// as expected.
|
||||||
func TestCheckBlockSanity(t *testing.T) {
|
func TestCheckBlockSanity(t *testing.T) {
|
||||||
powLimit := chaincfg.MainNetParams.PowLimit
|
powLimit := chaincfg.MainNetParams.PowLimit
|
||||||
block := btcutil.NewBlock(&Block100000)
|
block := GetBlock100000()
|
||||||
timeSource := NewMedianTime()
|
timeSource := NewMedianTime()
|
||||||
err := CheckBlockSanity(block, powLimit, timeSource)
|
err := CheckBlockSanity(block, powLimit, timeSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -235,254 +150,12 @@ func TestCheckSerializedHeight(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block100000 defines block 100,000 of the block chain. It is used to
|
var block100000Hex = "0000002024cbdc8644ee3983e66b003a0733891c069ca74c114c034c7b3e2e7ad7a12cd67e95e0555c0e056f6f2af538268ff9d21b420e529750d08eacb25c40f1322936637109b8a051157604c1c163cd39237687f6244b4e6d2b3a94e9d816babaecbb10c56058c811041b2b9c43000701000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2003a086010410c56058081011314abf0100000d2f6e6f64655374726174756d2f000000000180354a6e0a0000001976a914b5e74e7cc9e1f480a6599895c92aab1401f870f188ac000000000100000002f1b75decc2c1c59c2178852822de412f574ad9796b65ac9092a79630d8109aaf000000006a47304402202f78ed3bf8dcadb6c17e289cd06e9c96b02c6f23aa1f446a4a7896a31cfd1e4702202862261e2eb59475ac91092c620b3cac5a831372bafc446d5ee450866040b532012103db4f3785354d84311fab7624c52784a61e3046d8f364463d327bdd96281b5b90feffffff987ee6b4bf95548d01e443683261dd0ffdcb2eb335b2f7119df0d41b60756b92010000006a47304402200c422c7560b6418d45443138bb957ec44eb293a639f4b2235a622205ca6cac370220759f15d5dc2543fd1aef80104c93427fcb025847bf895669025d1d82c62fbf6801210201864b998db5436990a0029fc3fb153c09e8c2689214b91c8ed68784995c8da0feffffff022bccfedd000000001976a914738f16132942a01d00cb9699bd058c4925aada3288ac1f4d030c000000001976a914c4292e757f5ff6a27c2f0a87d3a4aea5e46c275a88ac9f86010001000000015fbb26ad6d818186032baeef4d3f475dfe165c6da2d93411b8ec5f9f523cf1a4000000006a4730440220356999ad5a9f6f09b676f17dd4a2617a0af234722d68a50edc3768c983c0623d022056b4e5531608aeb0205fde9c44f741158da3bba1f4c3788c9fe79d36d43ea355012103509893a2a7c765d49ac9ff70126cb1af54871d70baba2c7e39ec9b4096289a9bfeffffff02389332fa080000001976a914f85e054405fbcedc2341cf8bf41ea989090587a288acf9321a41000000001976a914e85e90c048fdfbe1c2117a7132856ff4b39b470188ac9f86010001000000013508189b9bb61ac2aa536b905447b58f6c58c17cdef305240f566caa689d760a010000006a4730440220669a2b86e5abe58bae54829d3c271669540a9ad965c2fb79e8cc1fb609c0b60002202f958403d979138075cb53d8cb5ff6bb14e18d66dfdb6701c7d43a8ceeed0fa80121029935a602205a3fb72446064f3bc3a55ab9cd2e3459bf2ffdf80a48ab029d4b42feffffff02523c2f13000000001976a914c5b2ae398496f0f9ceaf81b83c28a27ddc890e3588ac211958f2000000001976a914ac65f1d16e5a2af37408b5d65406000a7ea143ca88ac9f8601000100000001bdd724322c555a21d5eb62d4aadbdc051663bcd4ec03f8d9005992f299783c21000000006a47304402205448141a2a788f73310025123bd24f5bee01dd8f48f18d7abc62d7c26465008902207ab46e6ddf6ba416decf3fbb97b6946a1428ea0a7c25a55cab47c47110d8e9ce0121029d6ff3b1235f2a08560b23dd4a08b14cc415b544801b885365736ea8ab1d3470feffffff029d104ccf000000001976a914999d5b0e3d5efcf601c711127b91841afbf5c37a88ace5c5a07f070000001976a9144aade372298eb387da9b6ac69d215a213e822f3f88ac9f86010001000000011658304d4ce796cd450228a10fdf647c6ea42295c9f5e1663df11481af1c884d010000006b483045022100a35d5d3ccde85b41559047d976ae6210b8e6ba5653c53aae1adc90048de0761002200d6bd6ebc6d73f97855f435c6fd595009ee71d23bb34870ab83ad53f67eeb22b012102d2f681ebfd1a570416d602986a47ca4254d8dedf2935b3f8c2ba55dcee8e98f4feffffff025ee913e6020000001976a91468076c9380d3c6b468ad1d6109c36770fb181e8f88acb165394f000000001976a9147ae970e81b3657cbb59df26517e372165807be0088ac9f86010001000000018f285109f78524a88ff328a4f94de2ac03224c50984b11c68adda192e8f78efa010000006b483045022100d77f2ac32dd6a3015f02f7115a13f617c57952fc5d53a33a87dc3fc00ffe1864022006455f74cff864b10424e445c530a59243f86d309dc92c5010ec5709e38471ab012102fdac7335b41edcd2846fc7e2166bb48312ee583ed6ff70fb5c27bcb2addaad86feffffff028b7a6d5c000000001976a914c65106d2e7ea4ec6aa8aa30ba4d11cfd1143123388ac5934c228000000001976a914d1c4d190b07edb972b91f33c36c6568b80358dd488ac9f860100"
|
||||||
|
|
||||||
|
// GetBlock100000 defines block 100,000 of the block chain. It is used to
|
||||||
// test Block operations.
|
// test Block operations.
|
||||||
var Block100000 = wire.MsgBlock{
|
func GetBlock100000() *btcutil.Block {
|
||||||
Header: wire.BlockHeader{
|
var block100000Bytes, _ = hex.DecodeString(block100000Hex)
|
||||||
Version: 1,
|
var results, _ = btcutil.NewBlockFromBytes(block100000Bytes)
|
||||||
PrevBlock: chainhash.Hash([32]byte{ // Make go vet happy.
|
return results
|
||||||
0x50, 0x12, 0x01, 0x19, 0x17, 0x2a, 0x61, 0x04,
|
|
||||||
0x21, 0xa6, 0xc3, 0x01, 0x1d, 0xd3, 0x30, 0xd9,
|
|
||||||
0xdf, 0x07, 0xb6, 0x36, 0x16, 0xc2, 0xcc, 0x1f,
|
|
||||||
0x1c, 0xd0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
}), // 000000000002d01c1fccc21636b607dfd930d31d01c3a62104612a1719011250
|
|
||||||
MerkleRoot: chainhash.Hash([32]byte{ // Make go vet happy.
|
|
||||||
0x66, 0x57, 0xa9, 0x25, 0x2a, 0xac, 0xd5, 0xc0,
|
|
||||||
0xb2, 0x94, 0x09, 0x96, 0xec, 0xff, 0x95, 0x22,
|
|
||||||
0x28, 0xc3, 0x06, 0x7c, 0xc3, 0x8d, 0x48, 0x85,
|
|
||||||
0xef, 0xb5, 0xa4, 0xac, 0x42, 0x47, 0xe9, 0xf3,
|
|
||||||
}), // f3e94742aca4b5ef85488dc37c06c3282295ffec960994b2c0d5ac2a25a95766
|
|
||||||
Timestamp: time.Unix(1293623863, 0), // 2010-12-29 11:57:43 +0000 UTC
|
|
||||||
Bits: 0x1b04864c, // 453281356
|
|
||||||
Nonce: 0x10572b0f, // 274148111
|
|
||||||
},
|
|
||||||
Transactions: []*wire.MsgTx{
|
|
||||||
{
|
|
||||||
Version: 1,
|
|
||||||
TxIn: []*wire.TxIn{
|
|
||||||
{
|
|
||||||
PreviousOutPoint: wire.OutPoint{
|
|
||||||
Hash: chainhash.Hash{},
|
|
||||||
Index: 0xffffffff,
|
|
||||||
},
|
|
||||||
SignatureScript: []byte{
|
|
||||||
0x04, 0x4c, 0x86, 0x04, 0x1b, 0x02, 0x06, 0x02,
|
|
||||||
},
|
|
||||||
Sequence: 0xffffffff,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TxOut: []*wire.TxOut{
|
|
||||||
{
|
|
||||||
Value: 0x12a05f200, // 5000000000
|
|
||||||
PkScript: []byte{
|
|
||||||
0x41, // OP_DATA_65
|
|
||||||
0x04, 0x1b, 0x0e, 0x8c, 0x25, 0x67, 0xc1, 0x25,
|
|
||||||
0x36, 0xaa, 0x13, 0x35, 0x7b, 0x79, 0xa0, 0x73,
|
|
||||||
0xdc, 0x44, 0x44, 0xac, 0xb8, 0x3c, 0x4e, 0xc7,
|
|
||||||
0xa0, 0xe2, 0xf9, 0x9d, 0xd7, 0x45, 0x75, 0x16,
|
|
||||||
0xc5, 0x81, 0x72, 0x42, 0xda, 0x79, 0x69, 0x24,
|
|
||||||
0xca, 0x4e, 0x99, 0x94, 0x7d, 0x08, 0x7f, 0xed,
|
|
||||||
0xf9, 0xce, 0x46, 0x7c, 0xb9, 0xf7, 0xc6, 0x28,
|
|
||||||
0x70, 0x78, 0xf8, 0x01, 0xdf, 0x27, 0x6f, 0xdf,
|
|
||||||
0x84, // 65-byte signature
|
|
||||||
0xac, // OP_CHECKSIG
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
LockTime: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Version: 1,
|
|
||||||
TxIn: []*wire.TxIn{
|
|
||||||
{
|
|
||||||
PreviousOutPoint: wire.OutPoint{
|
|
||||||
Hash: chainhash.Hash([32]byte{ // Make go vet happy.
|
|
||||||
0x03, 0x2e, 0x38, 0xe9, 0xc0, 0xa8, 0x4c, 0x60,
|
|
||||||
0x46, 0xd6, 0x87, 0xd1, 0x05, 0x56, 0xdc, 0xac,
|
|
||||||
0xc4, 0x1d, 0x27, 0x5e, 0xc5, 0x5f, 0xc0, 0x07,
|
|
||||||
0x79, 0xac, 0x88, 0xfd, 0xf3, 0x57, 0xa1, 0x87,
|
|
||||||
}), // 87a157f3fd88ac7907c05fc55e271dc4acdc5605d187d646604ca8c0e9382e03
|
|
||||||
Index: 0,
|
|
||||||
},
|
|
||||||
SignatureScript: []byte{
|
|
||||||
0x49, // OP_DATA_73
|
|
||||||
0x30, 0x46, 0x02, 0x21, 0x00, 0xc3, 0x52, 0xd3,
|
|
||||||
0xdd, 0x99, 0x3a, 0x98, 0x1b, 0xeb, 0xa4, 0xa6,
|
|
||||||
0x3a, 0xd1, 0x5c, 0x20, 0x92, 0x75, 0xca, 0x94,
|
|
||||||
0x70, 0xab, 0xfc, 0xd5, 0x7d, 0xa9, 0x3b, 0x58,
|
|
||||||
0xe4, 0xeb, 0x5d, 0xce, 0x82, 0x02, 0x21, 0x00,
|
|
||||||
0x84, 0x07, 0x92, 0xbc, 0x1f, 0x45, 0x60, 0x62,
|
|
||||||
0x81, 0x9f, 0x15, 0xd3, 0x3e, 0xe7, 0x05, 0x5c,
|
|
||||||
0xf7, 0xb5, 0xee, 0x1a, 0xf1, 0xeb, 0xcc, 0x60,
|
|
||||||
0x28, 0xd9, 0xcd, 0xb1, 0xc3, 0xaf, 0x77, 0x48,
|
|
||||||
0x01, // 73-byte signature
|
|
||||||
0x41, // OP_DATA_65
|
|
||||||
0x04, 0xf4, 0x6d, 0xb5, 0xe9, 0xd6, 0x1a, 0x9d,
|
|
||||||
0xc2, 0x7b, 0x8d, 0x64, 0xad, 0x23, 0xe7, 0x38,
|
|
||||||
0x3a, 0x4e, 0x6c, 0xa1, 0x64, 0x59, 0x3c, 0x25,
|
|
||||||
0x27, 0xc0, 0x38, 0xc0, 0x85, 0x7e, 0xb6, 0x7e,
|
|
||||||
0xe8, 0xe8, 0x25, 0xdc, 0xa6, 0x50, 0x46, 0xb8,
|
|
||||||
0x2c, 0x93, 0x31, 0x58, 0x6c, 0x82, 0xe0, 0xfd,
|
|
||||||
0x1f, 0x63, 0x3f, 0x25, 0xf8, 0x7c, 0x16, 0x1b,
|
|
||||||
0xc6, 0xf8, 0xa6, 0x30, 0x12, 0x1d, 0xf2, 0xb3,
|
|
||||||
0xd3, // 65-byte pubkey
|
|
||||||
},
|
|
||||||
Sequence: 0xffffffff,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TxOut: []*wire.TxOut{
|
|
||||||
{
|
|
||||||
Value: 0x2123e300, // 556000000
|
|
||||||
PkScript: []byte{
|
|
||||||
0x76, // OP_DUP
|
|
||||||
0xa9, // OP_HASH160
|
|
||||||
0x14, // OP_DATA_20
|
|
||||||
0xc3, 0x98, 0xef, 0xa9, 0xc3, 0x92, 0xba, 0x60,
|
|
||||||
0x13, 0xc5, 0xe0, 0x4e, 0xe7, 0x29, 0x75, 0x5e,
|
|
||||||
0xf7, 0xf5, 0x8b, 0x32,
|
|
||||||
0x88, // OP_EQUALVERIFY
|
|
||||||
0xac, // OP_CHECKSIG
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Value: 0x108e20f00, // 4444000000
|
|
||||||
PkScript: []byte{
|
|
||||||
0x76, // OP_DUP
|
|
||||||
0xa9, // OP_HASH160
|
|
||||||
0x14, // OP_DATA_20
|
|
||||||
0x94, 0x8c, 0x76, 0x5a, 0x69, 0x14, 0xd4, 0x3f,
|
|
||||||
0x2a, 0x7a, 0xc1, 0x77, 0xda, 0x2c, 0x2f, 0x6b,
|
|
||||||
0x52, 0xde, 0x3d, 0x7c,
|
|
||||||
0x88, // OP_EQUALVERIFY
|
|
||||||
0xac, // OP_CHECKSIG
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
LockTime: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Version: 1,
|
|
||||||
TxIn: []*wire.TxIn{
|
|
||||||
{
|
|
||||||
PreviousOutPoint: wire.OutPoint{
|
|
||||||
Hash: chainhash.Hash([32]byte{ // Make go vet happy.
|
|
||||||
0xc3, 0x3e, 0xbf, 0xf2, 0xa7, 0x09, 0xf1, 0x3d,
|
|
||||||
0x9f, 0x9a, 0x75, 0x69, 0xab, 0x16, 0xa3, 0x27,
|
|
||||||
0x86, 0xaf, 0x7d, 0x7e, 0x2d, 0xe0, 0x92, 0x65,
|
|
||||||
0xe4, 0x1c, 0x61, 0xd0, 0x78, 0x29, 0x4e, 0xcf,
|
|
||||||
}), // cf4e2978d0611ce46592e02d7e7daf8627a316ab69759a9f3df109a7f2bf3ec3
|
|
||||||
Index: 1,
|
|
||||||
},
|
|
||||||
SignatureScript: []byte{
|
|
||||||
0x47, // OP_DATA_71
|
|
||||||
0x30, 0x44, 0x02, 0x20, 0x03, 0x2d, 0x30, 0xdf,
|
|
||||||
0x5e, 0xe6, 0xf5, 0x7f, 0xa4, 0x6c, 0xdd, 0xb5,
|
|
||||||
0xeb, 0x8d, 0x0d, 0x9f, 0xe8, 0xde, 0x6b, 0x34,
|
|
||||||
0x2d, 0x27, 0x94, 0x2a, 0xe9, 0x0a, 0x32, 0x31,
|
|
||||||
0xe0, 0xba, 0x33, 0x3e, 0x02, 0x20, 0x3d, 0xee,
|
|
||||||
0xe8, 0x06, 0x0f, 0xdc, 0x70, 0x23, 0x0a, 0x7f,
|
|
||||||
0x5b, 0x4a, 0xd7, 0xd7, 0xbc, 0x3e, 0x62, 0x8c,
|
|
||||||
0xbe, 0x21, 0x9a, 0x88, 0x6b, 0x84, 0x26, 0x9e,
|
|
||||||
0xae, 0xb8, 0x1e, 0x26, 0xb4, 0xfe, 0x01,
|
|
||||||
0x41, // OP_DATA_65
|
|
||||||
0x04, 0xae, 0x31, 0xc3, 0x1b, 0xf9, 0x12, 0x78,
|
|
||||||
0xd9, 0x9b, 0x83, 0x77, 0xa3, 0x5b, 0xbc, 0xe5,
|
|
||||||
0xb2, 0x7d, 0x9f, 0xff, 0x15, 0x45, 0x68, 0x39,
|
|
||||||
0xe9, 0x19, 0x45, 0x3f, 0xc7, 0xb3, 0xf7, 0x21,
|
|
||||||
0xf0, 0xba, 0x40, 0x3f, 0xf9, 0x6c, 0x9d, 0xee,
|
|
||||||
0xb6, 0x80, 0xe5, 0xfd, 0x34, 0x1c, 0x0f, 0xc3,
|
|
||||||
0xa7, 0xb9, 0x0d, 0xa4, 0x63, 0x1e, 0xe3, 0x95,
|
|
||||||
0x60, 0x63, 0x9d, 0xb4, 0x62, 0xe9, 0xcb, 0x85,
|
|
||||||
0x0f, // 65-byte pubkey
|
|
||||||
},
|
|
||||||
Sequence: 0xffffffff,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TxOut: []*wire.TxOut{
|
|
||||||
{
|
|
||||||
Value: 0xf4240, // 1000000
|
|
||||||
PkScript: []byte{
|
|
||||||
0x76, // OP_DUP
|
|
||||||
0xa9, // OP_HASH160
|
|
||||||
0x14, // OP_DATA_20
|
|
||||||
0xb0, 0xdc, 0xbf, 0x97, 0xea, 0xbf, 0x44, 0x04,
|
|
||||||
0xe3, 0x1d, 0x95, 0x24, 0x77, 0xce, 0x82, 0x2d,
|
|
||||||
0xad, 0xbe, 0x7e, 0x10,
|
|
||||||
0x88, // OP_EQUALVERIFY
|
|
||||||
0xac, // OP_CHECKSIG
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Value: 0x11d260c0, // 299000000
|
|
||||||
PkScript: []byte{
|
|
||||||
0x76, // OP_DUP
|
|
||||||
0xa9, // OP_HASH160
|
|
||||||
0x14, // OP_DATA_20
|
|
||||||
0x6b, 0x12, 0x81, 0xee, 0xc2, 0x5a, 0xb4, 0xe1,
|
|
||||||
0xe0, 0x79, 0x3f, 0xf4, 0xe0, 0x8a, 0xb1, 0xab,
|
|
||||||
0xb3, 0x40, 0x9c, 0xd9,
|
|
||||||
0x88, // OP_EQUALVERIFY
|
|
||||||
0xac, // OP_CHECKSIG
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
LockTime: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Version: 1,
|
|
||||||
TxIn: []*wire.TxIn{
|
|
||||||
{
|
|
||||||
PreviousOutPoint: wire.OutPoint{
|
|
||||||
Hash: chainhash.Hash([32]byte{ // Make go vet happy.
|
|
||||||
0x0b, 0x60, 0x72, 0xb3, 0x86, 0xd4, 0xa7, 0x73,
|
|
||||||
0x23, 0x52, 0x37, 0xf6, 0x4c, 0x11, 0x26, 0xac,
|
|
||||||
0x3b, 0x24, 0x0c, 0x84, 0xb9, 0x17, 0xa3, 0x90,
|
|
||||||
0x9b, 0xa1, 0xc4, 0x3d, 0xed, 0x5f, 0x51, 0xf4,
|
|
||||||
}), // f4515fed3dc4a19b90a317b9840c243bac26114cf637522373a7d486b372600b
|
|
||||||
Index: 0,
|
|
||||||
},
|
|
||||||
SignatureScript: []byte{
|
|
||||||
0x49, // OP_DATA_73
|
|
||||||
0x30, 0x46, 0x02, 0x21, 0x00, 0xbb, 0x1a, 0xd2,
|
|
||||||
0x6d, 0xf9, 0x30, 0xa5, 0x1c, 0xce, 0x11, 0x0c,
|
|
||||||
0xf4, 0x4f, 0x7a, 0x48, 0xc3, 0xc5, 0x61, 0xfd,
|
|
||||||
0x97, 0x75, 0x00, 0xb1, 0xae, 0x5d, 0x6b, 0x6f,
|
|
||||||
0xd1, 0x3d, 0x0b, 0x3f, 0x4a, 0x02, 0x21, 0x00,
|
|
||||||
0xc5, 0xb4, 0x29, 0x51, 0xac, 0xed, 0xff, 0x14,
|
|
||||||
0xab, 0xba, 0x27, 0x36, 0xfd, 0x57, 0x4b, 0xdb,
|
|
||||||
0x46, 0x5f, 0x3e, 0x6f, 0x8d, 0xa1, 0x2e, 0x2c,
|
|
||||||
0x53, 0x03, 0x95, 0x4a, 0xca, 0x7f, 0x78, 0xf3,
|
|
||||||
0x01, // 73-byte signature
|
|
||||||
0x41, // OP_DATA_65
|
|
||||||
0x04, 0xa7, 0x13, 0x5b, 0xfe, 0x82, 0x4c, 0x97,
|
|
||||||
0xec, 0xc0, 0x1e, 0xc7, 0xd7, 0xe3, 0x36, 0x18,
|
|
||||||
0x5c, 0x81, 0xe2, 0xaa, 0x2c, 0x41, 0xab, 0x17,
|
|
||||||
0x54, 0x07, 0xc0, 0x94, 0x84, 0xce, 0x96, 0x94,
|
|
||||||
0xb4, 0x49, 0x53, 0xfc, 0xb7, 0x51, 0x20, 0x65,
|
|
||||||
0x64, 0xa9, 0xc2, 0x4d, 0xd0, 0x94, 0xd4, 0x2f,
|
|
||||||
0xdb, 0xfd, 0xd5, 0xaa, 0xd3, 0xe0, 0x63, 0xce,
|
|
||||||
0x6a, 0xf4, 0xcf, 0xaa, 0xea, 0x4e, 0xa1, 0x4f,
|
|
||||||
0xbb, // 65-byte pubkey
|
|
||||||
},
|
|
||||||
Sequence: 0xffffffff,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TxOut: []*wire.TxOut{
|
|
||||||
{
|
|
||||||
Value: 0xf4240, // 1000000
|
|
||||||
PkScript: []byte{
|
|
||||||
0x76, // OP_DUP
|
|
||||||
0xa9, // OP_HASH160
|
|
||||||
0x14, // OP_DATA_20
|
|
||||||
0x39, 0xaa, 0x3d, 0x56, 0x9e, 0x06, 0xa1, 0xd7,
|
|
||||||
0x92, 0x6d, 0xc4, 0xbe, 0x11, 0x93, 0xc9, 0x9b,
|
|
||||||
0xf2, 0xeb, 0x9e, 0xe0,
|
|
||||||
0x88, // OP_EQUALVERIFY
|
|
||||||
0xac, // OP_CHECKSIG
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
LockTime: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ func TestChainSvrCmds(t *testing.T) {
|
||||||
return btcjson.NewGetBlockFilterCmd("0000afaf", nil)
|
return btcjson.NewGetBlockFilterCmd("0000afaf", nil)
|
||||||
},
|
},
|
||||||
marshalled: `{"jsonrpc":"1.0","method":"getblockfilter","params":["0000afaf"],"id":1}`,
|
marshalled: `{"jsonrpc":"1.0","method":"getblockfilter","params":["0000afaf"],"id":1}`,
|
||||||
unmarshalled: &btcjson.GetBlockFilterCmd{"0000afaf", nil},
|
unmarshalled: &btcjson.GetBlockFilterCmd{BlockHash: "0000afaf", FilterType: nil},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "getblockfilter optional filtertype",
|
name: "getblockfilter optional filtertype",
|
||||||
|
@ -399,7 +399,7 @@ func TestChainSvrCmds(t *testing.T) {
|
||||||
return btcjson.NewGetBlockFilterCmd("0000afaf", btcjson.NewFilterTypeName(btcjson.FilterTypeBasic))
|
return btcjson.NewGetBlockFilterCmd("0000afaf", btcjson.NewFilterTypeName(btcjson.FilterTypeBasic))
|
||||||
},
|
},
|
||||||
marshalled: `{"jsonrpc":"1.0","method":"getblockfilter","params":["0000afaf","basic"],"id":1}`,
|
marshalled: `{"jsonrpc":"1.0","method":"getblockfilter","params":["0000afaf","basic"],"id":1}`,
|
||||||
unmarshalled: &btcjson.GetBlockFilterCmd{"0000afaf", btcjson.NewFilterTypeName(btcjson.FilterTypeBasic)},
|
unmarshalled: &btcjson.GetBlockFilterCmd{BlockHash: "0000afaf", FilterType: btcjson.NewFilterTypeName(btcjson.FilterTypeBasic)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "getblockhash",
|
name: "getblockhash",
|
||||||
|
|
|
@ -86,15 +86,6 @@ var genesisBlock = wire.MsgBlock{
|
||||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||||
}
|
}
|
||||||
|
|
||||||
// regTestGenesisHash is the hash of the first block in the block chain for the
|
|
||||||
// regression test network (genesis block).
|
|
||||||
var regTestGenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy.
|
|
||||||
0x56, 0x75, 0x68, 0x69, 0x76, 0x67, 0x4f, 0x50,
|
|
||||||
0xa0, 0xa1, 0x95, 0x3d, 0x17, 0x2e, 0x9e, 0xcf,
|
|
||||||
0x4a, 0x4a, 0x62, 0x1d, 0xc9, 0xa4, 0xc3, 0x79,
|
|
||||||
0x5d, 0xec, 0xd4, 0x99, 0x12, 0xcf, 0x3f, 0x6e,
|
|
||||||
})
|
|
||||||
|
|
||||||
// regTestGenesisMerkleRoot is the hash of the first transaction in the genesis
|
// regTestGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||||
// block for the regression test network. It is the same as the merkle root for
|
// block for the regression test network. It is the same as the merkle root for
|
||||||
// the main network.
|
// the main network.
|
||||||
|
@ -115,14 +106,9 @@ var regTestGenesisBlock = wire.MsgBlock{
|
||||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||||
}
|
}
|
||||||
|
|
||||||
// testNet3GenesisHash is the hash of the first block in the block chain for the
|
// regTestGenesisHash is the hash of the first block in the block chain for the
|
||||||
// test network (version 3).
|
// regression test network (genesis block).
|
||||||
var testNet3GenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy.
|
var regTestGenesisHash = regTestGenesisBlock.BlockHash()
|
||||||
0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95, 0x71,
|
|
||||||
0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce, 0xc3, 0xae,
|
|
||||||
0xba, 0x79, 0x97, 0x20, 0x84, 0xe9, 0x0e, 0xad,
|
|
||||||
0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
})
|
|
||||||
|
|
||||||
// testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis
|
// testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||||
// block for the test network (version 3). It is the same as the merkle root
|
// block for the test network (version 3). It is the same as the merkle root
|
||||||
|
@ -144,14 +130,9 @@ var testNet3GenesisBlock = wire.MsgBlock{
|
||||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||||
}
|
}
|
||||||
|
|
||||||
// simNetGenesisHash is the hash of the first block in the block chain for the
|
// testNet3GenesisHash is the hash of the first block in the block chain for the
|
||||||
// simulation test network.
|
// test network (version 3).
|
||||||
var simNetGenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy.
|
var testNet3GenesisHash = testNet3GenesisBlock.BlockHash()
|
||||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a,
|
|
||||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
|
||||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
|
||||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
|
||||||
})
|
|
||||||
|
|
||||||
// simNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
// simNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||||
// block for the simulation test network. It is the same as the merkle root for
|
// block for the simulation test network. It is the same as the merkle root for
|
||||||
|
@ -172,14 +153,9 @@ var simNetGenesisBlock = wire.MsgBlock{
|
||||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||||
}
|
}
|
||||||
|
|
||||||
// sigNetGenesisHash is the hash of the first block in the block chain for the
|
// simNetGenesisHash is the hash of the first block in the block chain for the
|
||||||
// signet test network.
|
// simulation test network.
|
||||||
var sigNetGenesisHash = chainhash.Hash{
|
var simNetGenesisHash = simNetGenesisBlock.BlockHash()
|
||||||
0xf6, 0x1e, 0xee, 0x3b, 0x63, 0xa3, 0x80, 0xa4,
|
|
||||||
0x77, 0xa0, 0x63, 0xaf, 0x32, 0xb2, 0xbb, 0xc9,
|
|
||||||
0x7c, 0x9f, 0xf9, 0xf0, 0x1f, 0x2c, 0x42, 0x25,
|
|
||||||
0xe9, 0x73, 0x98, 0x81, 0x08, 0x00, 0x00, 0x00,
|
|
||||||
}
|
|
||||||
|
|
||||||
// sigNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
// sigNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||||
// block for the signet test network. It is the same as the merkle root for
|
// block for the signet test network. It is the same as the merkle root for
|
||||||
|
@ -199,3 +175,7 @@ var sigNetGenesisBlock = wire.MsgBlock{
|
||||||
},
|
},
|
||||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sigNetGenesisHash is the hash of the first block in the block chain for the
|
||||||
|
// signet test network.
|
||||||
|
var sigNetGenesisHash = sigNetGenesisBlock.BlockHash()
|
||||||
|
|
|
@ -21,13 +21,6 @@ func TestGenesisBlock(t *testing.T) {
|
||||||
t.Fatalf("TestGenesisBlock: %v", err)
|
t.Fatalf("TestGenesisBlock: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the encoded block matches the expected bytes.
|
|
||||||
if !bytes.Equal(buf.Bytes(), genesisBlockBytes) {
|
|
||||||
t.Fatalf("TestGenesisBlock: Genesis block does not appear valid - "+
|
|
||||||
"got %v, want %v", spew.Sdump(buf.Bytes()),
|
|
||||||
spew.Sdump(genesisBlockBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check hash of the block against expected hash.
|
// Check hash of the block against expected hash.
|
||||||
hash := MainNetParams.GenesisBlock.BlockHash()
|
hash := MainNetParams.GenesisBlock.BlockHash()
|
||||||
if !MainNetParams.GenesisHash.IsEqual(&hash) {
|
if !MainNetParams.GenesisHash.IsEqual(&hash) {
|
||||||
|
@ -47,14 +40,6 @@ func TestRegTestGenesisBlock(t *testing.T) {
|
||||||
t.Fatalf("TestRegTestGenesisBlock: %v", err)
|
t.Fatalf("TestRegTestGenesisBlock: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the encoded block matches the expected bytes.
|
|
||||||
if !bytes.Equal(buf.Bytes(), regTestGenesisBlockBytes) {
|
|
||||||
t.Fatalf("TestRegTestGenesisBlock: Genesis block does not "+
|
|
||||||
"appear valid - got %v, want %v",
|
|
||||||
spew.Sdump(buf.Bytes()),
|
|
||||||
spew.Sdump(regTestGenesisBlockBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check hash of the block against expected hash.
|
// Check hash of the block against expected hash.
|
||||||
hash := RegressionNetParams.GenesisBlock.BlockHash()
|
hash := RegressionNetParams.GenesisBlock.BlockHash()
|
||||||
if !RegressionNetParams.GenesisHash.IsEqual(&hash) {
|
if !RegressionNetParams.GenesisHash.IsEqual(&hash) {
|
||||||
|
@ -74,14 +59,6 @@ func TestTestNet3GenesisBlock(t *testing.T) {
|
||||||
t.Fatalf("TestTestNet3GenesisBlock: %v", err)
|
t.Fatalf("TestTestNet3GenesisBlock: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the encoded block matches the expected bytes.
|
|
||||||
if !bytes.Equal(buf.Bytes(), testNet3GenesisBlockBytes) {
|
|
||||||
t.Fatalf("TestTestNet3GenesisBlock: Genesis block does not "+
|
|
||||||
"appear valid - got %v, want %v",
|
|
||||||
spew.Sdump(buf.Bytes()),
|
|
||||||
spew.Sdump(testNet3GenesisBlockBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check hash of the block against expected hash.
|
// Check hash of the block against expected hash.
|
||||||
hash := TestNet3Params.GenesisBlock.BlockHash()
|
hash := TestNet3Params.GenesisBlock.BlockHash()
|
||||||
if !TestNet3Params.GenesisHash.IsEqual(&hash) {
|
if !TestNet3Params.GenesisHash.IsEqual(&hash) {
|
||||||
|
@ -101,14 +78,6 @@ func TestSimNetGenesisBlock(t *testing.T) {
|
||||||
t.Fatalf("TestSimNetGenesisBlock: %v", err)
|
t.Fatalf("TestSimNetGenesisBlock: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the encoded block matches the expected bytes.
|
|
||||||
if !bytes.Equal(buf.Bytes(), simNetGenesisBlockBytes) {
|
|
||||||
t.Fatalf("TestSimNetGenesisBlock: Genesis block does not "+
|
|
||||||
"appear valid - got %v, want %v",
|
|
||||||
spew.Sdump(buf.Bytes()),
|
|
||||||
spew.Sdump(simNetGenesisBlockBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check hash of the block against expected hash.
|
// Check hash of the block against expected hash.
|
||||||
hash := SimNetParams.GenesisBlock.BlockHash()
|
hash := SimNetParams.GenesisBlock.BlockHash()
|
||||||
if !SimNetParams.GenesisHash.IsEqual(&hash) {
|
if !SimNetParams.GenesisHash.IsEqual(&hash) {
|
||||||
|
@ -128,14 +97,6 @@ func TestSigNetGenesisBlock(t *testing.T) {
|
||||||
t.Fatalf("TestSigNetGenesisBlock: %v", err)
|
t.Fatalf("TestSigNetGenesisBlock: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the encoded block matches the expected bytes.
|
|
||||||
if !bytes.Equal(buf.Bytes(), sigNetGenesisBlockBytes) {
|
|
||||||
t.Fatalf("TestSigNetGenesisBlock: Genesis block does not "+
|
|
||||||
"appear valid - got %v, want %v",
|
|
||||||
spew.Sdump(buf.Bytes()),
|
|
||||||
spew.Sdump(sigNetGenesisBlockBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check hash of the block against expected hash.
|
// Check hash of the block against expected hash.
|
||||||
hash := SigNetParams.GenesisBlock.BlockHash()
|
hash := SigNetParams.GenesisBlock.BlockHash()
|
||||||
if !SigNetParams.GenesisHash.IsEqual(&hash) {
|
if !SigNetParams.GenesisHash.IsEqual(&hash) {
|
||||||
|
@ -144,208 +105,3 @@ func TestSigNetGenesisBlock(t *testing.T) {
|
||||||
spew.Sdump(SigNetParams.GenesisHash))
|
spew.Sdump(SigNetParams.GenesisHash))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// genesisBlockBytes are the wire encoded bytes for the genesis block of the
|
|
||||||
// main network as of protocol version 60002.
|
|
||||||
var genesisBlockBytes = []byte{
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */
|
|
||||||
0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */
|
|
||||||
0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */
|
|
||||||
0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */
|
|
||||||
0x4b, 0x1e, 0x5e, 0x4a, 0x29, 0xab, 0x5f, 0x49, /* |K.^J)._I| */
|
|
||||||
0xff, 0xff, 0x00, 0x1d, 0x1d, 0xac, 0x2b, 0x7c, /* |......+|| */
|
|
||||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */
|
|
||||||
0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */
|
|
||||||
0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */
|
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */
|
|
||||||
0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */
|
|
||||||
0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */
|
|
||||||
0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */
|
|
||||||
0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */
|
|
||||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */
|
|
||||||
0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */
|
|
||||||
0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */
|
|
||||||
0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */
|
|
||||||
0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */
|
|
||||||
0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */
|
|
||||||
0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */
|
|
||||||
0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */
|
|
||||||
0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */
|
|
||||||
0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */
|
|
||||||
0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */
|
|
||||||
0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/
|
|
||||||
0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */
|
|
||||||
}
|
|
||||||
|
|
||||||
// regTestGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
|
||||||
// the regression test network as of protocol version 60002.
|
|
||||||
var regTestGenesisBlockBytes = []byte{
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */
|
|
||||||
0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */
|
|
||||||
0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */
|
|
||||||
0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */
|
|
||||||
0x4b, 0x1e, 0x5e, 0x4a, 0xda, 0xe5, 0x49, 0x4d, /* |K.^J)._I| */
|
|
||||||
0xff, 0xff, 0x7f, 0x20, 0x02, 0x00, 0x00, 0x00, /* |......+|| */
|
|
||||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */
|
|
||||||
0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */
|
|
||||||
0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */
|
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */
|
|
||||||
0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */
|
|
||||||
0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */
|
|
||||||
0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */
|
|
||||||
0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */
|
|
||||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */
|
|
||||||
0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */
|
|
||||||
0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */
|
|
||||||
0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */
|
|
||||||
0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */
|
|
||||||
0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */
|
|
||||||
0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */
|
|
||||||
0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */
|
|
||||||
0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */
|
|
||||||
0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */
|
|
||||||
0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */
|
|
||||||
0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/
|
|
||||||
0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */
|
|
||||||
}
|
|
||||||
|
|
||||||
// testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of
|
|
||||||
// the test network (version 3) as of protocol version 60002.
|
|
||||||
var testNet3GenesisBlockBytes = []byte{
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */
|
|
||||||
0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */
|
|
||||||
0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */
|
|
||||||
0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */
|
|
||||||
0x4b, 0x1e, 0x5e, 0x4a, 0xda, 0xe5, 0x49, 0x4d, /* |K.^J)._I| */
|
|
||||||
0xff, 0xff, 0x00, 0x1d, 0x1a, 0xa4, 0xae, 0x18, /* |......+|| */
|
|
||||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */
|
|
||||||
0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */
|
|
||||||
0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */
|
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */
|
|
||||||
0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */
|
|
||||||
0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */
|
|
||||||
0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */
|
|
||||||
0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */
|
|
||||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */
|
|
||||||
0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */
|
|
||||||
0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */
|
|
||||||
0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */
|
|
||||||
0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */
|
|
||||||
0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */
|
|
||||||
0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */
|
|
||||||
0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */
|
|
||||||
0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */
|
|
||||||
0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */
|
|
||||||
0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */
|
|
||||||
0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/
|
|
||||||
0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */
|
|
||||||
}
|
|
||||||
|
|
||||||
// simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
|
||||||
// the simulation test network as of protocol version 70002.
|
|
||||||
var simNetGenesisBlockBytes = []byte{
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */
|
|
||||||
0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */
|
|
||||||
0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */
|
|
||||||
0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */
|
|
||||||
0x4b, 0x1e, 0x5e, 0x4a, 0x45, 0x06, 0x86, 0x53, /* |K.^J)._I| */
|
|
||||||
0xff, 0xff, 0x7f, 0x20, 0x02, 0x00, 0x00, 0x00, /* |......+|| */
|
|
||||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */
|
|
||||||
0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */
|
|
||||||
0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */
|
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */
|
|
||||||
0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */
|
|
||||||
0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */
|
|
||||||
0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */
|
|
||||||
0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */
|
|
||||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */
|
|
||||||
0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */
|
|
||||||
0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */
|
|
||||||
0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */
|
|
||||||
0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */
|
|
||||||
0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */
|
|
||||||
0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */
|
|
||||||
0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */
|
|
||||||
0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */
|
|
||||||
0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */
|
|
||||||
0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */
|
|
||||||
0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/
|
|
||||||
0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */
|
|
||||||
}
|
|
||||||
|
|
||||||
// sigNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
|
||||||
// the signet test network as of protocol version 70002.
|
|
||||||
var sigNetGenesisBlockBytes = []byte{
|
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |...@....| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |........| */
|
|
||||||
0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |....;...| */
|
|
||||||
0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |z{..z.,>| */
|
|
||||||
0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |gv.a....| */
|
|
||||||
0x4b, 0x1e, 0x5e, 0x4a, 0x00, 0x8f, 0x4d, 0x5f, /* |..Q2:...| */
|
|
||||||
0xae, 0x77, 0x03, 0x1e, 0x8a, 0xd2, 0x22, 0x03, /* |K.^J..M_| */
|
|
||||||
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |.w....".| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */
|
|
||||||
0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |........| */
|
|
||||||
0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..M.....| */
|
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |..EThe T| */
|
|
||||||
0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |imes 03/| */
|
|
||||||
0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* |Jan/2009| */
|
|
||||||
0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* | Chancel| */
|
|
||||||
0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |lor on b| */
|
|
||||||
0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |rink of| */
|
|
||||||
0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |second b| */
|
|
||||||
0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |ailout f| */
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |or banks| */
|
|
||||||
0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |........| */
|
|
||||||
0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |*....CA.| */
|
|
||||||
0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |g....UH'| */
|
|
||||||
0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |.g..q0..| */
|
|
||||||
0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |\..(.9..| */
|
|
||||||
0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |yb...a..| */
|
|
||||||
0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |I..?L.8.| */
|
|
||||||
0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |.U......| */
|
|
||||||
0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |\8M....W| */
|
|
||||||
0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */
|
|
||||||
}
|
|
||||||
|
|
|
@ -61,12 +61,10 @@ func loadBlocks(t *testing.T, dataFile string, network wire.BitcoinNet) ([]*btcu
|
||||||
dr := bzip2.NewReader(fi)
|
dr := bzip2.NewReader(fi)
|
||||||
|
|
||||||
// Set the first block as the genesis block.
|
// Set the first block as the genesis block.
|
||||||
blocks := make([]*btcutil.Block, 0, 256)
|
blocks := make([]*btcutil.Block, 0, 257)
|
||||||
genesis := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
|
|
||||||
blocks = append(blocks, genesis)
|
|
||||||
|
|
||||||
// Load the remaining blocks.
|
// Load the remaining blocks.
|
||||||
for height := 1; ; height++ {
|
for {
|
||||||
var net uint32
|
var net uint32
|
||||||
err := binary.Read(dr, binary.LittleEndian, &net)
|
err := binary.Read(dr, binary.LittleEndian, &net)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -75,20 +73,18 @@ func loadBlocks(t *testing.T, dataFile string, network wire.BitcoinNet) ([]*btcu
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to load network type for block %d: %v",
|
t.Errorf("Failed to load network type for block %d: %v",
|
||||||
height, err)
|
len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if net != uint32(network) {
|
if net != uint32(network) {
|
||||||
t.Errorf("Block doesn't match network: %v expects %v",
|
continue
|
||||||
net, network)
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var blockLen uint32
|
var blockLen uint32
|
||||||
err = binary.Read(dr, binary.LittleEndian, &blockLen)
|
err = binary.Read(dr, binary.LittleEndian, &blockLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to load block size for block %d: %v",
|
t.Errorf("Failed to load block size for block %d: %v",
|
||||||
height, err)
|
len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,17 +92,22 @@ func loadBlocks(t *testing.T, dataFile string, network wire.BitcoinNet) ([]*btcu
|
||||||
blockBytes := make([]byte, blockLen)
|
blockBytes := make([]byte, blockLen)
|
||||||
_, err = io.ReadFull(dr, blockBytes)
|
_, err = io.ReadFull(dr, blockBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to load block %d: %v", height, err)
|
t.Errorf("Failed to load block %d: %v", len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deserialize and store the block.
|
// Deserialize and store the block.
|
||||||
block, err := btcutil.NewBlockFromBytes(blockBytes)
|
block, err := btcutil.NewBlockFromBytes(blockBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to parse block %v: %v", height, err)
|
t.Errorf("Failed to parse block %v: %v", len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// NOTE: there's a bug here in that it doesn't read the checksum;
|
||||||
|
// we account for that by checking the network above; it probably skips every other block
|
||||||
blocks = append(blocks, block)
|
blocks = append(blocks, block)
|
||||||
|
if len(blocks) == 257 {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return blocks, nil
|
return blocks, nil
|
||||||
|
|
|
@ -54,12 +54,10 @@ func loadBlocks(t *testing.T, dataFile string, network wire.BitcoinNet) ([]*btcu
|
||||||
dr := bzip2.NewReader(fi)
|
dr := bzip2.NewReader(fi)
|
||||||
|
|
||||||
// Set the first block as the genesis block.
|
// Set the first block as the genesis block.
|
||||||
blocks := make([]*btcutil.Block, 0, 256)
|
blocks := make([]*btcutil.Block, 0, 257)
|
||||||
genesis := btcutil.NewBlock(chaincfg.MainNetParams.GenesisBlock)
|
|
||||||
blocks = append(blocks, genesis)
|
|
||||||
|
|
||||||
// Load the remaining blocks.
|
// Load the remaining blocks.
|
||||||
for height := 1; ; height++ {
|
for {
|
||||||
var net uint32
|
var net uint32
|
||||||
err := binary.Read(dr, binary.LittleEndian, &net)
|
err := binary.Read(dr, binary.LittleEndian, &net)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -68,20 +66,18 @@ func loadBlocks(t *testing.T, dataFile string, network wire.BitcoinNet) ([]*btcu
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to load network type for block %d: %v",
|
t.Errorf("Failed to load network type for block %d: %v",
|
||||||
height, err)
|
len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if net != uint32(network) {
|
if net != uint32(network) {
|
||||||
t.Errorf("Block doesn't match network: %v expects %v",
|
continue
|
||||||
net, network)
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var blockLen uint32
|
var blockLen uint32
|
||||||
err = binary.Read(dr, binary.LittleEndian, &blockLen)
|
err = binary.Read(dr, binary.LittleEndian, &blockLen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to load block size for block %d: %v",
|
t.Errorf("Failed to load block size for block %d: %v",
|
||||||
height, err)
|
len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,17 +85,22 @@ func loadBlocks(t *testing.T, dataFile string, network wire.BitcoinNet) ([]*btcu
|
||||||
blockBytes := make([]byte, blockLen)
|
blockBytes := make([]byte, blockLen)
|
||||||
_, err = io.ReadFull(dr, blockBytes)
|
_, err = io.ReadFull(dr, blockBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to load block %d: %v", height, err)
|
t.Errorf("Failed to load block %d: %v", len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deserialize and store the block.
|
// Deserialize and store the block.
|
||||||
block, err := btcutil.NewBlockFromBytes(blockBytes)
|
block, err := btcutil.NewBlockFromBytes(blockBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to parse block %v: %v", height, err)
|
t.Errorf("Failed to parse block %v: %v", len(blocks), err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// there's a bug here in that it doesn't read the checksum
|
||||||
|
// and then it maybe ends up skipping a block
|
||||||
blocks = append(blocks, block)
|
blocks = append(blocks, block)
|
||||||
|
if len(blocks) == 257 {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return blocks, nil
|
return blocks, nil
|
||||||
|
|
BIN
database/testdata/blocks1-256.bz2
vendored
BIN
database/testdata/blocks1-256.bz2
vendored
Binary file not shown.
|
@ -3,6 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This file is ignored during the regular tests due to the following build tag.
|
// This file is ignored during the regular tests due to the following build tag.
|
||||||
|
//go:build rpctest
|
||||||
// +build rpctest
|
// +build rpctest
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
|
@ -129,7 +130,7 @@ func assertSoftForkStatus(r *rpctest.Harness, t *testing.T, forkKey string, stat
|
||||||
// specific soft fork deployment to test.
|
// specific soft fork deployment to test.
|
||||||
func testBIP0009(t *testing.T, forkKey string, deploymentID uint32) {
|
func testBIP0009(t *testing.T, forkKey string, deploymentID uint32) {
|
||||||
// Initialize the primary mining node with only the genesis block.
|
// Initialize the primary mining node with only the genesis block.
|
||||||
r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, nil, "")
|
r, err := rpctest.New(&chaincfg.SimNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create primary harness: %v", err)
|
t.Fatalf("unable to create primary harness: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -320,7 +321,7 @@ func TestBIP0009Mining(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Initialize the primary mining node with only the genesis block.
|
// Initialize the primary mining node with only the genesis block.
|
||||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, nil, "")
|
r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create primary harness: %v", err)
|
t.Fatalf("unable to create primary harness: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This file is ignored during the regular tests due to the following build tag.
|
// This file is ignored during the regular tests due to the following build tag.
|
||||||
|
//go:build rpctest
|
||||||
// +build rpctest
|
// +build rpctest
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
|
@ -113,13 +114,13 @@ func TestBIP0113Activation(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unable to create primary harness: ", err)
|
t.Fatal("unable to create primary harness: ", err)
|
||||||
}
|
}
|
||||||
if err := r.SetUp(true, 1); err != nil {
|
if err := r.SetUp(true, 10); err != nil {
|
||||||
t.Fatalf("unable to setup test chain: %v", err)
|
t.Fatalf("unable to setup test chain: %v", err)
|
||||||
}
|
}
|
||||||
defer r.TearDown()
|
defer r.TearDown()
|
||||||
|
|
||||||
// Create a fresh output for usage within the test below.
|
// Create a fresh output for usage within the test below.
|
||||||
const outputValue = btcutil.SatoshiPerBitcoin
|
const outputValue = btcutil.SatoshiPerBitcoin / 50
|
||||||
outputKey, testOutput, testPkScript, err := makeTestOutput(r, t,
|
outputKey, testOutput, testPkScript, err := makeTestOutput(r, t,
|
||||||
outputValue)
|
outputValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -189,7 +190,7 @@ func TestBIP0113Activation(t *testing.T) {
|
||||||
// to create a single mature output, then an additional block to create
|
// to create a single mature output, then an additional block to create
|
||||||
// a new output, and then mined a single block above to include our
|
// a new output, and then mined a single block above to include our
|
||||||
// transaction.
|
// transaction.
|
||||||
assertChainHeight(r, t, 103)
|
assertChainHeight(r, t, 112)
|
||||||
|
|
||||||
// Next, mine enough blocks to ensure that the soft-fork becomes
|
// Next, mine enough blocks to ensure that the soft-fork becomes
|
||||||
// activated. Assert that the block version of the second-to-last block
|
// activated. Assert that the block version of the second-to-last block
|
||||||
|
@ -205,7 +206,7 @@ func TestBIP0113Activation(t *testing.T) {
|
||||||
t.Fatalf("unable to generate blocks: %v", err)
|
t.Fatalf("unable to generate blocks: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertChainHeight(r, t, 299)
|
assertChainHeight(r, t, 308)
|
||||||
assertSoftForkStatus(r, t, csvKey, blockchain.ThresholdActive)
|
assertSoftForkStatus(r, t, csvKey, blockchain.ThresholdActive)
|
||||||
|
|
||||||
// The timeLockDeltas slice represents a series of deviations from the
|
// The timeLockDeltas slice represents a series of deviations from the
|
||||||
|
@ -426,7 +427,7 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
outputAmt = btcutil.SatoshiPerBitcoin
|
outputAmt = btcutil.SatoshiPerBitcoin / 50
|
||||||
relativeBlockLock = 10
|
relativeBlockLock = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This file is ignored during the regular tests due to the following build tag.
|
// This file is ignored during the regular tests due to the following build tag.
|
||||||
|
//go:build rpctest
|
||||||
// +build rpctest
|
// +build rpctest
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
|
|
|
@ -44,7 +44,7 @@ func solveBlock(header *wire.BlockHeader, targetDifficulty *big.Int) bool {
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
hdr.Nonce = i
|
hdr.Nonce = i
|
||||||
hash := hdr.BlockHash()
|
hash := hdr.BlockPoWHash()
|
||||||
if blockchain.HashToBig(&hash).Cmp(targetDifficulty) <= 0 {
|
if blockchain.HashToBig(&hash).Cmp(targetDifficulty) <= 0 {
|
||||||
select {
|
select {
|
||||||
case results <- sbResult{true, i}:
|
case results <- sbResult{true, i}:
|
||||||
|
@ -205,6 +205,7 @@ func CreateBlock(prevBlock *btcutil.Block, inclusionTxs []*btcutil.Tx,
|
||||||
MerkleRoot: *merkles[len(merkles)-1],
|
MerkleRoot: *merkles[len(merkles)-1],
|
||||||
Timestamp: ts,
|
Timestamp: ts,
|
||||||
Bits: net.PowLimitBits,
|
Bits: net.PowLimitBits,
|
||||||
|
ClaimTrie: chainhash.Hash{1}, // EmptyTrieHash
|
||||||
}
|
}
|
||||||
for _, tx := range blockTxns {
|
for _, tx := range blockTxns {
|
||||||
if err := block.AddTransaction(tx.MsgTx()); err != nil {
|
if err := block.AddTransaction(tx.MsgTx()); err != nil {
|
||||||
|
|
|
@ -256,11 +256,11 @@ func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numToGenerate := uint32(0)
|
||||||
// Create a test chain with the desired number of mature coinbase
|
// Create a test chain with the desired number of mature coinbase
|
||||||
// outputs.
|
// outputs.
|
||||||
if createTestChain && numMatureOutputs != 0 {
|
if createTestChain && numMatureOutputs != 0 {
|
||||||
numToGenerate := (uint32(h.ActiveNet.CoinbaseMaturity) +
|
numToGenerate = uint32(h.ActiveNet.CoinbaseMaturity) + numMatureOutputs
|
||||||
numMatureOutputs)
|
|
||||||
_, err := h.Client.Generate(numToGenerate)
|
_, err := h.Client.Generate(numToGenerate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -273,6 +273,9 @@ func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if numToGenerate > 0 && uint32(height) < numToGenerate {
|
||||||
|
return fmt.Errorf("failed to generate this many blocks: %d", numToGenerate)
|
||||||
|
}
|
||||||
ticker := time.NewTicker(time.Millisecond * 100)
|
ticker := time.NewTicker(time.Millisecond * 100)
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
walletHeight := h.wallet.SyncedHeight()
|
walletHeight := h.wallet.SyncedHeight()
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This file is ignored during the regular tests due to the following build tag.
|
// This file is ignored during the regular tests due to the following build tag.
|
||||||
|
//go:build rpctest
|
||||||
// +build rpctest
|
// +build rpctest
|
||||||
|
|
||||||
package rpctest
|
package rpctest
|
||||||
|
@ -63,7 +64,7 @@ func testSendOutputs(r *Harness, t *testing.T) {
|
||||||
|
|
||||||
// First, generate a small spend which will require only a single
|
// First, generate a small spend which will require only a single
|
||||||
// input.
|
// input.
|
||||||
txid := genSpend(btcutil.Amount(5 * btcutil.SatoshiPerBitcoin))
|
txid := genSpend(btcutil.Amount(btcutil.SatoshiPerBitcoin))
|
||||||
|
|
||||||
// Generate a single block, the transaction the wallet created should
|
// Generate a single block, the transaction the wallet created should
|
||||||
// be found in this block.
|
// be found in this block.
|
||||||
|
@ -75,7 +76,7 @@ func testSendOutputs(r *Harness, t *testing.T) {
|
||||||
|
|
||||||
// Next, generate a spend much greater than the block reward. This
|
// Next, generate a spend much greater than the block reward. This
|
||||||
// transaction should also have been mined properly.
|
// transaction should also have been mined properly.
|
||||||
txid = genSpend(btcutil.Amount(500 * btcutil.SatoshiPerBitcoin))
|
txid = genSpend(btcutil.Amount(10 * btcutil.SatoshiPerBitcoin))
|
||||||
blockHashes, err = r.Client.Generate(1)
|
blockHashes, err = r.Client.Generate(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to generate single block: %v", err)
|
t.Fatalf("unable to generate single block: %v", err)
|
||||||
|
@ -105,7 +106,7 @@ func assertConnectedTo(t *testing.T, nodeA *Harness, nodeB *Harness) {
|
||||||
|
|
||||||
func testConnectNode(r *Harness, t *testing.T) {
|
func testConnectNode(r *Harness, t *testing.T) {
|
||||||
// Create a fresh test harness.
|
// Create a fresh test harness.
|
||||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
harness, err := New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -153,7 +154,7 @@ func testActiveHarnesses(r *Harness, t *testing.T) {
|
||||||
numInitialHarnesses := len(ActiveHarnesses())
|
numInitialHarnesses := len(ActiveHarnesses())
|
||||||
|
|
||||||
// Create a single test harness.
|
// Create a single test harness.
|
||||||
harness1, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
harness1, err := New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -181,7 +182,7 @@ func testJoinMempools(r *Harness, t *testing.T) {
|
||||||
// Create a local test harness with only the genesis block. The nodes
|
// Create a local test harness with only the genesis block. The nodes
|
||||||
// will be synced below so the same transaction can be sent to both
|
// will be synced below so the same transaction can be sent to both
|
||||||
// nodes without it being an orphan.
|
// nodes without it being an orphan.
|
||||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
harness, err := New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ func testJoinMempools(r *Harness, t *testing.T) {
|
||||||
func testJoinBlocks(r *Harness, t *testing.T) {
|
func testJoinBlocks(r *Harness, t *testing.T) {
|
||||||
// Create a second harness with only the genesis block so it is behind
|
// Create a second harness with only the genesis block so it is behind
|
||||||
// the main harness.
|
// the main harness.
|
||||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
harness, err := New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -335,7 +336,7 @@ func testGenerateAndSubmitBlock(r *Harness, t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create script: %v", err)
|
t.Fatalf("unable to create script: %v", err)
|
||||||
}
|
}
|
||||||
output := wire.NewTxOut(btcutil.SatoshiPerBitcoin, pkScript)
|
output := wire.NewTxOut(btcutil.SatoshiPerBitcoin/50, pkScript)
|
||||||
|
|
||||||
const numTxns = 5
|
const numTxns = 5
|
||||||
txns := make([]*btcutil.Tx, 0, numTxns)
|
txns := make([]*btcutil.Tx, 0, numTxns)
|
||||||
|
@ -469,7 +470,7 @@ func testGenerateAndSubmitBlockWithCustomCoinbaseOutputs(r *Harness,
|
||||||
func testMemWalletReorg(r *Harness, t *testing.T) {
|
func testMemWalletReorg(r *Harness, t *testing.T) {
|
||||||
// Create a fresh harness, we'll be using the main harness to force a
|
// Create a fresh harness, we'll be using the main harness to force a
|
||||||
// re-org on this local harness.
|
// re-org on this local harness.
|
||||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
harness, err := New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -478,8 +479,8 @@ func testMemWalletReorg(r *Harness, t *testing.T) {
|
||||||
}
|
}
|
||||||
defer harness.TearDown()
|
defer harness.TearDown()
|
||||||
|
|
||||||
// The internal wallet of this harness should now have 250 BTC.
|
// The internal wallet of this harness should now have 250 BTC, but BTC is 50x LBC per generated coin.
|
||||||
expectedBalance := btcutil.Amount(250 * btcutil.SatoshiPerBitcoin)
|
expectedBalance := btcutil.Amount(5 * btcutil.SatoshiPerBitcoin)
|
||||||
walletBalance := harness.ConfirmedBalance()
|
walletBalance := harness.ConfirmedBalance()
|
||||||
if expectedBalance != walletBalance {
|
if expectedBalance != walletBalance {
|
||||||
t.Fatalf("wallet balance incorrect: expected %v, got %v",
|
t.Fatalf("wallet balance incorrect: expected %v, got %v",
|
||||||
|
@ -520,7 +521,7 @@ func testMemWalletLockedOutputs(r *Harness, t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create script: %v", err)
|
t.Fatalf("unable to create script: %v", err)
|
||||||
}
|
}
|
||||||
outputAmt := btcutil.Amount(50 * btcutil.SatoshiPerBitcoin)
|
outputAmt := btcutil.Amount(btcutil.SatoshiPerBitcoin)
|
||||||
output := wire.NewTxOut(int64(outputAmt), pkScript)
|
output := wire.NewTxOut(int64(outputAmt), pkScript)
|
||||||
tx, err := r.CreateTransaction([]*wire.TxOut{output}, 10, true)
|
tx, err := r.CreateTransaction([]*wire.TxOut{output}, 10, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -566,7 +567,7 @@ const (
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
var err error
|
var err error
|
||||||
mainHarness, err = New(&chaincfg.SimNetParams, nil, nil, "")
|
mainHarness, err = New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("unable to create main harness: ", err)
|
fmt.Println("unable to create main harness: ", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -601,9 +602,7 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHarness(t *testing.T) {
|
func TestHarness(t *testing.T) {
|
||||||
// We should have (numMatureOutputs * 50 BTC) of mature unspendable
|
expectedBalance := btcutil.Amount(numMatureOutputs * btcutil.SatoshiPerBitcoin)
|
||||||
// outputs.
|
|
||||||
expectedBalance := btcutil.Amount(numMatureOutputs * 50 * btcutil.SatoshiPerBitcoin)
|
|
||||||
harnessBalance := mainHarness.ConfirmedBalance()
|
harnessBalance := mainHarness.ConfirmedBalance()
|
||||||
if harnessBalance != expectedBalance {
|
if harnessBalance != expectedBalance {
|
||||||
t.Fatalf("expected wallet balance of %v instead have %v",
|
t.Fatalf("expected wallet balance of %v instead have %v",
|
||||||
|
|
|
@ -1457,7 +1457,7 @@ func TestAncestorsDescendants(t *testing.T) {
|
||||||
func TestRBF(t *testing.T) {
|
func TestRBF(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
const defaultFee = btcutil.SatoshiPerBitcoin
|
const defaultFee = btcutil.SatoshiPerBitcoin / 50
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
@ -176,6 +176,8 @@ func checkPkScriptStandard(pkScript []byte, scriptClass txscript.ScriptClass) er
|
||||||
// GetDustThreshold calculates the dust limit for a *wire.TxOut by taking the
|
// GetDustThreshold calculates the dust limit for a *wire.TxOut by taking the
|
||||||
// size of a typical spending transaction and multiplying it by 3 to account
|
// size of a typical spending transaction and multiplying it by 3 to account
|
||||||
// for the minimum dust relay fee of 3000sat/kvb.
|
// for the minimum dust relay fee of 3000sat/kvb.
|
||||||
|
const dustCap = math.MaxInt64 / 1001
|
||||||
|
|
||||||
func GetDustThreshold(txOut *wire.TxOut) int64 {
|
func GetDustThreshold(txOut *wire.TxOut) int64 {
|
||||||
// The total serialized size consists of the output and the associated
|
// The total serialized size consists of the output and the associated
|
||||||
// input script to redeem it. Since there is no input script
|
// input script to redeem it. Since there is no input script
|
||||||
|
@ -273,6 +275,9 @@ func IsDust(txOut *wire.TxOut, minRelayTxFee btcutil.Amount) bool {
|
||||||
//
|
//
|
||||||
// The following is equivalent to (value/totalSize) * (1/3) * 1000
|
// The following is equivalent to (value/totalSize) * (1/3) * 1000
|
||||||
// without needing to do floating point math.
|
// without needing to do floating point math.
|
||||||
|
if txOut.Value > dustCap {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return txOut.Value*1000/GetDustThreshold(txOut) < int64(minRelayTxFee)
|
return txOut.Value*1000/GetDustThreshold(txOut) < int64(minRelayTxFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func TestCalcMinRequiredTxRelayFee(t *testing.T) {
|
||||||
{
|
{
|
||||||
"max standard tx size with max satoshi relay fee",
|
"max standard tx size with max satoshi relay fee",
|
||||||
maxStandardTxWeight / 4,
|
maxStandardTxWeight / 4,
|
||||||
btcutil.MaxSatoshi,
|
btcutil.MaxSatoshi / 100, // overflow on purpose
|
||||||
btcutil.MaxSatoshi,
|
btcutil.MaxSatoshi,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -252,11 +252,11 @@ func TestDust(t *testing.T) {
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Maximum int64 value causes overflow.
|
// Maximum int64 value causes overflow if we're not careful
|
||||||
"maximum int64 value",
|
"maximum int64 value",
|
||||||
wire.TxOut{Value: 1<<63 - 1, PkScript: pkScript},
|
wire.TxOut{Value: 1<<63 - 1, PkScript: pkScript},
|
||||||
1<<63 - 1,
|
1<<63 - 1,
|
||||||
true,
|
false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Unspendable pkScript due to an invalid public key
|
// Unspendable pkScript due to an invalid public key
|
||||||
|
|
|
@ -519,7 +519,7 @@ func TestPeerListeners(t *testing.T) {
|
||||||
{
|
{
|
||||||
"OnBlock",
|
"OnBlock",
|
||||||
wire.NewMsgBlock(wire.NewBlockHeader(1,
|
wire.NewMsgBlock(wire.NewBlockHeader(1,
|
||||||
&chainhash.Hash{}, &chainhash.Hash{}, 1, 1)),
|
&chainhash.Hash{}, &chainhash.Hash{}, &chainhash.Hash{}, 1, 1)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"OnInv",
|
"OnInv",
|
||||||
|
@ -585,7 +585,7 @@ func TestPeerListeners(t *testing.T) {
|
||||||
{
|
{
|
||||||
"OnMerkleBlock",
|
"OnMerkleBlock",
|
||||||
wire.NewMsgMerkleBlock(wire.NewBlockHeader(1,
|
wire.NewMsgMerkleBlock(wire.NewBlockHeader(1,
|
||||||
&chainhash.Hash{}, &chainhash.Hash{}, 1, 1)),
|
&chainhash.Hash{}, &chainhash.Hash{}, &chainhash.Hash{}, 1, 1)),
|
||||||
},
|
},
|
||||||
// only one version message is allowed
|
// only one version message is allowed
|
||||||
// only one verack message is allowed
|
// only one verack message is allowed
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -275,10 +275,6 @@
|
||||||
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
["0000000000000000000000000000000000000000000000000000000000000100", 2, "0x51", 3000]],
|
||||||
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151540b00000000000001510002483045022100a3cec69b52cba2d2de623eeef89e0ba1606184ea55476c0f8189fda231bc9cbb022003181ad597f7c380a7d1c740286b1d022b8b04ded028b833282e055e03b8efef812103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
"0100000000010300010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00010000000000000000000000000000000000000000000000000000000000000100000000ffffffff00010000000000000000000000000000000000000000000000000000000000000200000000ffffffff03e8030000000000000151d0070000000000000151540b00000000000001510002483045022100a3cec69b52cba2d2de623eeef89e0ba1606184ea55476c0f8189fda231bc9cbb022003181ad597f7c380a7d1c740286b1d022b8b04ded028b833282e055e03b8efef812103596d3451025c19dbbdeb932d6bf8bfb4ad499b95b6f88db8899efac102e5fc710000000000", "P2SH,WITNESS"],
|
||||||
|
|
||||||
["Witness with a push of 521 bytes"],
|
|
||||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x00 0x20 0x33198a9bfef674ebddb9ffaa52928017b8472791e54c609cb95f278ac6b1e349", 1000]],
|
|
||||||
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff010000000000000000015102fd0902000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002755100000000", "P2SH,WITNESS"],
|
|
||||||
|
|
||||||
["Witness with unknown version which push false on the stack should be invalid (even without DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)"],
|
["Witness with unknown version which push false on the stack should be invalid (even without DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM)"],
|
||||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x60 0x02 0x0000", 2000]],
|
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x60 0x02 0x0000", 2000]],
|
||||||
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff010000000000000000015101010100000000", "P2SH,WITNESS"],
|
"0100000000010100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff010000000000000000015101010100000000", "P2SH,WITNESS"],
|
||||||
|
|
|
@ -25,7 +25,7 @@ func ExamplePayToAddrScript() {
|
||||||
// which is useful to ensure the accuracy of the address and determine
|
// which is useful to ensure the accuracy of the address and determine
|
||||||
// the address type. It is also required for the upcoming call to
|
// the address type. It is also required for the upcoming call to
|
||||||
// PayToAddrScript.
|
// PayToAddrScript.
|
||||||
addressStr := "12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV"
|
addressStr := "bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf"
|
||||||
address, err := btcutil.DecodeAddress(addressStr, &chaincfg.MainNetParams)
|
address, err := btcutil.DecodeAddress(addressStr, &chaincfg.MainNetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -48,8 +48,8 @@ func ExamplePayToAddrScript() {
|
||||||
fmt.Println("Script Disassembly:", disasm)
|
fmt.Println("Script Disassembly:", disasm)
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// Script Hex: 76a914128004ff2fcaf13b2b91eb654b1dc2b674f7ec6188ac
|
// Script Hex: 76a914345991dbf57bfb014b87006acdfafbfc5fe8292f88ac
|
||||||
// Script Disassembly: OP_DUP OP_HASH160 128004ff2fcaf13b2b91eb654b1dc2b674f7ec61 OP_EQUALVERIFY OP_CHECKSIG
|
// Script Disassembly: OP_DUP OP_HASH160 345991dbf57bfb014b87006acdfafbfc5fe8292f OP_EQUALVERIFY OP_CHECKSIG
|
||||||
}
|
}
|
||||||
|
|
||||||
// This example demonstrates extracting information from a standard public key
|
// This example demonstrates extracting information from a standard public key
|
||||||
|
@ -76,7 +76,7 @@ func ExampleExtractPkScriptAddrs() {
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
// Script Class: pubkeyhash
|
// Script Class: pubkeyhash
|
||||||
// Addresses: [12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV]
|
// Addresses: [bER6Ddq6YfRKDJDmmdeaqrP8XHmDJcYSJQ]
|
||||||
// Required Signatures: 1
|
// Required Signatures: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,12 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||||
case 0xb2:
|
case 0xb2:
|
||||||
// OP_NOP3 is an alias of OP_CHECKSEQUENCEVERIFY
|
// OP_NOP3 is an alias of OP_CHECKSEQUENCEVERIFY
|
||||||
expectedStr = "OP_CHECKSEQUENCEVERIFY"
|
expectedStr = "OP_CHECKSEQUENCEVERIFY"
|
||||||
|
case OP_CLAIMNAME:
|
||||||
|
expectedStr = "OP_CLAIMNAME"
|
||||||
|
case OP_SUPPORTCLAIM:
|
||||||
|
expectedStr = "OP_SUPPORTCLAIM"
|
||||||
|
case OP_UPDATECLAIM:
|
||||||
|
expectedStr = "OP_UPDATECLAIM"
|
||||||
default:
|
default:
|
||||||
val := byte(opcodeVal - (0xb0 - 1))
|
val := byte(opcodeVal - (0xb0 - 1))
|
||||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||||
|
@ -184,6 +190,12 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||||
case 0xb2:
|
case 0xb2:
|
||||||
// OP_NOP3 is an alias of OP_CHECKSEQUENCEVERIFY
|
// OP_NOP3 is an alias of OP_CHECKSEQUENCEVERIFY
|
||||||
expectedStr = "OP_CHECKSEQUENCEVERIFY"
|
expectedStr = "OP_CHECKSEQUENCEVERIFY"
|
||||||
|
case OP_CLAIMNAME:
|
||||||
|
expectedStr = "OP_CLAIMNAME"
|
||||||
|
case OP_SUPPORTCLAIM:
|
||||||
|
expectedStr = "OP_SUPPORTCLAIM"
|
||||||
|
case OP_UPDATECLAIM:
|
||||||
|
expectedStr = "OP_UPDATECLAIM"
|
||||||
default:
|
default:
|
||||||
val := byte(opcodeVal - (0xb0 - 1))
|
val := byte(opcodeVal - (0xb0 - 1))
|
||||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||||
|
|
|
@ -220,19 +220,10 @@ func TestScriptBuilderAddData(t *testing.T) {
|
||||||
expected: append([]byte{OP_PUSHDATA2, 0, 1}, bytes.Repeat([]byte{0x49}, 256)...),
|
expected: append([]byte{OP_PUSHDATA2, 0, 1}, bytes.Repeat([]byte{0x49}, 256)...),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "push data len 520",
|
name: "push data len 520", // bitcoin has a 520 byte cap, but lbry is 20k
|
||||||
data: bytes.Repeat([]byte{0x49}, 520),
|
data: bytes.Repeat([]byte{0x49}, 520),
|
||||||
expected: append([]byte{OP_PUSHDATA2, 0x08, 0x02}, bytes.Repeat([]byte{0x49}, 520)...),
|
expected: append([]byte{OP_PUSHDATA2, 0x08, 0x02}, bytes.Repeat([]byte{0x49}, 520)...),
|
||||||
},
|
},
|
||||||
|
|
||||||
// BIP0062: OP_PUSHDATA4 can never be used, as pushes over 520
|
|
||||||
// bytes are not allowed, and those below can be done using
|
|
||||||
// other operators.
|
|
||||||
{
|
|
||||||
name: "push data len 521",
|
|
||||||
data: bytes.Repeat([]byte{0x49}, 521),
|
|
||||||
expected: nil,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "push data len 32767 (canonical)",
|
name: "push data len 32767 (canonical)",
|
||||||
data: bytes.Repeat([]byte{0x49}, 32767),
|
data: bytes.Repeat([]byte{0x49}, 32767),
|
||||||
|
|
|
@ -419,7 +419,7 @@ func BenchmarkDecodeHeaders(b *testing.B) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("NewHashFromStr: unexpected error: %v", err)
|
b.Fatalf("NewHashFromStr: unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
m.AddBlockHeader(NewBlockHeader(1, hash, hash, 0, uint32(i)))
|
m.AddBlockHeader(NewBlockHeader(1, hash, hash, hash, 0, uint32(i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize it so the bytes are available to test the decode below.
|
// Serialize it so the bytes are available to test the decode below.
|
||||||
|
@ -565,7 +565,7 @@ func BenchmarkDecodeMerkleBlock(b *testing.B) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("NewHashFromStr: unexpected error: %v", err)
|
b.Fatalf("NewHashFromStr: unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
m.Header = *NewBlockHeader(1, hash, hash, 0, uint32(10000))
|
m.Header = *NewBlockHeader(1, hash, hash, hash, 0, uint32(10000))
|
||||||
for i := 0; i < 105; i++ {
|
for i := 0; i < 105; i++ {
|
||||||
hash, err := chainhash.NewHashFromStr(fmt.Sprintf("%x", i))
|
hash, err := chainhash.NewHashFromStr(fmt.Sprintf("%x", i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -45,7 +45,7 @@ type BlockHeader struct {
|
||||||
|
|
||||||
// blockHeaderLen is a constant that represents the number of bytes for a block
|
// blockHeaderLen is a constant that represents the number of bytes for a block
|
||||||
// header.
|
// header.
|
||||||
const blockHeaderLen = 80
|
const blockHeaderLen = 112
|
||||||
|
|
||||||
// BlockHash computes the block identifier hash for the given block header.
|
// BlockHash computes the block identifier hash for the given block header.
|
||||||
func (h *BlockHeader) BlockHash() chainhash.Hash {
|
func (h *BlockHeader) BlockHash() chainhash.Hash {
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestBlockHeader(t *testing.T) {
|
||||||
hash := mainNetGenesisHash
|
hash := mainNetGenesisHash
|
||||||
merkleHash := mainNetGenesisMerkleRoot
|
merkleHash := mainNetGenesisMerkleRoot
|
||||||
bits := uint32(0x1d00ffff)
|
bits := uint32(0x1d00ffff)
|
||||||
bh := NewBlockHeader(1, &hash, &merkleHash, bits, nonce)
|
bh := NewBlockHeader(1, &hash, &merkleHash, &merkleHash, bits, nonce)
|
||||||
|
|
||||||
// Ensure we get the same data back out.
|
// Ensure we get the same data back out.
|
||||||
if !bh.PrevBlock.IsEqual(&hash) {
|
if !bh.PrevBlock.IsEqual(&hash) {
|
||||||
|
@ -57,10 +57,12 @@ func TestBlockHeaderWire(t *testing.T) {
|
||||||
Version: 1,
|
Version: 1,
|
||||||
PrevBlock: mainNetGenesisHash,
|
PrevBlock: mainNetGenesisHash,
|
||||||
MerkleRoot: mainNetGenesisMerkleRoot,
|
MerkleRoot: mainNetGenesisMerkleRoot,
|
||||||
|
ClaimTrie: mainNetGenesisMerkleRoot,
|
||||||
Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST
|
Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST
|
||||||
Bits: bits,
|
Bits: bits,
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
}
|
}
|
||||||
|
baseBlockHdr.ClaimTrie[0] = 0x33
|
||||||
|
|
||||||
// baseBlockHdrEncoded is the wire encoded bytes of baseBlockHdr.
|
// baseBlockHdrEncoded is the wire encoded bytes of baseBlockHdr.
|
||||||
baseBlockHdrEncoded := []byte{
|
baseBlockHdrEncoded := []byte{
|
||||||
|
@ -73,6 +75,10 @@ func TestBlockHeaderWire(t *testing.T) {
|
||||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // MerkleRoot
|
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // MerkleRoot
|
||||||
|
0x33, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2,
|
||||||
|
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||||
|
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||||
|
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // ClaimTrie
|
||||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
||||||
|
@ -196,10 +202,12 @@ func TestBlockHeaderSerialize(t *testing.T) {
|
||||||
Version: 1,
|
Version: 1,
|
||||||
PrevBlock: mainNetGenesisHash,
|
PrevBlock: mainNetGenesisHash,
|
||||||
MerkleRoot: mainNetGenesisMerkleRoot,
|
MerkleRoot: mainNetGenesisMerkleRoot,
|
||||||
|
ClaimTrie: mainNetGenesisMerkleRoot,
|
||||||
Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST
|
Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST
|
||||||
Bits: bits,
|
Bits: bits,
|
||||||
Nonce: nonce,
|
Nonce: nonce,
|
||||||
}
|
}
|
||||||
|
baseBlockHdr.ClaimTrie[0] = 0x33
|
||||||
|
|
||||||
// baseBlockHdrEncoded is the wire encoded bytes of baseBlockHdr.
|
// baseBlockHdrEncoded is the wire encoded bytes of baseBlockHdr.
|
||||||
baseBlockHdrEncoded := []byte{
|
baseBlockHdrEncoded := []byte{
|
||||||
|
@ -212,6 +220,10 @@ func TestBlockHeaderSerialize(t *testing.T) {
|
||||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // MerkleRoot
|
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // MerkleRoot
|
||||||
|
0x33, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2,
|
||||||
|
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||||
|
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||||
|
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // ClaimTrie
|
||||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
||||||
|
|
|
@ -127,7 +127,7 @@ func TestElementWire(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MainNet,
|
MainNet,
|
||||||
[]byte{0xf9, 0xbe, 0xb4, 0xd9},
|
[]byte{0xfa, 0xe4, 0xaa, 0xf1},
|
||||||
},
|
},
|
||||||
// Type not supported by the "fast" path and requires reflection.
|
// Type not supported by the "fast" path and requires reflection.
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@ func TestMessage(t *testing.T) {
|
||||||
msgFilterAdd := NewMsgFilterAdd([]byte{0x01})
|
msgFilterAdd := NewMsgFilterAdd([]byte{0x01})
|
||||||
msgFilterClear := NewMsgFilterClear()
|
msgFilterClear := NewMsgFilterClear()
|
||||||
msgFilterLoad := NewMsgFilterLoad([]byte{0x01}, 10, 0, BloomUpdateNone)
|
msgFilterLoad := NewMsgFilterLoad([]byte{0x01}, 10, 0, BloomUpdateNone)
|
||||||
bh := NewBlockHeader(1, &chainhash.Hash{}, &chainhash.Hash{}, 0, 0)
|
bh := NewBlockHeader(1, &chainhash.Hash{}, &chainhash.Hash{}, &chainhash.Hash{}, 0, 0)
|
||||||
msgMerkleBlock := NewMsgMerkleBlock(bh)
|
msgMerkleBlock := NewMsgMerkleBlock(bh)
|
||||||
msgReject := NewMsgReject("block", RejectDuplicate, "duplicate block")
|
msgReject := NewMsgReject("block", RejectDuplicate, "duplicate block")
|
||||||
msgGetCFilters := NewMsgGetCFilters(GCSFilterRegular, 0, &chainhash.Hash{})
|
msgGetCFilters := NewMsgGetCFilters(GCSFilterRegular, 0, &chainhash.Hash{})
|
||||||
|
@ -89,7 +89,7 @@ func TestMessage(t *testing.T) {
|
||||||
{msgGetAddr, msgGetAddr, pver, MainNet, 24},
|
{msgGetAddr, msgGetAddr, pver, MainNet, 24},
|
||||||
{msgAddr, msgAddr, pver, MainNet, 25},
|
{msgAddr, msgAddr, pver, MainNet, 25},
|
||||||
{msgGetBlocks, msgGetBlocks, pver, MainNet, 61},
|
{msgGetBlocks, msgGetBlocks, pver, MainNet, 61},
|
||||||
{msgBlock, msgBlock, pver, MainNet, 239},
|
{msgBlock, msgBlock, pver, MainNet, 271},
|
||||||
{msgInv, msgInv, pver, MainNet, 25},
|
{msgInv, msgInv, pver, MainNet, 25},
|
||||||
{msgGetData, msgGetData, pver, MainNet, 25},
|
{msgGetData, msgGetData, pver, MainNet, 25},
|
||||||
{msgNotFound, msgNotFound, pver, MainNet, 25},
|
{msgNotFound, msgNotFound, pver, MainNet, 25},
|
||||||
|
@ -103,7 +103,7 @@ func TestMessage(t *testing.T) {
|
||||||
{msgFilterAdd, msgFilterAdd, pver, MainNet, 26},
|
{msgFilterAdd, msgFilterAdd, pver, MainNet, 26},
|
||||||
{msgFilterClear, msgFilterClear, pver, MainNet, 24},
|
{msgFilterClear, msgFilterClear, pver, MainNet, 24},
|
||||||
{msgFilterLoad, msgFilterLoad, pver, MainNet, 35},
|
{msgFilterLoad, msgFilterLoad, pver, MainNet, 35},
|
||||||
{msgMerkleBlock, msgMerkleBlock, pver, MainNet, 110},
|
{msgMerkleBlock, msgMerkleBlock, pver, MainNet, 142},
|
||||||
{msgReject, msgReject, pver, MainNet, 79},
|
{msgReject, msgReject, pver, MainNet, 79},
|
||||||
{msgGetCFilters, msgGetCFilters, pver, MainNet, 61},
|
{msgGetCFilters, msgGetCFilters, pver, MainNet, 61},
|
||||||
{msgGetCFHeaders, msgGetCFHeaders, pver, MainNet, 61},
|
{msgGetCFHeaders, msgGetCFHeaders, pver, MainNet, 61},
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestBlock(t *testing.T) {
|
||||||
merkleHash := &blockOne.Header.MerkleRoot
|
merkleHash := &blockOne.Header.MerkleRoot
|
||||||
bits := blockOne.Header.Bits
|
bits := blockOne.Header.Bits
|
||||||
nonce := blockOne.Header.Nonce
|
nonce := blockOne.Header.Nonce
|
||||||
bh := NewBlockHeader(1, prevHash, merkleHash, bits, nonce)
|
bh := NewBlockHeader(1, prevHash, merkleHash, merkleHash, bits, nonce)
|
||||||
|
|
||||||
// Ensure the command is expected value.
|
// Ensure the command is expected value.
|
||||||
wantCmd := "block"
|
wantCmd := "block"
|
||||||
|
@ -92,7 +92,7 @@ func TestBlockTxHashes(t *testing.T) {
|
||||||
// TestBlockHash tests the ability to generate the hash of a block accurately.
|
// TestBlockHash tests the ability to generate the hash of a block accurately.
|
||||||
func TestBlockHash(t *testing.T) {
|
func TestBlockHash(t *testing.T) {
|
||||||
// Block 1 hash.
|
// Block 1 hash.
|
||||||
hashStr := "839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"
|
hashStr := "a6b9bbfdd71af02426d2fc8131cfb843a27946e1f660a9dbca7556a0bb4a8ce2"
|
||||||
wantHash, err := chainhash.NewHashFromStr(hashStr)
|
wantHash, err := chainhash.NewHashFromStr(hashStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("NewHashFromStr: %v", err)
|
t.Errorf("NewHashFromStr: %v", err)
|
||||||
|
@ -224,15 +224,15 @@ func TestBlockWireErrors(t *testing.T) {
|
||||||
// Force error in merkle root.
|
// Force error in merkle root.
|
||||||
{&blockOne, blockOneBytes, pver, BaseEncoding, 36, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, pver, BaseEncoding, 36, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in timestamp.
|
// Force error in timestamp.
|
||||||
{&blockOne, blockOneBytes, pver, BaseEncoding, 68, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, pver, BaseEncoding, 68 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in difficulty bits.
|
// Force error in difficulty bits.
|
||||||
{&blockOne, blockOneBytes, pver, BaseEncoding, 72, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, pver, BaseEncoding, 72 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in header nonce.
|
// Force error in header nonce.
|
||||||
{&blockOne, blockOneBytes, pver, BaseEncoding, 76, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, pver, BaseEncoding, 76 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in transaction count.
|
// Force error in transaction count.
|
||||||
{&blockOne, blockOneBytes, pver, BaseEncoding, 80, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, pver, BaseEncoding, 80 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in transactions.
|
// Force error in transactions.
|
||||||
{&blockOne, blockOneBytes, pver, BaseEncoding, 81, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, pver, BaseEncoding, 81 + 32, io.ErrShortWrite, io.EOF},
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Running %d tests", len(tests))
|
t.Logf("Running %d tests", len(tests))
|
||||||
|
@ -342,15 +342,15 @@ func TestBlockSerializeErrors(t *testing.T) {
|
||||||
// Force error in merkle root.
|
// Force error in merkle root.
|
||||||
{&blockOne, blockOneBytes, 36, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, 36, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in timestamp.
|
// Force error in timestamp.
|
||||||
{&blockOne, blockOneBytes, 68, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, 68 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in difficulty bits.
|
// Force error in difficulty bits.
|
||||||
{&blockOne, blockOneBytes, 72, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, 72 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in header nonce.
|
// Force error in header nonce.
|
||||||
{&blockOne, blockOneBytes, 76, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, 76 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in transaction count.
|
// Force error in transaction count.
|
||||||
{&blockOne, blockOneBytes, 80, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, 80 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error in transactions.
|
// Force error in transactions.
|
||||||
{&blockOne, blockOneBytes, 81, io.ErrShortWrite, io.EOF},
|
{&blockOne, blockOneBytes, 81 + 32, io.ErrShortWrite, io.EOF},
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Running %d tests", len(tests))
|
t.Logf("Running %d tests", len(tests))
|
||||||
|
@ -413,6 +413,10 @@ func TestBlockOverflowErrors(t *testing.T) {
|
||||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||||
|
0x33, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // ClaimTrie
|
||||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||||
|
@ -465,7 +469,7 @@ func TestBlockSerializeSize(t *testing.T) {
|
||||||
size int // Expected serialized size
|
size int // Expected serialized size
|
||||||
}{
|
}{
|
||||||
// Block with no transactions.
|
// Block with no transactions.
|
||||||
{noTxBlock, 81},
|
{noTxBlock, 81 + 32},
|
||||||
|
|
||||||
// First block in the mainnet block chain.
|
// First block in the mainnet block chain.
|
||||||
{&blockOne, len(blockOneBytes)},
|
{&blockOne, len(blockOneBytes)},
|
||||||
|
@ -498,6 +502,12 @@ var blockOne = MsgBlock{
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
||||||
}),
|
}),
|
||||||
|
ClaimTrie: chainhash.Hash([chainhash.HashSize]byte{
|
||||||
|
0x33, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
||||||
|
}),
|
||||||
|
|
||||||
Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST
|
Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST
|
||||||
Bits: 0x1d00ffff, // 486604799
|
Bits: 0x1d00ffff, // 486604799
|
||||||
|
@ -552,6 +562,10 @@ var blockOneBytes = []byte{
|
||||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||||
|
0x33, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // ClaimTrie
|
||||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||||
|
@ -585,5 +599,5 @@ var blockOneBytes = []byte{
|
||||||
|
|
||||||
// Transaction location information for block one transactions.
|
// Transaction location information for block one transactions.
|
||||||
var blockOneTxLocs = []TxLoc{
|
var blockOneTxLocs = []TxLoc{
|
||||||
{TxStart: 81, TxLen: 134},
|
{TxStart: 81 + 32, TxLen: 134},
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TestHeaders(t *testing.T) {
|
||||||
// Ensure max payload is expected value for latest protocol version.
|
// Ensure max payload is expected value for latest protocol version.
|
||||||
// Num headers (varInt) + max allowed headers (header length + 1 byte
|
// Num headers (varInt) + max allowed headers (header length + 1 byte
|
||||||
// for the number of transactions which is always 0).
|
// for the number of transactions which is always 0).
|
||||||
wantPayload := uint32(162009)
|
wantPayload := uint32(226009)
|
||||||
maxPayload := msg.MaxPayloadLength(pver)
|
maxPayload := msg.MaxPayloadLength(pver)
|
||||||
if maxPayload != wantPayload {
|
if maxPayload != wantPayload {
|
||||||
t.Errorf("MaxPayloadLength: wrong max payload length for "+
|
t.Errorf("MaxPayloadLength: wrong max payload length for "+
|
||||||
|
@ -64,7 +64,7 @@ func TestHeadersWire(t *testing.T) {
|
||||||
merkleHash := blockOne.Header.MerkleRoot
|
merkleHash := blockOne.Header.MerkleRoot
|
||||||
bits := uint32(0x1d00ffff)
|
bits := uint32(0x1d00ffff)
|
||||||
nonce := uint32(0x9962e301)
|
nonce := uint32(0x9962e301)
|
||||||
bh := NewBlockHeader(1, &hash, &merkleHash, bits, nonce)
|
bh := NewBlockHeader(1, &hash, &merkleHash, &merkleHash, bits, nonce)
|
||||||
bh.Version = blockOne.Header.Version
|
bh.Version = blockOne.Header.Version
|
||||||
bh.Timestamp = blockOne.Header.Timestamp
|
bh.Timestamp = blockOne.Header.Timestamp
|
||||||
|
|
||||||
|
@ -88,6 +88,10 @@ func TestHeadersWire(t *testing.T) {
|
||||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||||
|
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // ClaimTrie
|
||||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||||
|
@ -232,7 +236,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||||
merkleHash := blockOne.Header.MerkleRoot
|
merkleHash := blockOne.Header.MerkleRoot
|
||||||
bits := uint32(0x1d00ffff)
|
bits := uint32(0x1d00ffff)
|
||||||
nonce := uint32(0x9962e301)
|
nonce := uint32(0x9962e301)
|
||||||
bh := NewBlockHeader(1, &hash, &merkleHash, bits, nonce)
|
bh := NewBlockHeader(1, &hash, &merkleHash, &merkleHash, bits, nonce)
|
||||||
bh.Version = blockOne.Header.Version
|
bh.Version = blockOne.Header.Version
|
||||||
bh.Timestamp = blockOne.Header.Timestamp
|
bh.Timestamp = blockOne.Header.Timestamp
|
||||||
|
|
||||||
|
@ -250,6 +254,10 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||||
|
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // ClaimTrie
|
||||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||||
|
@ -269,7 +277,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||||
|
|
||||||
// Intentionally invalid block header that has a transaction count used
|
// Intentionally invalid block header that has a transaction count used
|
||||||
// to force errors.
|
// to force errors.
|
||||||
bhTrans := NewBlockHeader(1, &hash, &merkleHash, bits, nonce)
|
bhTrans := NewBlockHeader(1, &hash, &merkleHash, &merkleHash, bits, nonce)
|
||||||
bhTrans.Version = blockOne.Header.Version
|
bhTrans.Version = blockOne.Header.Version
|
||||||
bhTrans.Timestamp = blockOne.Header.Timestamp
|
bhTrans.Timestamp = blockOne.Header.Timestamp
|
||||||
|
|
||||||
|
@ -286,6 +294,10 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||||
|
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // ClaimTrie
|
||||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||||
|
@ -309,7 +321,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||||
// Force error with greater than max headers.
|
// Force error with greater than max headers.
|
||||||
{maxHeaders, maxHeadersEncoded, pver, BaseEncoding, 3, wireErr, wireErr},
|
{maxHeaders, maxHeadersEncoded, pver, BaseEncoding, 3, wireErr, wireErr},
|
||||||
// Force error with number of transactions.
|
// Force error with number of transactions.
|
||||||
{transHeader, transHeaderEncoded, pver, BaseEncoding, 81, io.ErrShortWrite, io.EOF},
|
{transHeader, transHeaderEncoded, pver, BaseEncoding, 81 + 32, io.ErrShortWrite, io.EOF},
|
||||||
// Force error with included transactions.
|
// Force error with included transactions.
|
||||||
{transHeader, transHeaderEncoded, pver, BaseEncoding, len(transHeaderEncoded), nil, wireErr},
|
{transHeader, transHeaderEncoded, pver, BaseEncoding, len(transHeaderEncoded), nil, wireErr},
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestMerkleBlock(t *testing.T) {
|
||||||
merkleHash := &blockOne.Header.MerkleRoot
|
merkleHash := &blockOne.Header.MerkleRoot
|
||||||
bits := blockOne.Header.Bits
|
bits := blockOne.Header.Bits
|
||||||
nonce := blockOne.Header.Nonce
|
nonce := blockOne.Header.Nonce
|
||||||
bh := NewBlockHeader(1, prevHash, merkleHash, bits, nonce)
|
bh := NewBlockHeader(1, prevHash, merkleHash, merkleHash, bits, nonce)
|
||||||
|
|
||||||
// Ensure the command is expected value.
|
// Ensure the command is expected value.
|
||||||
wantCmd := "merkleblock"
|
wantCmd := "merkleblock"
|
||||||
|
@ -118,7 +118,7 @@ func TestMerkleBlockCrossProtocol(t *testing.T) {
|
||||||
merkleHash := &blockOne.Header.MerkleRoot
|
merkleHash := &blockOne.Header.MerkleRoot
|
||||||
bits := blockOne.Header.Bits
|
bits := blockOne.Header.Bits
|
||||||
nonce := blockOne.Header.Nonce
|
nonce := blockOne.Header.Nonce
|
||||||
bh := NewBlockHeader(1, prevHash, merkleHash, bits, nonce)
|
bh := NewBlockHeader(1, prevHash, merkleHash, merkleHash, bits, nonce)
|
||||||
|
|
||||||
msg := NewMsgMerkleBlock(bh)
|
msg := NewMsgMerkleBlock(bh)
|
||||||
|
|
||||||
|
@ -229,48 +229,48 @@ func TestMerkleBlockWireErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
// Force error in timestamp.
|
// Force error in timestamp.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 68,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 68 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in difficulty bits.
|
// Force error in difficulty bits.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 72,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 72 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in header nonce.
|
// Force error in header nonce.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 76,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 76 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in transaction count.
|
// Force error in transaction count.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 80,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 80 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in num hashes.
|
// Force error in num hashes.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 84,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 84 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in hashes.
|
// Force error in hashes.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 85,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 85 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in num flag bytes.
|
// Force error in num flag bytes.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 117,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 117 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error in flag bytes.
|
// Force error in flag bytes.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 118,
|
&merkleBlockOne, merkleBlockOneBytes, pver, BaseEncoding, 118 + 32,
|
||||||
io.ErrShortWrite, io.EOF,
|
io.ErrShortWrite, io.EOF,
|
||||||
},
|
},
|
||||||
// Force error due to unsupported protocol version.
|
// Force error due to unsupported protocol version.
|
||||||
{
|
{
|
||||||
&merkleBlockOne, merkleBlockOneBytes, pverNoMerkleBlock,
|
&merkleBlockOne, merkleBlockOneBytes, pverNoMerkleBlock,
|
||||||
BaseEncoding, 119, wireErr, wireErr,
|
BaseEncoding, 119 + 32, wireErr, wireErr,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
|
||||||
// allowed tx hashes.
|
// allowed tx hashes.
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteVarInt(&buf, pver, maxTxPerBlock+1)
|
WriteVarInt(&buf, pver, maxTxPerBlock+1)
|
||||||
numHashesOffset := 84
|
numHashesOffset := 84 + 32
|
||||||
exceedMaxHashes := make([]byte, numHashesOffset)
|
exceedMaxHashes := make([]byte, numHashesOffset)
|
||||||
copy(exceedMaxHashes, merkleBlockOneBytes[:numHashesOffset])
|
copy(exceedMaxHashes, merkleBlockOneBytes[:numHashesOffset])
|
||||||
exceedMaxHashes = append(exceedMaxHashes, buf.Bytes()...)
|
exceedMaxHashes = append(exceedMaxHashes, buf.Bytes()...)
|
||||||
|
@ -340,7 +340,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
|
||||||
// allowed flag bytes.
|
// allowed flag bytes.
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
WriteVarInt(&buf, pver, maxFlagsPerMerkleBlock+1)
|
WriteVarInt(&buf, pver, maxFlagsPerMerkleBlock+1)
|
||||||
numFlagBytesOffset := 117
|
numFlagBytesOffset := 117 + 32
|
||||||
exceedMaxFlagBytes := make([]byte, numFlagBytesOffset)
|
exceedMaxFlagBytes := make([]byte, numFlagBytesOffset)
|
||||||
copy(exceedMaxFlagBytes, merkleBlockOneBytes[:numFlagBytesOffset])
|
copy(exceedMaxFlagBytes, merkleBlockOneBytes[:numFlagBytesOffset])
|
||||||
exceedMaxFlagBytes = append(exceedMaxFlagBytes, buf.Bytes()...)
|
exceedMaxFlagBytes = append(exceedMaxFlagBytes, buf.Bytes()...)
|
||||||
|
@ -388,6 +388,12 @@ var merkleBlockOne = MsgMerkleBlock{
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
||||||
}),
|
}),
|
||||||
|
ClaimTrie: chainhash.Hash([chainhash.HashSize]byte{
|
||||||
|
0x33, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
||||||
|
}),
|
||||||
Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST
|
Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST
|
||||||
Bits: 0x1d00ffff, // 486604799
|
Bits: 0x1d00ffff, // 486604799
|
||||||
Nonce: 0x9962e301, // 2573394689
|
Nonce: 0x9962e301, // 2573394689
|
||||||
|
@ -416,6 +422,10 @@ var merkleBlockOneBytes = []byte{
|
||||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||||
|
0x33, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||||
|
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||||
|
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||||
|
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // ClaimTrie
|
||||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||||
|
|
Loading…
Reference in a new issue