mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-570] Separate genesis variables for different netwroks (#578)
* [NOD-570] Separate genesis variables for different netwroks * [NOD-570] Make Testnet genesis * [NOD-570] Make simnet and regtest genesis * [NOD-570] Remake devnet genesis * [NOD-570] Rename regNet -> regTest testnet->testNet * [NOD-570] Change network names to one word instead of camel case * [NOD-570] Change network names to one word instead of camel case * [NOD-570] Fix test names * [NOD-570] Fix TestGHOSTDAG Co-authored-by: Dan Aharoni <dereeno@protonmail.com>
This commit is contained in:
parent
20819ca4cd
commit
6d765f58ba
@ -120,7 +120,7 @@ func TestAddAddressByIP(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -174,7 +174,7 @@ func TestAddLocalAddress(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -237,7 +237,7 @@ func TestAttempt(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -269,7 +269,7 @@ func TestConnected(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -299,7 +299,7 @@ func TestNeedMoreAddresses(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -341,7 +341,7 @@ func TestGood(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -398,7 +398,7 @@ func TestGoodChangeSubnetworkID(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -477,7 +477,7 @@ func TestGetAddress(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -559,7 +559,7 @@ func TestGetBestLocalAddress(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
@ -22,7 +22,7 @@ func TestIPTypes(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
@ -162,7 +162,7 @@ func TestGroupKey(t *testing.T) {
|
||||
return &config.Config{
|
||||
Flags: &config.Flags{
|
||||
NetworkFlags: config.NetworkFlags{
|
||||
ActiveNetParams: &dagconfig.SimNetParams},
|
||||
ActiveNetParams: &dagconfig.SimnetParams},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
func TestMaybeAcceptBlockErrors(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("TestMaybeAcceptBlockErrors", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TestMaybeAcceptBlockErrors: Failed to setup DAG instance: %v", err)
|
||||
|
@ -11,14 +11,14 @@ import (
|
||||
func TestBlockHeap(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("TestBlockHeap", Config{
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TestBlockHeap: Failed to setup DAG instance: %s", err)
|
||||
}
|
||||
defer teardownFunc()
|
||||
|
||||
block0Header := dagconfig.MainNetParams.GenesisBlock.Header
|
||||
block0Header := dagconfig.MainnetParams.GenesisBlock.Header
|
||||
block0, _ := dag.newBlockNode(&block0Header, newSet())
|
||||
|
||||
block100000Header := Block100000.Header
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
|
||||
func TestAncestorErrors(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
dag, teardownFunc, err := DAGSetup("TestAncestorErrors", Config{
|
||||
DAGParams: ¶ms,
|
||||
})
|
||||
@ -33,7 +33,7 @@ func TestAncestorErrors(t *testing.T) {
|
||||
func TestFlushToDBErrors(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("TestFlushToDBErrors", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TestFlushToDBErrors: Failed to setup DAG instance: %s", err)
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestChainHeight(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 2
|
||||
dag, teardownFunc, err := DAGSetup("TestChainHeight", Config{
|
||||
DAGParams: ¶ms,
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBlueBlockWindow(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
dag, teardownFunc, err := DAGSetup("TestBlueBlockWindow", Config{
|
||||
DAGParams: ¶ms,
|
||||
|
@ -47,7 +47,7 @@ func TestBlockCount(t *testing.T) {
|
||||
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("TestBlockCount", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to setup DAG instance: %v", err)
|
||||
@ -100,7 +100,7 @@ func TestHaveBlock(t *testing.T) {
|
||||
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("haveblock", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to setup DAG instance: %v", err)
|
||||
@ -206,10 +206,10 @@ func TestHaveBlock(t *testing.T) {
|
||||
want bool
|
||||
}{
|
||||
// Genesis block should be present.
|
||||
{hash: dagconfig.SimNetParams.GenesisHash.String(), want: true},
|
||||
{hash: dagconfig.SimnetParams.GenesisHash.String(), want: true},
|
||||
|
||||
// Block 3b should be present (as a second child of Block 2).
|
||||
{hash: "09e5e38f3fa2c5104b72b2f7122b2245085331e0d8cd1df79a3b12d66666ecb3", want: true},
|
||||
{hash: "264176fb6072e2362db18f92d3f4b739cff071a206736df7c407c0bf9a1d7fef", want: true},
|
||||
|
||||
// Block 100000 should be present (as an orphan).
|
||||
{hash: "65b20b048a074793ebfd1196e49341c8d194dabfc6b44a4fd0c607406e122baf", want: true},
|
||||
@ -237,7 +237,7 @@ func TestHaveBlock(t *testing.T) {
|
||||
// combinations of inputs to the CalcSequenceLock function in order to ensure
|
||||
// the returned SequenceLocks are correct for each test instance.
|
||||
func TestCalcSequenceLock(t *testing.T) {
|
||||
netParams := &dagconfig.SimNetParams
|
||||
netParams := &dagconfig.SimnetParams
|
||||
|
||||
blockVersion := int32(0x10000000)
|
||||
|
||||
@ -505,7 +505,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCalcPastMedianTime(t *testing.T) {
|
||||
netParams := &dagconfig.SimNetParams
|
||||
netParams := &dagconfig.SimnetParams
|
||||
|
||||
blockVersion := int32(0x10000000)
|
||||
|
||||
@ -602,7 +602,7 @@ func TestChainHeightToHashRange(t *testing.T) {
|
||||
// genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18
|
||||
// \-> 16a -> 17a -> 18a (unvalidated)
|
||||
tip := testTip
|
||||
dag := newTestDAG(&dagconfig.SimNetParams)
|
||||
dag := newTestDAG(&dagconfig.SimnetParams)
|
||||
branch0Nodes := chainedNodes(dag, setFromSlice(dag.genesis), 18)
|
||||
branch1Nodes := chainedNodes(dag, setFromSlice(branch0Nodes[14]), 3)
|
||||
for _, node := range branch0Nodes {
|
||||
@ -694,7 +694,7 @@ func TestIntervalBlockHashes(t *testing.T) {
|
||||
// genesis -> 1 -> 2 -> ... -> 15 -> 16 -> 17 -> 18
|
||||
// \-> 16a -> 17a -> 18a (unvalidated)
|
||||
tip := testTip
|
||||
dag := newTestDAG(&dagconfig.SimNetParams)
|
||||
dag := newTestDAG(&dagconfig.SimnetParams)
|
||||
branch0Nodes := chainedNodes(dag, setFromSlice(dag.genesis), 18)
|
||||
branch1Nodes := chainedNodes(dag, setFromSlice(branch0Nodes[14]), 3)
|
||||
for _, node := range branch0Nodes {
|
||||
@ -812,7 +812,7 @@ func testErrorThroughPatching(t *testing.T, expectedErrorMessage string, targetF
|
||||
|
||||
// Create a new database and dag instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("testErrorThroughPatching", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to setup dag instance: %v", err)
|
||||
@ -872,7 +872,7 @@ func TestNew(t *testing.T) {
|
||||
os.RemoveAll(testDbRoot)
|
||||
}()
|
||||
config := &Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
DB: db,
|
||||
TimeSource: NewMedianTime(),
|
||||
SigCache: txscript.NewSigCache(1000),
|
||||
@ -921,7 +921,7 @@ func TestAcceptingInInit(t *testing.T) {
|
||||
|
||||
// Create a DAG to add the test block into
|
||||
config := &Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
DB: db,
|
||||
TimeSource: NewMedianTime(),
|
||||
SigCache: txscript.NewSigCache(1000),
|
||||
@ -972,7 +972,7 @@ func TestAcceptingInInit(t *testing.T) {
|
||||
|
||||
func TestConfirmations(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
dag, teardownFunc, err := DAGSetup("TestConfirmations", Config{
|
||||
DAGParams: ¶ms,
|
||||
@ -1078,7 +1078,7 @@ func TestConfirmations(t *testing.T) {
|
||||
|
||||
func TestAcceptingBlock(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 3
|
||||
dag, teardownFunc, err := DAGSetup("TestAcceptingBlock", Config{
|
||||
DAGParams: ¶ms,
|
||||
@ -1204,7 +1204,7 @@ func TestFinalizeNodesBelowFinalityPoint(t *testing.T) {
|
||||
}
|
||||
|
||||
func testFinalizeNodesBelowFinalityPoint(t *testing.T, deleteDiffData bool) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
dag, teardownFunc, err := DAGSetup("testFinalizeNodesBelowFinalityPoint", Config{
|
||||
DAGParams: ¶ms,
|
||||
@ -1290,7 +1290,7 @@ func testFinalizeNodesBelowFinalityPoint(t *testing.T, deleteDiffData bool) {
|
||||
}
|
||||
|
||||
func TestDAGIndexFailedStatus(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
dag, teardownFunc, err := DAGSetup("TestDAGIndexFailedStatus", Config{
|
||||
DAGParams: ¶ms,
|
||||
})
|
||||
|
@ -79,7 +79,7 @@ func TestCalcWork(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDifficulty(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
params.DifficultyAdjustmentWindowSize = 264
|
||||
dag, teardownFunc, err := DAGSetup("TestDifficulty", Config{
|
||||
|
@ -37,7 +37,7 @@ import (
|
||||
// gets rejected because it doesn't have the last finality point in
|
||||
// its selected parent chain.
|
||||
func TestFinality(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
params.FinalityInterval = 100
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestFinality", blockdag.Config{
|
||||
@ -167,15 +167,15 @@ func TestFinality(t *testing.T) {
|
||||
// a getblocks message it should always be able to send
|
||||
// all the necessary invs.
|
||||
func TestFinalityInterval(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
if params.FinalityInterval > wire.MaxInvPerMsg {
|
||||
t.Errorf("dagconfig.SimNetParams.FinalityInterval should be lower or equal to wire.MaxInvPerMsg")
|
||||
t.Errorf("dagconfig.SimnetParams.FinalityInterval should be lower or equal to wire.MaxInvPerMsg")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSubnetworkRegistry tests the full subnetwork registry flow
|
||||
func TestSubnetworkRegistry(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestSubnetworkRegistry", blockdag.Config{
|
||||
@ -201,7 +201,7 @@ func TestSubnetworkRegistry(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChainedTransactions(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
// Create a new database and dag instance to run tests against.
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestChainedTransactions", blockdag.Config{
|
||||
@ -319,7 +319,7 @@ func TestChainedTransactions(t *testing.T) {
|
||||
// before txB.
|
||||
func TestOrderInDiffFromAcceptanceData(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = math.MaxUint32
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestOrderInDiffFromAcceptanceData", blockdag.Config{
|
||||
DAGParams: ¶ms,
|
||||
@ -388,7 +388,7 @@ func TestOrderInDiffFromAcceptanceData(t *testing.T) {
|
||||
|
||||
// TestGasLimit tests the gas limit rules
|
||||
func TestGasLimit(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestSubnetworkRegistry", blockdag.Config{
|
||||
|
@ -21,7 +21,7 @@ type testBlockData struct {
|
||||
// that the blue score, blue set and selected parent of each
|
||||
// block are calculated as expected.
|
||||
func TestGHOSTDAG(t *testing.T) {
|
||||
dagParams := dagconfig.SimNetParams
|
||||
dagParams := dagconfig.SimnetParams
|
||||
|
||||
tests := []struct {
|
||||
k uint32
|
||||
@ -30,7 +30,7 @@ func TestGHOSTDAG(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
k: 3,
|
||||
expectedReds: []string{"F", "G", "H", "I", "N", "Q"},
|
||||
expectedReds: []string{"F", "G", "H", "I", "O", "P"},
|
||||
dagData: []*testBlockData{
|
||||
{
|
||||
parents: []string{"A"},
|
||||
@ -163,7 +163,7 @@ func TestGHOSTDAG(t *testing.T) {
|
||||
id: "T",
|
||||
expectedScore: 13,
|
||||
expectedSelectedParent: "S",
|
||||
expectedBlues: []string{"S", "P", "O"},
|
||||
expectedBlues: []string{"S", "N", "Q"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -71,7 +71,7 @@ func TestAcceptanceIndexSerializationAndDeserialization(t *testing.T) {
|
||||
// comparing dag1's last block acceptance data and dag3's last block acceptance
|
||||
// data.
|
||||
func TestAcceptanceIndexRecover(t *testing.T) {
|
||||
params := &dagconfig.SimNetParams
|
||||
params := &dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
|
||||
testFiles := []string{
|
||||
|
@ -39,7 +39,7 @@ func TestTxIndexConnectBlock(t *testing.T) {
|
||||
txIndex := NewTxIndex()
|
||||
indexManager := NewManager([]Indexer{txIndex})
|
||||
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
params.K = 1
|
||||
|
||||
|
@ -20,7 +20,7 @@ func TestNotifications(t *testing.T) {
|
||||
|
||||
// Create a new database and dag instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("notifications", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to setup dag instance: %v", err)
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
|
||||
func TestProcessBlock(t *testing.T) {
|
||||
dag, teardownFunc, err := DAGSetup("TestProcessBlock", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Failed to setup dag instance: %v", err)
|
||||
@ -61,8 +61,8 @@ func TestProcessBlock(t *testing.T) {
|
||||
t.Errorf("ProcessBlock: Didn't expected checkBlockSanity to be called")
|
||||
}
|
||||
|
||||
isOrphan, isDelayed, err = dag.ProcessBlock(util.NewBlock(dagconfig.SimNetParams.GenesisBlock), BFNone)
|
||||
expectedErrMsg := fmt.Sprintf("already have block %s", dagconfig.SimNetParams.GenesisHash)
|
||||
isOrphan, isDelayed, err = dag.ProcessBlock(util.NewBlock(dagconfig.SimnetParams.GenesisBlock), BFNone)
|
||||
expectedErrMsg := fmt.Sprintf("already have block %s", dagconfig.SimnetParams.GenesisHash)
|
||||
if err == nil || err.Error() != expectedErrMsg {
|
||||
t.Errorf("ProcessBlock: Expected error \"%s\" but got \"%s\"", expectedErrMsg, err)
|
||||
}
|
||||
@ -70,7 +70,7 @@ func TestProcessBlock(t *testing.T) {
|
||||
|
||||
func TestProcessOrphans(t *testing.T) {
|
||||
dag, teardownFunc, err := DAGSetup("TestProcessOrphans", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Failed to setup dag instance: %v", err)
|
||||
|
@ -30,7 +30,7 @@ const (
|
||||
testDbRoot = "testdbs"
|
||||
|
||||
// blockDataNet is the expected network in the test block data.
|
||||
blockDataNet = wire.MainNet
|
||||
blockDataNet = wire.Mainnet
|
||||
)
|
||||
|
||||
// isSupportedDbType returns whether or not the passed database type is
|
||||
@ -200,7 +200,7 @@ func GetVirtualFromParentsForTest(dag *BlockDAG, parentHashes []*daghash.Hash) (
|
||||
// LoadBlocks reads files containing kaspa gzipped block data from disk
|
||||
// and returns them as an array of util.Block.
|
||||
func LoadBlocks(filename string) (blocks []*util.Block, err error) {
|
||||
var network = wire.MainNet
|
||||
var network = wire.Mainnet
|
||||
var dr io.Reader
|
||||
var fi io.ReadCloser
|
||||
|
||||
|
@ -45,7 +45,7 @@ func testDAGSetupErrorThroughPatching(t *testing.T, expectedErrorMessage string,
|
||||
guard := monkey.Patch(targetFunction, replacementFunction)
|
||||
defer guard.Unpatch()
|
||||
_, tearDown, err := DAGSetup("TestDAGSetup", Config{
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
})
|
||||
if tearDown != nil {
|
||||
defer tearDown()
|
||||
|
BIN
blockdag/testdata/blk_0_to_4.dat
vendored
BIN
blockdag/testdata/blk_0_to_4.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3A.dat
vendored
BIN
blockdag/testdata/blk_3A.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3B.dat
vendored
BIN
blockdag/testdata/blk_3B.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3C.dat
vendored
BIN
blockdag/testdata/blk_3C.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3D.dat
vendored
BIN
blockdag/testdata/blk_3D.dat
vendored
Binary file not shown.
@ -13,7 +13,7 @@ import (
|
||||
func TestUTXODiffStore(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("TestUTXODiffStore", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TestUTXODiffStore: Failed to setup DAG instance: %v", err)
|
||||
|
@ -71,7 +71,7 @@ func TestSequenceLocksActive(t *testing.T) {
|
||||
func TestCheckConnectBlockTemplate(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("checkconnectblocktemplate", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Failed to setup dag instance: %v", err)
|
||||
@ -162,7 +162,7 @@ func TestCheckConnectBlockTemplate(t *testing.T) {
|
||||
func TestCheckBlockSanity(t *testing.T) {
|
||||
// Create a new database and dag instance to run tests against.
|
||||
dag, teardownFunc, err := DAGSetup("TestCheckBlockSanity", Config{
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Failed to setup dag instance: %v", err)
|
||||
@ -502,7 +502,7 @@ func TestCheckBlockSanity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPastMedianTime(t *testing.T) {
|
||||
dag := newTestDAG(&dagconfig.MainNetParams)
|
||||
dag := newTestDAG(&dagconfig.MainnetParams)
|
||||
tip := dag.genesis
|
||||
blockVersion := int32(0x10000000)
|
||||
|
||||
@ -571,7 +571,7 @@ func TestPastMedianTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateParents(t *testing.T) {
|
||||
dag := newTestDAG(&dagconfig.SimNetParams)
|
||||
dag := newTestDAG(&dagconfig.SimnetParams)
|
||||
genesisNode := dag.genesis
|
||||
blockVersion := int32(0x10000000)
|
||||
|
||||
|
@ -33,7 +33,7 @@ func buildNode(t *testing.T, dag *BlockDAG, parents blockSet) *blockNode {
|
||||
// TestVirtualBlock ensures that VirtualBlock works as expected.
|
||||
func TestVirtualBlock(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
dag, teardownFunc, err := DAGSetup("TestVirtualBlock", Config{
|
||||
DAGParams: ¶ms,
|
||||
@ -132,7 +132,7 @@ func TestVirtualBlock(t *testing.T) {
|
||||
|
||||
func TestSelectedPath(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
dag, teardownFunc, err := DAGSetup("TestSelectedPath", Config{
|
||||
DAGParams: ¶ms,
|
||||
@ -220,7 +220,7 @@ func TestSelectedPath(t *testing.T) {
|
||||
|
||||
func TestChainUpdates(t *testing.T) {
|
||||
// Create a new database and DAG instance to run tests against.
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.K = 1
|
||||
dag, teardownFunc, err := DAGSetup("TestChainUpdates", Config{
|
||||
DAGParams: ¶ms,
|
||||
|
@ -110,16 +110,16 @@ type ConfigFlags struct {
|
||||
|
||||
// normalizeAddress returns addr with the passed default port appended if
|
||||
// there is not already a port specified.
|
||||
func normalizeAddress(addr string, useTestNet, useSimNet, useDevNet bool) string {
|
||||
func normalizeAddress(addr string, useTestnet, useSimnet, useDevnet bool) string {
|
||||
_, _, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
var defaultPort string
|
||||
switch {
|
||||
case useDevNet:
|
||||
case useDevnet:
|
||||
defaultPort = "16610"
|
||||
case useTestNet:
|
||||
case useTestnet:
|
||||
defaultPort = "16210"
|
||||
case useSimNet:
|
||||
case useSimnet:
|
||||
defaultPort = "16510"
|
||||
default:
|
||||
defaultPort = "16110"
|
||||
@ -242,8 +242,8 @@ func loadConfig() (*ConfigFlags, []string, error) {
|
||||
|
||||
// Add default port to RPC server based on --testnet and --simnet flags
|
||||
// if needed.
|
||||
activeConfig.RPCServer = normalizeAddress(activeConfig.RPCServer, activeConfig.TestNet,
|
||||
activeConfig.SimNet, activeConfig.DevNet)
|
||||
activeConfig.RPCServer = normalizeAddress(activeConfig.RPCServer, activeConfig.Testnet,
|
||||
activeConfig.Simnet, activeConfig.Devnet)
|
||||
|
||||
return activeConfig, remainingArgs, nil
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ func loadConfig() (*Config, []string, error) {
|
||||
activeConfig = &Config{
|
||||
Flags: &cfgFlags,
|
||||
}
|
||||
if !(preCfg.RegressionTest || preCfg.SimNet) || preCfg.ConfigFile !=
|
||||
if !(preCfg.RegressionTest || preCfg.Simnet) || preCfg.ConfigFile !=
|
||||
defaultConfigFile {
|
||||
|
||||
if _, err := os.Stat(preCfg.ConfigFile); os.IsNotExist(err) {
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
|
||||
// NetworkFlags holds the network configuration, that is which network is selected.
|
||||
type NetworkFlags struct {
|
||||
TestNet bool `long:"testnet" description:"Use the test network"`
|
||||
Testnet bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Use the development test network"`
|
||||
Simnet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
Devnet bool `long:"devnet" description:"Use the development test network"`
|
||||
ActiveNetParams *dagconfig.Params
|
||||
}
|
||||
|
||||
@ -21,27 +21,27 @@ type NetworkFlags struct {
|
||||
// It returns error if more than one network was selected, nil otherwise.
|
||||
func (networkFlags *NetworkFlags) ResolveNetwork(parser *flags.Parser) error {
|
||||
//NetParams holds the selected network parameters. Default value is main-net.
|
||||
networkFlags.ActiveNetParams = &dagconfig.MainNetParams
|
||||
networkFlags.ActiveNetParams = &dagconfig.MainnetParams
|
||||
// Multiple networks can't be selected simultaneously.
|
||||
numNets := 0
|
||||
// default net is main net
|
||||
// Count number of network flags passed; assign active network params
|
||||
// while we're at it
|
||||
if networkFlags.TestNet {
|
||||
if networkFlags.Testnet {
|
||||
numNets++
|
||||
networkFlags.ActiveNetParams = &dagconfig.TestNetParams
|
||||
networkFlags.ActiveNetParams = &dagconfig.TestnetParams
|
||||
}
|
||||
if networkFlags.RegressionTest {
|
||||
numNets++
|
||||
networkFlags.ActiveNetParams = &dagconfig.RegressionNetParams
|
||||
}
|
||||
if networkFlags.SimNet {
|
||||
if networkFlags.Simnet {
|
||||
numNets++
|
||||
networkFlags.ActiveNetParams = &dagconfig.SimNetParams
|
||||
networkFlags.ActiveNetParams = &dagconfig.SimnetParams
|
||||
}
|
||||
if networkFlags.DevNet {
|
||||
if networkFlags.Devnet {
|
||||
numNets++
|
||||
networkFlags.ActiveNetParams = &dagconfig.DevNetParams
|
||||
networkFlags.ActiveNetParams = &dagconfig.DevnetParams
|
||||
}
|
||||
if numNets > 1 {
|
||||
message := "Multiple networks parameters (testnet, simnet, devnet, etc.) cannot be used" +
|
||||
|
@ -25,14 +25,14 @@ import (
|
||||
var testnet = flag.Bool("testnet", false, "operate on the testnet Kaspa network")
|
||||
|
||||
// By default (without --testnet), use mainnet.
|
||||
var dagParams = &dagconfig.MainNetParams
|
||||
var dagParams = &dagconfig.MainnetParams
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
// Modify active network parameters if operating on testnet.
|
||||
if *testnet {
|
||||
dagParams = &dagconfig.TestNetParams
|
||||
dagParams = &dagconfig.TestnetParams
|
||||
}
|
||||
|
||||
// later...
|
||||
|
@ -34,14 +34,14 @@ variable (either directly, or hidden in a library call).
|
||||
var testnet = flag.Bool("testnet", false, "operate on the testnet Kaspa network")
|
||||
|
||||
// By default (without --testnet), use mainnet.
|
||||
var dagParams = &dagconfig.MainNetParams
|
||||
var dagParams = &dagconfig.MainnetParams
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
// Modify active network parameters if operating on testnet.
|
||||
if *testnet {
|
||||
dagParams = &dagconfig.TestNetParams
|
||||
dagParams = &dagconfig.TestnetParams
|
||||
}
|
||||
|
||||
// later...
|
||||
|
@ -36,26 +36,26 @@ var genesisTxPayload = []byte{
|
||||
}
|
||||
|
||||
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||
// the main network, regression test network, and test network.
|
||||
// the main network.
|
||||
var genesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, genesisTxIns, genesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, genesisTxPayload)
|
||||
|
||||
// genesisHash is the hash of the first block in the block DAG for the main
|
||||
// network (genesis block).
|
||||
var genesisHash = daghash.Hash([daghash.HashSize]byte{
|
||||
var genesisHash = daghash.Hash{
|
||||
0x9b, 0x22, 0x59, 0x44, 0x66, 0xf0, 0xbe, 0x50,
|
||||
0x7c, 0x1c, 0x8a, 0xf6, 0x06, 0x27, 0xe6, 0x33,
|
||||
0x38, 0x7e, 0xd1, 0xd5, 0x8c, 0x42, 0x59, 0x1a,
|
||||
0x31, 0xac, 0x9a, 0xa6, 0x2e, 0xd5, 0x2b, 0x0f,
|
||||
})
|
||||
}
|
||||
|
||||
// genesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// for the main network.
|
||||
var genesisMerkleRoot = daghash.Hash([daghash.HashSize]byte{
|
||||
var genesisMerkleRoot = daghash.Hash{
|
||||
0x72, 0x10, 0x35, 0x85, 0xdd, 0xac, 0x82, 0x5c,
|
||||
0x49, 0x13, 0x9f, 0xc0, 0x0e, 0x37, 0xc0, 0x45,
|
||||
0x71, 0xdf, 0xd9, 0xf6, 0x36, 0xdf, 0x4c, 0x42,
|
||||
0x72, 0x7b, 0x9e, 0x86, 0xdd, 0x37, 0xd2, 0xbd,
|
||||
})
|
||||
}
|
||||
|
||||
// genesisBlock defines the genesis block of the block DAG which serves as the
|
||||
// public transaction ledger for the main network.
|
||||
@ -73,74 +73,242 @@ var genesisBlock = wire.MsgBlock{
|
||||
Transactions: []*wire.MsgTx{genesisCoinbaseTx},
|
||||
}
|
||||
|
||||
// regTestGenesisHash is the hash of the first block in the block DAG for the
|
||||
// regression test network (genesis block).
|
||||
var regTestGenesisHash = genesisHash
|
||||
var devnetGenesisTxIns = []*wire.TxIn{
|
||||
{
|
||||
PreviousOutpoint: wire.Outpoint{
|
||||
TxID: daghash.TxID{},
|
||||
Index: math.MaxUint32,
|
||||
},
|
||||
SignatureScript: []byte{
|
||||
0x00, 0x00, 0x0b, 0x2f, 0x50, 0x32, 0x53, 0x48,
|
||||
0x2f, 0x62, 0x74, 0x63, 0x64, 0x2f,
|
||||
},
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
}
|
||||
var devnetGenesisTxOuts = []*wire.TxOut{}
|
||||
|
||||
// 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
|
||||
// the main network.
|
||||
var regTestGenesisMerkleRoot = genesisMerkleRoot
|
||||
var devnetGenesisTxPayload = []byte{
|
||||
0x17, // Varint
|
||||
0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5, 0x49, // OP-TRUE p2sh
|
||||
0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71, 0xc7,
|
||||
0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x64, 0x65, 0x76, 0x6e, 0x65, 0x74, // kaspa-devnet
|
||||
}
|
||||
|
||||
// regTestGenesisBlock defines the genesis block of the block DAG which serves
|
||||
// as the public transaction ledger for the regression test network.
|
||||
var regTestGenesisBlock = genesisBlock
|
||||
|
||||
// testNetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// test network.
|
||||
var testNetGenesisHash = genesisHash
|
||||
|
||||
// testNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
// block for the test network. It is the same as the merkle root for the main
|
||||
// network.
|
||||
var testNetGenesisMerkleRoot = genesisMerkleRoot
|
||||
|
||||
// testNetGenesisBlock defines the genesis block of the block DAG which
|
||||
// serves as the public transaction ledger for the test network.
|
||||
var testNetGenesisBlock = genesisBlock
|
||||
|
||||
// simNetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// simulation test network.
|
||||
var simNetGenesisHash = genesisHash
|
||||
|
||||
// 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
|
||||
// the main network.
|
||||
var simNetGenesisMerkleRoot = genesisMerkleRoot
|
||||
|
||||
// simNetGenesisBlock defines the genesis block of the block DAG which serves
|
||||
// as the public transaction ledger for the simulation test network.
|
||||
var simNetGenesisBlock = genesisBlock
|
||||
|
||||
// devNetGenesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||
// the main network, regression test network, and test network.
|
||||
var devNetGenesisCoinbaseTx = genesisCoinbaseTx
|
||||
// devnetGenesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||
// the development network.
|
||||
var devnetGenesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, devnetGenesisTxIns, devnetGenesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, devnetGenesisTxPayload)
|
||||
|
||||
// devGenesisHash is the hash of the first block in the block DAG for the development
|
||||
// network (genesis block).
|
||||
var devNetGenesisHash = daghash.Hash([daghash.HashSize]byte{
|
||||
0xf4, 0xd6, 0x37, 0x0b, 0xc6, 0x67, 0x41, 0x90,
|
||||
0x06, 0x57, 0xef, 0x65, 0x45, 0x07, 0x3a, 0x50,
|
||||
0xb7, 0x85, 0x21, 0xb9, 0xa2, 0xe3, 0xf5, 0x9e,
|
||||
0xe0, 0x45, 0x9b, 0xb0, 0xab, 0x33, 0x00, 0x00,
|
||||
})
|
||||
var devnetGenesisHash = daghash.Hash{
|
||||
0x17, 0x59, 0x5c, 0x09, 0xdd, 0x1a, 0x51, 0x65,
|
||||
0x14, 0xbc, 0x19, 0xff, 0x29, 0xea, 0xf3, 0xcb,
|
||||
0xe2, 0x76, 0xf0, 0xc7, 0x86, 0xf8, 0x0c, 0x53,
|
||||
0x59, 0xbe, 0xee, 0x0c, 0x2b, 0x5d, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// devNetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// devnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// for the devopment network.
|
||||
var devNetGenesisMerkleRoot = genesisMerkleRoot
|
||||
var devnetGenesisMerkleRoot = daghash.Hash{
|
||||
0x16, 0x0a, 0xc6, 0x8b, 0x77, 0x08, 0xf4, 0x96,
|
||||
0xa3, 0x07, 0x05, 0xbc, 0x92, 0xda, 0xee, 0x73,
|
||||
0x26, 0x5e, 0xd0, 0x85, 0x78, 0xa2, 0x5d, 0x02,
|
||||
0x49, 0x8a, 0x2a, 0x22, 0xef, 0x41, 0xc9, 0xc3,
|
||||
}
|
||||
|
||||
// devNetGenesisBlock defines the genesis block of the block DAG which serves as the
|
||||
// devnetGenesisBlock defines the genesis block of the block DAG which serves as the
|
||||
// public transaction ledger for the development network.
|
||||
var devNetGenesisBlock = wire.MsgBlock{
|
||||
var devnetGenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{},
|
||||
HashMerkleRoot: &devNetGenesisMerkleRoot,
|
||||
HashMerkleRoot: &devnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: &daghash.Hash{},
|
||||
UTXOCommitment: &daghash.ZeroHash,
|
||||
Timestamp: time.Unix(0x5d021d3e, 0),
|
||||
Timestamp: time.Unix(0x5e15e758, 0),
|
||||
Bits: 0x1e7fffff,
|
||||
Nonce: 0x5221,
|
||||
Nonce: 0x282ac,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{devNetGenesisCoinbaseTx},
|
||||
Transactions: []*wire.MsgTx{devnetGenesisCoinbaseTx},
|
||||
}
|
||||
|
||||
var regtestGenesisTxIns = []*wire.TxIn{
|
||||
{
|
||||
PreviousOutpoint: wire.Outpoint{
|
||||
TxID: daghash.TxID{},
|
||||
Index: math.MaxUint32,
|
||||
},
|
||||
SignatureScript: []byte{
|
||||
0x00, 0x00, 0x0b, 0x2f, 0x50, 0x32, 0x53, 0x48,
|
||||
0x2f, 0x62, 0x74, 0x63, 0x64, 0x2f,
|
||||
},
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
}
|
||||
var regtestGenesisTxOuts = []*wire.TxOut{}
|
||||
|
||||
var regtestGenesisTxPayload = []byte{
|
||||
0x17, // Varint
|
||||
0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5, 0x49, // OP-TRUE p2sh
|
||||
0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71, 0xc7,
|
||||
0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x72, 0x65, 0x67, 0x74, 0x65, 0x73, 0x74, // kaspa-regtest
|
||||
}
|
||||
|
||||
// regtestGenesisCoinbaseTx is the coinbase transaction for
|
||||
// the genesis blocks for the regtest network.
|
||||
var regtestGenesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, regtestGenesisTxIns, regtestGenesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, regtestGenesisTxPayload)
|
||||
|
||||
// devGenesisHash is the hash of the first block in the block DAG for the development
|
||||
// network (genesis block).
|
||||
var regtestGenesisHash = daghash.Hash{
|
||||
0xfc, 0x02, 0x19, 0x6f, 0x79, 0x7a, 0xed, 0x2d,
|
||||
0x0f, 0x31, 0xa5, 0xbd, 0x32, 0x13, 0x29, 0xc7,
|
||||
0x7c, 0x0c, 0x5c, 0x1a, 0x5b, 0x7c, 0x20, 0x68,
|
||||
0xb7, 0xc9, 0x9f, 0x61, 0x13, 0x11, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// regtestGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// for the regtest.
|
||||
var regtestGenesisMerkleRoot = daghash.Hash{
|
||||
0x3a, 0x9f, 0x62, 0xc9, 0x2b, 0x16, 0x17, 0xb3,
|
||||
0x41, 0x6d, 0x9e, 0x2d, 0x87, 0x93, 0xfd, 0x72,
|
||||
0x77, 0x4d, 0x1d, 0x6f, 0x6d, 0x38, 0x5b, 0xf1,
|
||||
0x24, 0x1b, 0xdc, 0x96, 0xce, 0xbf, 0xa1, 0x09,
|
||||
}
|
||||
|
||||
// regtestGenesisBlock defines the genesis block of the block DAG which serves as the
|
||||
// public transaction ledger for the development network.
|
||||
var regtestGenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{},
|
||||
HashMerkleRoot: ®testGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: &daghash.Hash{},
|
||||
UTXOCommitment: &daghash.ZeroHash,
|
||||
Timestamp: time.Unix(0x5e15e2d8, 0),
|
||||
Bits: 0x1e7fffff,
|
||||
Nonce: 0x15a6,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{regtestGenesisCoinbaseTx},
|
||||
}
|
||||
|
||||
var simnetGenesisTxIns = []*wire.TxIn{
|
||||
{
|
||||
PreviousOutpoint: wire.Outpoint{
|
||||
TxID: daghash.TxID{},
|
||||
Index: math.MaxUint32,
|
||||
},
|
||||
SignatureScript: []byte{
|
||||
0x00, 0x00, 0x0b, 0x2f, 0x50, 0x32, 0x53, 0x48,
|
||||
0x2f, 0x62, 0x74, 0x63, 0x64, 0x2f,
|
||||
},
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
}
|
||||
var simnetGenesisTxOuts = []*wire.TxOut{}
|
||||
|
||||
var simnetGenesisTxPayload = []byte{
|
||||
0x17, // Varint
|
||||
0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5, 0x49, // OP-TRUE p2sh
|
||||
0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71, 0xc7,
|
||||
0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x73, 0x69, 0x6d, 0x6e, 0x65, 0x74, // kaspa-simnet
|
||||
}
|
||||
|
||||
// simnetGenesisCoinbaseTx is the coinbase transaction for the simnet genesis block.
|
||||
var simnetGenesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, simnetGenesisTxIns, simnetGenesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, simnetGenesisTxPayload)
|
||||
|
||||
// simnetGenesisHash is the hash of the first block in the block DAG for
|
||||
// the simnet (genesis block).
|
||||
var simnetGenesisHash = daghash.Hash{
|
||||
0xff, 0x69, 0xcc, 0x45, 0x45, 0x74, 0x5b, 0xf9,
|
||||
0xd5, 0x4e, 0x43, 0x56, 0x4f, 0x1b, 0xdf, 0x31,
|
||||
0x09, 0xb7, 0x76, 0xaa, 0x2a, 0x33, 0x35, 0xc9,
|
||||
0xa1, 0x80, 0xe0, 0x92, 0xbb, 0xae, 0xcd, 0x49,
|
||||
}
|
||||
|
||||
// simnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// for the devopment network.
|
||||
var simnetGenesisMerkleRoot = daghash.Hash{
|
||||
0xb0, 0x1c, 0x3b, 0x9e, 0x0d, 0x9a, 0xc0, 0x80,
|
||||
0x0a, 0x08, 0x42, 0x50, 0x02, 0xa3, 0xea, 0xdb,
|
||||
0xed, 0xc8, 0xd0, 0xad, 0x35, 0x03, 0xd8, 0x0e,
|
||||
0x11, 0x3c, 0x7b, 0xb2, 0xb5, 0x20, 0xe5, 0x84,
|
||||
}
|
||||
|
||||
// simnetGenesisBlock defines the genesis block of the block DAG which serves as the
|
||||
// public transaction ledger for the development network.
|
||||
var simnetGenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{},
|
||||
HashMerkleRoot: &simnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: &daghash.Hash{},
|
||||
UTXOCommitment: &daghash.ZeroHash,
|
||||
Timestamp: time.Unix(0x5e15d31c, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x3,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{simnetGenesisCoinbaseTx},
|
||||
}
|
||||
|
||||
var testnetGenesisTxIns = []*wire.TxIn{
|
||||
{
|
||||
PreviousOutpoint: wire.Outpoint{
|
||||
TxID: daghash.TxID{},
|
||||
Index: math.MaxUint32,
|
||||
},
|
||||
SignatureScript: []byte{
|
||||
0x00, 0x00, 0x0b, 0x2f, 0x50, 0x32, 0x53, 0x48,
|
||||
0x2f, 0x62, 0x74, 0x63, 0x64, 0x2f,
|
||||
},
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
}
|
||||
var testnetGenesisTxOuts = []*wire.TxOut{}
|
||||
|
||||
var testnetGenesisTxPayload = []byte{
|
||||
0x01, // Varint
|
||||
0x00, // OP-FALSE
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x6e, 0x65, 0x74, // kaspa-testnet
|
||||
}
|
||||
|
||||
// testnetGenesisCoinbaseTx is the coinbase transaction for the testnet genesis block.
|
||||
var testnetGenesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, testnetGenesisTxIns, testnetGenesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, testnetGenesisTxPayload)
|
||||
|
||||
// testnetGenesisHash is the hash of the first block in the block DAG for the test
|
||||
// network (genesis block).
|
||||
var testnetGenesisHash = daghash.Hash{
|
||||
0x22, 0x15, 0x34, 0xa9, 0xff, 0x10, 0xdd, 0x47,
|
||||
0xcd, 0x21, 0x11, 0x25, 0xc5, 0x6d, 0x85, 0x9a,
|
||||
0x97, 0xc8, 0x63, 0x63, 0x79, 0x40, 0x80, 0x04,
|
||||
0x74, 0xe6, 0x29, 0x7b, 0xbc, 0x08, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// testnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// for testnet.
|
||||
var testnetGenesisMerkleRoot = daghash.Hash{
|
||||
0x88, 0x05, 0xd0, 0xe7, 0x8f, 0x41, 0x77, 0x39,
|
||||
0x2c, 0xb6, 0xbb, 0xb4, 0x19, 0xa8, 0x48, 0x4a,
|
||||
0xdf, 0x77, 0xb0, 0x82, 0xd6, 0x70, 0xd8, 0x24,
|
||||
0x6a, 0x36, 0x05, 0xaa, 0xbd, 0x7a, 0xd1, 0x62,
|
||||
}
|
||||
|
||||
// testnetGenesisBlock defines the genesis block of the block DAG which serves as the
|
||||
// public transaction ledger for testnet.
|
||||
var testnetGenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{},
|
||||
HashMerkleRoot: &testnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: &daghash.ZeroHash,
|
||||
UTXOCommitment: &daghash.ZeroHash,
|
||||
Timestamp: time.Unix(0x5e15adfe, 0),
|
||||
Bits: 0x1e7fffff,
|
||||
Nonce: 0x20a1,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{testnetGenesisCoinbaseTx},
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
func TestGenesisBlock(t *testing.T) {
|
||||
// Encode the genesis block to raw bytes.
|
||||
var buf bytes.Buffer
|
||||
err := MainNetParams.GenesisBlock.Serialize(&buf)
|
||||
err := MainnetParams.GenesisBlock.Serialize(&buf)
|
||||
if err != nil {
|
||||
t.Fatalf("TestGenesisBlock: %v", err)
|
||||
}
|
||||
@ -29,97 +29,124 @@ func TestGenesisBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
// Check hash of the block against expected hash.
|
||||
hash := MainNetParams.GenesisBlock.BlockHash()
|
||||
if !MainNetParams.GenesisHash.IsEqual(hash) {
|
||||
hash := MainnetParams.GenesisBlock.BlockHash()
|
||||
if !MainnetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestGenesisBlock: Genesis block hash does not "+
|
||||
"appear valid - got %v, want %v", spew.Sdump(hash),
|
||||
spew.Sdump(MainNetParams.GenesisHash))
|
||||
spew.Sdump(MainnetParams.GenesisHash))
|
||||
}
|
||||
}
|
||||
|
||||
// TestRegTestGenesisBlock tests the genesis block of the regression test
|
||||
// TestRegtestGenesisBlock tests the genesis block of the regression test
|
||||
// network for validity by checking the encoded bytes and hashes.
|
||||
func TestRegTestGenesisBlock(t *testing.T) {
|
||||
func TestRegtestGenesisBlock(t *testing.T) {
|
||||
// Encode the genesis block to raw bytes.
|
||||
var buf bytes.Buffer
|
||||
err := RegressionNetParams.GenesisBlock.Serialize(&buf)
|
||||
if err != nil {
|
||||
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 "+
|
||||
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))
|
||||
spew.Sdump(regtestGenesisBlockBytes))
|
||||
}
|
||||
|
||||
// Check hash of the block against expected hash.
|
||||
hash := RegressionNetParams.GenesisBlock.BlockHash()
|
||||
if !RegressionNetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestRegTestGenesisBlock: Genesis block hash does "+
|
||||
t.Fatalf("TestRegtestGenesisBlock: Genesis block hash does "+
|
||||
"not appear valid - got %v, want %v", spew.Sdump(hash),
|
||||
spew.Sdump(RegressionNetParams.GenesisHash))
|
||||
}
|
||||
}
|
||||
|
||||
// TestTestNetGenesisBlock tests the genesis block of the test network for
|
||||
// TestTestnetGenesisBlock tests the genesis block of the test network for
|
||||
// validity by checking the encoded bytes and hashes.
|
||||
func TestTestNetGenesisBlock(t *testing.T) {
|
||||
func TestTestnetGenesisBlock(t *testing.T) {
|
||||
// Encode the genesis block to raw bytes.
|
||||
var buf bytes.Buffer
|
||||
err := TestNetParams.GenesisBlock.Serialize(&buf)
|
||||
err := TestnetParams.GenesisBlock.Serialize(&buf)
|
||||
if err != nil {
|
||||
t.Fatalf("TestTestNetGenesisBlock: %v", err)
|
||||
t.Fatalf("TestTestnetGenesisBlock: %v", err)
|
||||
}
|
||||
|
||||
// Ensure the encoded block matches the expected bytes.
|
||||
if !bytes.Equal(buf.Bytes(), testNetGenesisBlockBytes) {
|
||||
t.Fatalf("TestTestNetGenesisBlock: Genesis block does not "+
|
||||
if !bytes.Equal(buf.Bytes(), testnetGenesisBlockBytes) {
|
||||
t.Fatalf("TestTestnetGenesisBlock: Genesis block does not "+
|
||||
"appear valid - got %v, want %v",
|
||||
spew.Sdump(buf.Bytes()),
|
||||
spew.Sdump(testNetGenesisBlockBytes))
|
||||
spew.Sdump(testnetGenesisBlockBytes))
|
||||
}
|
||||
|
||||
// Check hash of the block against expected hash.
|
||||
hash := TestNetParams.GenesisBlock.BlockHash()
|
||||
if !TestNetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestTestNetGenesisBlock: Genesis block hash does "+
|
||||
hash := TestnetParams.GenesisBlock.BlockHash()
|
||||
if !TestnetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestTestnetGenesisBlock: Genesis block hash does "+
|
||||
"not appear valid - got %v, want %v", spew.Sdump(hash),
|
||||
spew.Sdump(TestNetParams.GenesisHash))
|
||||
spew.Sdump(TestnetParams.GenesisHash))
|
||||
}
|
||||
}
|
||||
|
||||
// TestSimNetGenesisBlock tests the genesis block of the simulation test network
|
||||
// TestSimnetGenesisBlock tests the genesis block of the simulation test network
|
||||
// for validity by checking the encoded bytes and hashes.
|
||||
func TestSimNetGenesisBlock(t *testing.T) {
|
||||
func TestSimnetGenesisBlock(t *testing.T) {
|
||||
// Encode the genesis block to raw bytes.
|
||||
var buf bytes.Buffer
|
||||
err := SimNetParams.GenesisBlock.Serialize(&buf)
|
||||
err := SimnetParams.GenesisBlock.Serialize(&buf)
|
||||
if err != nil {
|
||||
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 "+
|
||||
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))
|
||||
spew.Sdump(simnetGenesisBlockBytes))
|
||||
}
|
||||
|
||||
// Check hash of the block against expected hash.
|
||||
hash := SimNetParams.GenesisBlock.BlockHash()
|
||||
if !SimNetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestSimNetGenesisBlock: Genesis block hash does "+
|
||||
hash := SimnetParams.GenesisBlock.BlockHash()
|
||||
if !SimnetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestSimnetGenesisBlock: Genesis block hash does "+
|
||||
"not appear valid - got %v, want %v", spew.Sdump(hash),
|
||||
spew.Sdump(SimNetParams.GenesisHash))
|
||||
spew.Sdump(SimnetParams.GenesisHash))
|
||||
}
|
||||
}
|
||||
|
||||
// TestDevnetGenesisBlock tests the genesis block of the development network
|
||||
// for validity by checking the encoded bytes and hashes.
|
||||
func TestDevnetGenesisBlock(t *testing.T) {
|
||||
// Encode the genesis block to raw bytes.
|
||||
var buf bytes.Buffer
|
||||
err := DevnetParams.GenesisBlock.Serialize(&buf)
|
||||
if err != nil {
|
||||
t.Fatalf("TestDevnetGenesisBlock: %v", err)
|
||||
}
|
||||
|
||||
// Ensure the encoded block matches the expected bytes.
|
||||
if !bytes.Equal(buf.Bytes(), devnetGenesisBlockBytes) {
|
||||
t.Fatalf("TestDevnetGenesisBlock: 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.
|
||||
hash := DevnetParams.GenesisBlock.BlockHash()
|
||||
if !DevnetParams.GenesisHash.IsEqual(hash) {
|
||||
t.Fatalf("TestDevnetGenesisBlock: Genesis block hash does "+
|
||||
"not appear valid - got %v, want %v", spew.Sdump(hash),
|
||||
spew.Sdump(DevnetParams.GenesisHash))
|
||||
}
|
||||
}
|
||||
|
||||
// genesisBlockBytes are the wire encoded bytes for the genesis block of the
|
||||
// main network as of protocol version 60002.
|
||||
// main network as of protocol version 1.
|
||||
var genesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x72, 0x10, 0x35, 0x85, 0xdd, 0xac, 0x82, 0x5c, 0x49, 0x13, 0x9f,
|
||||
0xc0, 0x0e, 0x37, 0xc0, 0x45, 0x71, 0xdf, 0xd9, 0xf6, 0x36, 0xdf, 0x4c, 0x42, 0x72, 0x7b, 0x9e,
|
||||
@ -141,14 +168,167 @@ var genesisBlockBytes = []byte{
|
||||
0xc7, 0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
}
|
||||
|
||||
// regTestGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the regression test network as of protocol version 60002.
|
||||
var regTestGenesisBlockBytes = genesisBlockBytes
|
||||
// regtestGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the regression test network as of protocol version 1.
|
||||
var regtestGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x9f, 0x62,
|
||||
0xc9, 0x2b, 0x16, 0x17, 0xb3, 0x41, 0x6d, 0x9e,
|
||||
0x2d, 0x87, 0x93, 0xfd, 0x72, 0x77, 0x4d, 0x1d,
|
||||
0x6f, 0x6d, 0x38, 0x5b, 0xf1, 0x24, 0x1b, 0xdc,
|
||||
0x96, 0xce, 0xbf, 0xa1, 0x09, 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,
|
||||
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, 0xd8, 0xe2, 0x15,
|
||||
0x5e, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
||||
0x1e, 0xa6, 0x15, 0x00, 0x00, 0x00, 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, 0x0e, 0x00, 0x00, 0x0b, 0x2f,
|
||||
0x50, 0x32, 0x53, 0x48, 0x2f, 0x62, 0x74, 0x63,
|
||||
0x64, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
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, 0xed,
|
||||
0x32, 0xec, 0xb4, 0xf8, 0x3c, 0x7a, 0x32, 0x0f,
|
||||
0xd2, 0xe5, 0x24, 0x77, 0x89, 0x43, 0x3a, 0x78,
|
||||
0x0a, 0xda, 0x68, 0x2d, 0xf6, 0xaa, 0xb1, 0x19,
|
||||
0xdd, 0xd8, 0x97, 0x15, 0x4b, 0xcb, 0x42, 0x25,
|
||||
0x17, 0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5,
|
||||
0x49, 0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71,
|
||||
0xc7, 0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x72, 0x65,
|
||||
0x67, 0x74, 0x65, 0x73, 0x74,
|
||||
}
|
||||
|
||||
// testNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the test network as of protocol version 60002.
|
||||
var testNetGenesisBlockBytes = genesisBlockBytes
|
||||
// testnetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the test network as of protocol version 1.
|
||||
var testnetGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x88, 0x05, 0xd0,
|
||||
0xe7, 0x8f, 0x41, 0x77, 0x39, 0x2c, 0xb6, 0xbb,
|
||||
0xb4, 0x19, 0xa8, 0x48, 0x4a, 0xdf, 0x77, 0xb0,
|
||||
0x82, 0xd6, 0x70, 0xd8, 0x24, 0x6a, 0x36, 0x05,
|
||||
0xaa, 0xbd, 0x7a, 0xd1, 0x62, 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,
|
||||
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, 0xfe, 0xad, 0x15,
|
||||
0x5e, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
||||
0x1e, 0xa1, 0x20, 0x00, 0x00, 0x00, 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, 0x0e, 0x00, 0x00, 0x0b, 0x2f,
|
||||
0x50, 0x32, 0x53, 0x48, 0x2f, 0x62, 0x74, 0x63,
|
||||
0x64, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
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, 0xcc,
|
||||
0x72, 0xe6, 0x7e, 0x37, 0xa1, 0x34, 0x89, 0x23,
|
||||
0x24, 0xaf, 0xae, 0x99, 0x1f, 0x89, 0x09, 0x41,
|
||||
0x1a, 0x4d, 0x58, 0xfe, 0x5a, 0x04, 0xb0, 0x3e,
|
||||
0xeb, 0x1b, 0x5b, 0xb8, 0x65, 0xa8, 0x65, 0x0f,
|
||||
0x01, 0x00, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d,
|
||||
0x74, 0x65, 0x73, 0x74, 0x6e, 0x65, 0x74,
|
||||
}
|
||||
|
||||
// simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the simulation test network as of protocol version 70002.
|
||||
var simNetGenesisBlockBytes = genesisBlockBytes
|
||||
// simnetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the simulation test network as of protocol version 1.
|
||||
var simnetGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x1c, 0x3b,
|
||||
0x9e, 0x0d, 0x9a, 0xc0, 0x80, 0x0a, 0x08, 0x42,
|
||||
0x50, 0x02, 0xa3, 0xea, 0xdb, 0xed, 0xc8, 0xd0,
|
||||
0xad, 0x35, 0x03, 0xd8, 0x0e, 0x11, 0x3c, 0x7b,
|
||||
0xb2, 0xb5, 0x20, 0xe5, 0x84, 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,
|
||||
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, 0x1c, 0xd3, 0x15,
|
||||
0x5e, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
||||
0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 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, 0x0e, 0x00, 0x00, 0x0b, 0x2f,
|
||||
0x50, 0x32, 0x53, 0x48, 0x2f, 0x62, 0x74, 0x63,
|
||||
0x64, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
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, 0x89,
|
||||
0x48, 0xd3, 0x23, 0x9c, 0xf9, 0x88, 0x2b, 0x63,
|
||||
0xc7, 0x33, 0x0f, 0xa3, 0x64, 0xf2, 0xdb, 0x39,
|
||||
0x73, 0x5f, 0x2b, 0xa8, 0xd5, 0x7b, 0x5c, 0x31,
|
||||
0x68, 0xc9, 0x63, 0x37, 0x5c, 0xe7, 0x41, 0x24,
|
||||
0x17, 0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5,
|
||||
0x49, 0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71,
|
||||
0xc7, 0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x73, 0x69,
|
||||
0x6d, 0x6e, 0x65, 0x74,
|
||||
}
|
||||
|
||||
// devnetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the development network as of protocol version 1.
|
||||
var devnetGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0a, 0xc6,
|
||||
0x8b, 0x77, 0x08, 0xf4, 0x96, 0xa3, 0x07, 0x05,
|
||||
0xbc, 0x92, 0xda, 0xee, 0x73, 0x26, 0x5e, 0xd0,
|
||||
0x85, 0x78, 0xa2, 0x5d, 0x02, 0x49, 0x8a, 0x2a,
|
||||
0x22, 0xef, 0x41, 0xc9, 0xc3, 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,
|
||||
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, 0x58, 0xe7, 0x15,
|
||||
0x5e, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
||||
0x1e, 0xac, 0x82, 0x02, 0x00, 0x00, 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, 0x0e, 0x00, 0x00, 0x0b, 0x2f,
|
||||
0x50, 0x32, 0x53, 0x48, 0x2f, 0x62, 0x74, 0x63,
|
||||
0x64, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
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, 0x11,
|
||||
0xc7, 0x0c, 0x02, 0x9e, 0xb2, 0x2e, 0xb3, 0xad,
|
||||
0x24, 0x10, 0xfe, 0x2c, 0xdb, 0x8e, 0x1d, 0xde,
|
||||
0x81, 0x5b, 0xbb, 0x42, 0xfe, 0xb4, 0x93, 0xd6,
|
||||
0xe3, 0xbe, 0x86, 0x02, 0xe6, 0x3a, 0x65, 0x24,
|
||||
0x17, 0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5,
|
||||
0x49, 0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71,
|
||||
0xc7, 0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x64, 0x65,
|
||||
0x76, 0x6e, 0x65, 0x74,
|
||||
}
|
||||
|
@ -33,18 +33,18 @@ var (
|
||||
// can have for the regression test network. It is the value 2^255 - 1.
|
||||
regressionPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// testNetPowMax is the highest proof of work value a Kaspa block
|
||||
// testnetPowMax is the highest proof of work value a Kaspa block
|
||||
// can have for the test network. It is the value 2^255 - 1.
|
||||
testNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
testnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// simNetPowMax is the highest proof of work value a Kaspa block
|
||||
// simnetPowMax is the highest proof of work value a Kaspa block
|
||||
// can have for the simulation test network. It is the value 2^255 - 1.
|
||||
simNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
simnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// devNetPowMax is the highest proof of work value a Kaspa block
|
||||
// devnetPowMax is the highest proof of work value a Kaspa block
|
||||
// can have for the development network. It is the value
|
||||
// 2^239 - 1.
|
||||
devNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
|
||||
devnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
|
||||
)
|
||||
|
||||
const ghostdagK = 10
|
||||
@ -178,11 +178,11 @@ type Params struct {
|
||||
HDCoinType uint32
|
||||
}
|
||||
|
||||
// MainNetParams defines the network parameters for the main Kaspa network.
|
||||
var MainNetParams = Params{
|
||||
// MainnetParams defines the network parameters for the main Kaspa network.
|
||||
var MainnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "mainnet",
|
||||
Net: wire.MainNet,
|
||||
Net: wire.Mainnet,
|
||||
RPCPort: "16110",
|
||||
DefaultPort: "16111",
|
||||
DNSSeeds: []string{"dnsseed.kas.pa"},
|
||||
@ -227,7 +227,7 @@ var MainNetParams = Params{
|
||||
PrivateKeyID: 0x80, // starts with 5 (uncompressed) or K (compressed)
|
||||
|
||||
// BIP32 hierarchical deterministic extended key magics
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairMainNet,
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairMainnet,
|
||||
|
||||
// BIP44 coin type used in the hierarchical deterministic path for
|
||||
// address generation.
|
||||
@ -240,14 +240,14 @@ var MainNetParams = Params{
|
||||
var RegressionNetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "regtest",
|
||||
Net: wire.RegTest,
|
||||
Net: wire.Regtest,
|
||||
RPCPort: "16210",
|
||||
DefaultPort: "16211",
|
||||
DNSSeeds: []string{},
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: ®TestGenesisBlock,
|
||||
GenesisHash: ®TestGenesisHash,
|
||||
GenesisBlock: ®testGenesisBlock,
|
||||
GenesisHash: ®testGenesisHash,
|
||||
PowMax: regressionPowMax,
|
||||
BlockCoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 150,
|
||||
@ -292,19 +292,19 @@ var RegressionNetParams = Params{
|
||||
HDCoinType: 1,
|
||||
}
|
||||
|
||||
// TestNetParams defines the network parameters for the test Kaspa network.
|
||||
var TestNetParams = Params{
|
||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||
var TestnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "testnet",
|
||||
Net: wire.TestNet,
|
||||
Net: wire.Testnet,
|
||||
RPCPort: "16210",
|
||||
DefaultPort: "16211",
|
||||
DNSSeeds: []string{"testnet-dnsseed.kas.pa"},
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: &testNetGenesisBlock,
|
||||
GenesisHash: &testNetGenesisHash,
|
||||
PowMax: testNetPowMax,
|
||||
GenesisBlock: &testnetGenesisBlock,
|
||||
GenesisHash: &testnetGenesisHash,
|
||||
PowMax: testnetPowMax,
|
||||
BlockCoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
TargetTimePerBlock: time.Second * 1, // 1 second
|
||||
@ -341,32 +341,32 @@ var TestNetParams = Params{
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
|
||||
// BIP32 hierarchical deterministic extended key magics
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairTestNet,
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairTestnet,
|
||||
|
||||
// BIP44 coin type used in the hierarchical deterministic path for
|
||||
// address generation.
|
||||
HDCoinType: 1,
|
||||
}
|
||||
|
||||
// SimNetParams defines the network parameters for the simulation test Kaspa
|
||||
// SimnetParams defines the network parameters for the simulation test Kaspa
|
||||
// network. This network is similar to the normal test network except it is
|
||||
// intended for private use within a group of individuals doing simulation
|
||||
// testing. The functionality is intended to differ in that the only nodes
|
||||
// which are specifically specified are used to create the network rather than
|
||||
// following normal discovery rules. This is important as otherwise it would
|
||||
// just turn into another public testnet.
|
||||
var SimNetParams = Params{
|
||||
var SimnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "simnet",
|
||||
Net: wire.SimNet,
|
||||
Net: wire.Simnet,
|
||||
RPCPort: "16510",
|
||||
DefaultPort: "16511",
|
||||
DNSSeeds: []string{}, // NOTE: There must NOT be any seeds.
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: &simNetGenesisBlock,
|
||||
GenesisHash: &simNetGenesisHash,
|
||||
PowMax: simNetPowMax,
|
||||
GenesisBlock: &simnetGenesisBlock,
|
||||
GenesisHash: &simnetGenesisHash,
|
||||
PowMax: simnetPowMax,
|
||||
BlockCoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
TargetTimePerBlock: time.Second * 1, // 1 second
|
||||
@ -401,26 +401,26 @@ var SimNetParams = Params{
|
||||
Prefix: util.Bech32PrefixKaspaSim,
|
||||
|
||||
// BIP32 hierarchical deterministic extended key magics
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairSimNet,
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairSimnet,
|
||||
|
||||
// BIP44 coin type used in the hierarchical deterministic path for
|
||||
// address generation.
|
||||
HDCoinType: 115, // ASCII for s
|
||||
}
|
||||
|
||||
// DevNetParams defines the network parameters for the development Kaspa network.
|
||||
var DevNetParams = Params{
|
||||
// DevnetParams defines the network parameters for the development Kaspa network.
|
||||
var DevnetParams = Params{
|
||||
K: ghostdagK,
|
||||
Name: "devnet",
|
||||
Net: wire.DevNet,
|
||||
Net: wire.Devnet,
|
||||
RPCPort: "16610",
|
||||
DefaultPort: "16611",
|
||||
DNSSeeds: []string{}, // NOTE: There must NOT be any seeds.
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: &devNetGenesisBlock,
|
||||
GenesisHash: &devNetGenesisHash,
|
||||
PowMax: devNetPowMax,
|
||||
GenesisBlock: &devnetGenesisBlock,
|
||||
GenesisHash: &devnetGenesisHash,
|
||||
PowMax: devnetPowMax,
|
||||
BlockCoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
TargetTimePerBlock: time.Second * 1, // 1 second
|
||||
@ -457,7 +457,7 @@ var DevNetParams = Params{
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
|
||||
// BIP32 hierarchical deterministic extended key magics
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairDevNet,
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairDevnet,
|
||||
|
||||
// BIP44 coin type used in the hierarchical deterministic path for
|
||||
// address generation.
|
||||
@ -522,8 +522,8 @@ func newHashFromStr(hexStr string) *daghash.Hash {
|
||||
|
||||
func init() {
|
||||
// Register all default networks when the package is initialized.
|
||||
mustRegister(&MainNetParams)
|
||||
mustRegister(&TestNetParams)
|
||||
mustRegister(&MainnetParams)
|
||||
mustRegister(&TestnetParams)
|
||||
mustRegister(&RegressionNetParams)
|
||||
mustRegister(&SimNetParams)
|
||||
mustRegister(&SimnetParams)
|
||||
}
|
||||
|
@ -55,5 +55,5 @@ func TestMustRegisterPanic(t *testing.T) {
|
||||
}()
|
||||
|
||||
// Intentionally try to register duplicate params to force a panic.
|
||||
mustRegister(&MainNetParams)
|
||||
mustRegister(&MainnetParams)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func TestRegister(t *testing.T) {
|
||||
register: []registerTest{
|
||||
{
|
||||
name: "duplicate mainnet",
|
||||
params: &MainNetParams,
|
||||
params: &MainnetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
@ -53,24 +53,24 @@ func TestRegister(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "duplicate testnet",
|
||||
params: &TestNetParams,
|
||||
params: &TestnetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
name: "duplicate simnet",
|
||||
params: &SimNetParams,
|
||||
params: &SimnetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
},
|
||||
hdMagics: []hdTest{
|
||||
{
|
||||
priv: MainNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: MainNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: MainnetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: MainnetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
priv: TestNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: TestnetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestnetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@ -79,8 +79,8 @@ func TestRegister(t *testing.T) {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
priv: SimNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: SimNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: SimnetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: SimnetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@ -119,7 +119,7 @@ func TestRegister(t *testing.T) {
|
||||
register: []registerTest{
|
||||
{
|
||||
name: "duplicate mainnet",
|
||||
params: &MainNetParams,
|
||||
params: &MainnetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
@ -129,12 +129,12 @@ func TestRegister(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "duplicate testnet",
|
||||
params: &TestNetParams,
|
||||
params: &TestnetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
name: "duplicate simnet",
|
||||
params: &SimNetParams,
|
||||
params: &SimnetParams,
|
||||
err: ErrDuplicateNet,
|
||||
},
|
||||
{
|
||||
@ -145,13 +145,13 @@ func TestRegister(t *testing.T) {
|
||||
},
|
||||
hdMagics: []hdTest{
|
||||
{
|
||||
priv: MainNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: MainNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: MainnetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: MainnetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
priv: TestNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: TestnetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: TestnetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@ -160,8 +160,8 @@ func TestRegister(t *testing.T) {
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
priv: SimNetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: SimNetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
priv: SimnetParams.HDKeyIDPair.PrivateKeyID[:],
|
||||
want: SimnetParams.HDKeyIDPair.PublicKeyID[:],
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
@ -182,15 +182,15 @@ func TestRegister(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
for _, regTest := range test.register {
|
||||
err := Register(regTest.params)
|
||||
for _, regtest := range test.register {
|
||||
err := Register(regtest.params)
|
||||
|
||||
// HDKeyIDPairs must be registered separately
|
||||
hdkeychain.RegisterHDKeyIDPair(regTest.params.HDKeyIDPair)
|
||||
hdkeychain.RegisterHDKeyIDPair(regtest.params.HDKeyIDPair)
|
||||
|
||||
if err != regTest.err {
|
||||
if err != regtest.err {
|
||||
t.Errorf("%s:%s: Registered network with unexpected error: got %v expected %v",
|
||||
test.name, regTest.name, err, regTest.err)
|
||||
test.name, regtest.name, err, regtest.err)
|
||||
}
|
||||
}
|
||||
for i, magTest := range test.hdMagics {
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
var (
|
||||
kaspadHomeDir = util.AppDataDir("kaspad", false)
|
||||
knownDbTypes = database.SupportedDrivers()
|
||||
activeNetParams = &dagconfig.MainNetParams
|
||||
activeNetParams = &dagconfig.MainnetParams
|
||||
|
||||
// Default global config.
|
||||
cfg = &config{
|
||||
@ -32,10 +32,10 @@ var (
|
||||
type config struct {
|
||||
DataDir string `short:"b" long:"datadir" description:"Location of the kaspad data directory"`
|
||||
DbType string `long:"dbtype" description:"Database backend to use for the Block DAG"`
|
||||
TestNet bool `long:"testnet" description:"Use the test network"`
|
||||
Testnet bool `long:"testnet" description:"Use the test network"`
|
||||
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
|
||||
SimNet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
DevNet bool `long:"devnet" description:"Use the development test network"`
|
||||
Simnet bool `long:"simnet" description:"Use the simulation test network"`
|
||||
Devnet bool `long:"devnet" description:"Use the development test network"`
|
||||
}
|
||||
|
||||
// fileExists reports whether the named file or directory exists.
|
||||
@ -67,21 +67,21 @@ func setupGlobalConfig() error {
|
||||
// Count number of network flags passed; assign active network params
|
||||
// while we're at it
|
||||
numNets := 0
|
||||
if cfg.TestNet {
|
||||
if cfg.Testnet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.TestNetParams
|
||||
activeNetParams = &dagconfig.TestnetParams
|
||||
}
|
||||
if cfg.RegressionTest {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.RegressionNetParams
|
||||
}
|
||||
if cfg.SimNet {
|
||||
if cfg.Simnet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.SimNetParams
|
||||
activeNetParams = &dagconfig.SimnetParams
|
||||
}
|
||||
if cfg.DevNet {
|
||||
if cfg.Devnet {
|
||||
numNets++
|
||||
activeNetParams = &dagconfig.DevNetParams
|
||||
activeNetParams = &dagconfig.DevnetParams
|
||||
}
|
||||
if numNets > 1 {
|
||||
return errors.New("The testnet, regtest, simnet and devnet params " +
|
||||
|
@ -32,7 +32,7 @@ func ExampleCreate() {
|
||||
// this, nor put it in the temp directory, but it's done here to ensure
|
||||
// the example cleans up after itself.
|
||||
dbPath := filepath.Join(os.TempDir(), "examplecreate")
|
||||
db, err := database.Create("ffldb", dbPath, wire.MainNet)
|
||||
db, err := database.Create("ffldb", dbPath, wire.Mainnet)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@ -60,7 +60,7 @@ func Example_basicUsage() {
|
||||
dbPath := filepath.Join(os.TempDir(), "exampleusage")
|
||||
// ensure that DB does not exist before test starts
|
||||
os.RemoveAll(dbPath)
|
||||
db, err := database.Create("ffldb", dbPath, wire.MainNet)
|
||||
db, err := database.Create("ffldb", dbPath, wire.Mainnet)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@ -126,7 +126,7 @@ func Example_blockStorageAndRetrieval() {
|
||||
// this, nor put it in the temp directory, but it's done here to ensure
|
||||
// the example cleans up after itself.
|
||||
dbPath := filepath.Join(os.TempDir(), "exampleblkstorage")
|
||||
db, err := database.Create("ffldb", dbPath, wire.MainNet)
|
||||
db, err := database.Create("ffldb", dbPath, wire.Mainnet)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@ -138,7 +138,7 @@ func Example_blockStorageAndRetrieval() {
|
||||
// read-write transaction and store a genesis block in the database as
|
||||
// and example.
|
||||
err = db.Update(func(dbTx database.Tx) error {
|
||||
genesisBlock := dagconfig.MainNetParams.GenesisBlock
|
||||
genesisBlock := dagconfig.MainnetParams.GenesisBlock
|
||||
return dbTx.StoreBlock(util.NewBlock(genesisBlock))
|
||||
})
|
||||
if err != nil {
|
||||
@ -150,7 +150,7 @@ func Example_blockStorageAndRetrieval() {
|
||||
// transaction and fetch the block stored above.
|
||||
var loadedBlockBytes []byte
|
||||
err = db.Update(func(dbTx database.Tx) error {
|
||||
genesisHash := dagconfig.MainNetParams.GenesisHash
|
||||
genesisHash := dagconfig.MainnetParams.GenesisHash
|
||||
blockBytes, err := dbTx.FetchBlock(genesisHash)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -19,14 +19,14 @@ of "ffldb". The parameters the Open and Create functions take are the
|
||||
database path as a string and the block network.
|
||||
|
||||
```Go
|
||||
db, err := database.Open("ffldb", "path/to/database", wire.MainNet)
|
||||
db, err := database.Open("ffldb", "path/to/database", wire.Mainnet)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
```Go
|
||||
db, err := database.Create("ffldb", "path/to/database", wire.MainNet)
|
||||
db, err := database.Create("ffldb", "path/to/database", wire.Mainnet)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ func BenchmarkBlockHeader(b *testing.B) {
|
||||
defer os.RemoveAll(dbPath)
|
||||
defer db.Close()
|
||||
err = db.Update(func(dbTx database.Tx) error {
|
||||
block := util.NewBlock(dagconfig.MainNetParams.GenesisBlock)
|
||||
block := util.NewBlock(dagconfig.MainnetParams.GenesisBlock)
|
||||
return dbTx.StoreBlock(block)
|
||||
})
|
||||
if err != nil {
|
||||
@ -38,7 +38,7 @@ func BenchmarkBlockHeader(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
err = db.View(func(dbTx database.Tx) error {
|
||||
blockHash := dagconfig.MainNetParams.GenesisHash
|
||||
blockHash := dagconfig.MainnetParams.GenesisHash
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := dbTx.FetchBlockHeader(blockHash)
|
||||
if err != nil {
|
||||
@ -69,7 +69,7 @@ func BenchmarkBlock(b *testing.B) {
|
||||
defer os.RemoveAll(dbPath)
|
||||
defer db.Close()
|
||||
err = db.Update(func(dbTx database.Tx) error {
|
||||
block := util.NewBlock(dagconfig.MainNetParams.GenesisBlock)
|
||||
block := util.NewBlock(dagconfig.MainnetParams.GenesisBlock)
|
||||
return dbTx.StoreBlock(block)
|
||||
})
|
||||
if err != nil {
|
||||
@ -79,7 +79,7 @@ func BenchmarkBlock(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
err = db.View(func(dbTx database.Tx) error {
|
||||
blockHash := dagconfig.MainNetParams.GenesisHash
|
||||
blockHash := dagconfig.MainnetParams.GenesisHash
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := dbTx.FetchBlock(blockHash)
|
||||
if err != nil {
|
||||
|
@ -19,7 +19,7 @@ func newTestDb(testName string, t *testing.T) *db {
|
||||
t.Fatalf("%s: Error deleting database folder before starting: %s", testName, err)
|
||||
}
|
||||
|
||||
network := wire.SimNet
|
||||
network := wire.Simnet
|
||||
|
||||
opts := opt.Options{
|
||||
ErrorIfExist: true,
|
||||
|
@ -12,12 +12,12 @@ This package is a driver to the database package and provides the database type
|
||||
of "ffldb". The parameters the Open and Create functions take are the
|
||||
database path as a string and the block network:
|
||||
|
||||
db, err := database.Open("ffldb", "path/to/database", wire.MainNet)
|
||||
db, err := database.Open("ffldb", "path/to/database", wire.Mainnet)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
db, err := database.Create("ffldb", "path/to/database", wire.MainNet)
|
||||
db, err := database.Create("ffldb", "path/to/database", wire.Mainnet)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
@ -171,8 +171,8 @@ func TestPersistence(t *testing.T) {
|
||||
"b1key2": "foo2",
|
||||
"b1key3": "foo3",
|
||||
}
|
||||
genesisBlock := util.NewBlock(dagconfig.MainNetParams.GenesisBlock)
|
||||
genesisHash := dagconfig.MainNetParams.GenesisHash
|
||||
genesisBlock := util.NewBlock(dagconfig.MainnetParams.GenesisBlock)
|
||||
genesisHash := dagconfig.MainnetParams.GenesisHash
|
||||
err = db.Update(func(dbTx database.Tx) error {
|
||||
metadataBucket := dbTx.Metadata()
|
||||
if metadataBucket == nil {
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
|
||||
var (
|
||||
// blockDataNet is the expected network in the test block data.
|
||||
blockDataNet = wire.MainNet
|
||||
blockDataNet = wire.Mainnet
|
||||
|
||||
// blockDataFile is the path to a file containing the first 256 blocks
|
||||
// of the block DAG.
|
||||
@ -64,7 +64,7 @@ func loadBlocks(t *testing.T, dataFile string, network wire.KaspaNet) ([]*util.B
|
||||
|
||||
// Set the first block as the genesis block.
|
||||
blocks := make([]*util.Block, 0, 256)
|
||||
genesis := util.NewBlock(dagconfig.MainNetParams.GenesisBlock)
|
||||
genesis := util.NewBlock(dagconfig.MainnetParams.GenesisBlock)
|
||||
blocks = append(blocks, genesis)
|
||||
|
||||
// Load the remaining blocks.
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
|
||||
var (
|
||||
// blockDataNet is the expected network in the test block data.
|
||||
blockDataNet = wire.MainNet
|
||||
blockDataNet = wire.Mainnet
|
||||
|
||||
// blockDataFile is the path to a file containing the first 256 blocks
|
||||
// of the block DAG.
|
||||
@ -57,7 +57,7 @@ func loadBlocks(t *testing.T, dataFile string, network wire.KaspaNet) ([]*util.B
|
||||
|
||||
// Set the first block as the genesis block.
|
||||
blocks := make([]*util.Block, 0, 256)
|
||||
genesis := util.NewBlock(dagconfig.MainNetParams.GenesisBlock)
|
||||
genesis := util.NewBlock(dagconfig.MainnetParams.GenesisBlock)
|
||||
blocks = append(blocks, genesis)
|
||||
|
||||
// Load the remaining blocks.
|
||||
|
4
database/testdata/generator.go
vendored
4
database/testdata/generator.go
vendored
@ -34,7 +34,7 @@ func main() {
|
||||
}
|
||||
|
||||
func generateBlocks(out *os.File, numBlocks int) {
|
||||
lastBlock := dagconfig.MainNetParams.GenesisBlock
|
||||
lastBlock := dagconfig.MainnetParams.GenesisBlock
|
||||
|
||||
for i := 0; i < numBlocks; i++ {
|
||||
lastBlock = generateBlock(lastBlock)
|
||||
@ -81,7 +81,7 @@ func writeBlock(out *os.File, block *wire.MsgBlock) {
|
||||
}
|
||||
|
||||
func writeNet(out *os.File) {
|
||||
err := binary.Write(out, binary.LittleEndian, wire.MainNet)
|
||||
err := binary.Write(out, binary.LittleEndian, wire.Mainnet)
|
||||
if err != nil {
|
||||
panic(errors.Errorf("error writing net to file: %s", err))
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ func TestBIP0009Mining(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Initialize the primary mining node with only the genesis block.
|
||||
r, err := rpctest.New(&dagconfig.SimNetParams, nil, nil)
|
||||
r, err := rpctest.New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create primary harness: %v", err)
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func TestBIP0113(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
kaspadCfg := []string{"--rejectnonstd"}
|
||||
r, err := rpctest.New(&dagconfig.SimNetParams, nil, kaspadCfg)
|
||||
r, err := rpctest.New(&dagconfig.SimnetParams, nil, kaspadCfg)
|
||||
if err != nil {
|
||||
t.Fatal("unable to create primary harness: ", err)
|
||||
}
|
||||
@ -351,7 +351,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
// relative lock times.
|
||||
|
||||
kaspadCfg := []string{"--rejectnonstd"}
|
||||
r, err := rpctest.New(&dagconfig.SimNetParams, nil, kaspadCfg)
|
||||
r, err := rpctest.New(&dagconfig.SimnetParams, nil, kaspadCfg)
|
||||
if err != nil {
|
||||
t.Fatal("unable to create primary harness: ", err)
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func TestMain(m *testing.M) {
|
||||
// ensure that non-standard transactions aren't accepted into the
|
||||
// mempool or relayed.
|
||||
kaspadCfg := []string{"--rejectnonstd"}
|
||||
primaryHarness, err = rpctest.New(&dagconfig.SimNetParams, nil, kaspadCfg)
|
||||
primaryHarness, err = rpctest.New(&dagconfig.SimnetParams, nil, kaspadCfg)
|
||||
if err != nil {
|
||||
fmt.Println("unable to create primary harness: ", err)
|
||||
os.Exit(1)
|
||||
|
@ -108,13 +108,13 @@ func New(activeNet *dagconfig.Params, handlers *rpcclient.NotificationHandlers,
|
||||
// Add a flag for the appropriate network type based on the provided
|
||||
// chain params.
|
||||
switch activeNet.Net {
|
||||
case wire.MainNet:
|
||||
case wire.Mainnet:
|
||||
// No extra flags since mainnet is the default
|
||||
case wire.TestNet:
|
||||
case wire.Testnet:
|
||||
extraArgs = append(extraArgs, "--testnet")
|
||||
case wire.RegTest:
|
||||
case wire.Regtest:
|
||||
extraArgs = append(extraArgs, "--regtest")
|
||||
case wire.SimNet:
|
||||
case wire.Simnet:
|
||||
extraArgs = append(extraArgs, "--simnet")
|
||||
default:
|
||||
return nil, errors.Errorf("rpctest.New must be called with one " +
|
||||
|
@ -105,7 +105,7 @@ func assertConnectedTo(t *testing.T, nodeA *Harness, nodeB *Harness) {
|
||||
|
||||
func testConnectNode(r *Harness, t *testing.T) {
|
||||
// Create a fresh test harness.
|
||||
harness, err := New(&dagconfig.SimNetParams, nil, nil)
|
||||
harness, err := New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -153,7 +153,7 @@ func testActiveHarnesses(r *Harness, t *testing.T) {
|
||||
numInitialHarnesses := len(ActiveHarnesses())
|
||||
|
||||
// Create a single test harness.
|
||||
harness1, err := New(&dagconfig.SimNetParams, nil, nil)
|
||||
harness1, err := New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -181,7 +181,7 @@ func testJoinMempools(r *Harness, t *testing.T) {
|
||||
// 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
|
||||
// nodes without it being an orphan.
|
||||
harness, err := New(&dagconfig.SimNetParams, nil, nil)
|
||||
harness, err := New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -281,7 +281,7 @@ func testJoinMempools(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
|
||||
// the main harness.
|
||||
harness, err := New(&dagconfig.SimNetParams, nil, nil)
|
||||
harness, err := New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -469,7 +469,7 @@ func testGenerateAndSubmitBlockWithCustomCoinbaseOutputs(r *Harness,
|
||||
func testMemWalletReorg(r *Harness, t *testing.T) {
|
||||
// Create a fresh harness, we'll be using the main harness to force a
|
||||
// re-org on this local harness.
|
||||
harness, err := New(&dagconfig.SimNetParams, nil, nil)
|
||||
harness, err := New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -566,7 +566,7 @@ const (
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
mainHarness, err = New(&dagconfig.SimNetParams, nil, nil)
|
||||
mainHarness, err = New(&dagconfig.SimnetParams, nil, nil)
|
||||
if err != nil {
|
||||
fmt.Println("unable to create main harness: ", err)
|
||||
os.Exit(1)
|
||||
|
@ -483,7 +483,7 @@ func (p *poolHarness) createTx(outpoint spendableOutpoint, fee uint64, numOutput
|
||||
}
|
||||
|
||||
func TestProcessTransaction(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, ¶ms, 6, "TestProcessTransaction")
|
||||
if err != nil {
|
||||
@ -744,7 +744,7 @@ func TestProcessTransaction(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddrIndex(t *testing.T) {
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 2, "TestAddrIndex")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 2, "TestAddrIndex")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -786,7 +786,7 @@ func TestAddrIndex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoubleSpends(t *testing.T) {
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.SimNetParams, 2, "TestDoubleSpends")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.SimnetParams, 2, "TestDoubleSpends")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -842,7 +842,7 @@ func TestDoubleSpends(t *testing.T) {
|
||||
//TestFetchTransaction checks that FetchTransaction
|
||||
//returns only transaction from the main pool and not from the orphan pool
|
||||
func TestFetchTransaction(t *testing.T) {
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestFetchTransaction")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestFetchTransaction")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -888,7 +888,7 @@ func TestFetchTransaction(t *testing.T) {
|
||||
// they are all orphans. Finally, it adds the linking transaction and ensures
|
||||
// the entire orphan chain is moved to the transaction pool.
|
||||
func TestSimpleOrphanChain(t *testing.T) {
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestSimpleOrphanChain")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestSimpleOrphanChain")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -948,7 +948,7 @@ func TestSimpleOrphanChain(t *testing.T) {
|
||||
// TestOrphanReject ensures that orphans are properly rejected when the allow
|
||||
// orphans flag is not set on ProcessTransaction.
|
||||
func TestOrphanReject(t *testing.T) {
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestOrphanReject")
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestOrphanReject")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1002,7 +1002,7 @@ func TestOrphanReject(t *testing.T) {
|
||||
// it will check if we are beyond nextExpireScan, and if so, it will remove
|
||||
// all expired orphan transactions
|
||||
func TestOrphanExpiration(t *testing.T) {
|
||||
tc, _, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestOrphanExpiration")
|
||||
tc, _, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestOrphanExpiration")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1044,7 +1044,7 @@ func TestOrphanExpiration(t *testing.T) {
|
||||
//TestMaxOrphanTxSize ensures that a transaction that is
|
||||
//bigger than MaxOrphanTxSize will get rejected
|
||||
func TestMaxOrphanTxSize(t *testing.T) {
|
||||
tc, _, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestMaxOrphanTxSize")
|
||||
tc, _, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestMaxOrphanTxSize")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ func TestMaxOrphanTxSize(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveTransaction(t *testing.T) {
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 2, "TestRemoveTransaction")
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 2, "TestRemoveTransaction")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1130,7 +1130,7 @@ func TestRemoveTransaction(t *testing.T) {
|
||||
// TestOrphanEviction ensures that exceeding the maximum number of orphans
|
||||
// evicts entries to make room for the new ones.
|
||||
func TestOrphanEviction(t *testing.T) {
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestOrphanEviction")
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestOrphanEviction")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ func TestOrphanEviction(t *testing.T) {
|
||||
// Attempt to remove orphans by tag,
|
||||
// and ensure the state of all other orphans are unaffected.
|
||||
func TestRemoveOrphansByTag(t *testing.T) {
|
||||
tc, _, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestRemoveOrphansByTag")
|
||||
tc, _, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestRemoveOrphansByTag")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1244,7 +1244,7 @@ func TestRemoveOrphansByTag(t *testing.T) {
|
||||
// redeems it and when there is not.
|
||||
func TestBasicOrphanRemoval(t *testing.T) {
|
||||
const maxOrphans = 4
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestBasicOrphanRemoval")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestBasicOrphanRemoval")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1318,7 +1318,7 @@ func TestBasicOrphanRemoval(t *testing.T) {
|
||||
// from other orphans) are removed as expected.
|
||||
func TestOrphanChainRemoval(t *testing.T) {
|
||||
const maxOrphans = 10
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestOrphanChainRemoval")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestOrphanChainRemoval")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1379,7 +1379,7 @@ func TestOrphanChainRemoval(t *testing.T) {
|
||||
// output that is spend by another transaction entering the pool are removed.
|
||||
func TestMultiInputOrphanDoubleSpend(t *testing.T) {
|
||||
const maxOrphans = 4
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestMultiInputOrphanDoubleSpend")
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestMultiInputOrphanDoubleSpend")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1463,7 +1463,7 @@ func TestMultiInputOrphanDoubleSpend(t *testing.T) {
|
||||
// TestCheckSpend tests that CheckSpend returns the expected spends found in
|
||||
// the mempool.
|
||||
func TestCheckSpend(t *testing.T) {
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestCheckSpend")
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestCheckSpend")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1529,7 +1529,7 @@ func TestCheckSpend(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCount(t *testing.T) {
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 1, "TestCount")
|
||||
tc, outputs, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 1, "TestCount")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1632,7 +1632,7 @@ func TestExtractRejectCode(t *testing.T) {
|
||||
|
||||
// TestHandleNewBlock
|
||||
func TestHandleNewBlock(t *testing.T) {
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainNetParams, 2, "TestHandleNewBlock")
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, &dagconfig.MainnetParams, 2, "TestHandleNewBlock")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test pool: %v", err)
|
||||
}
|
||||
@ -1735,13 +1735,13 @@ var dummyBlock = wire.MsgBlock{
|
||||
0x78, 0x6b, 0x03, 0x1d, 0xa3, 0x48, 0x3c, 0x45,
|
||||
0x3f, 0xc3, 0x2e, 0xd4, 0x53, 0x5b, 0x6f, 0x26,
|
||||
0x26, 0xb0, 0x48, 0x4f, 0x09, 0x00, 0x00, 0x00,
|
||||
}, // MainNet genesis
|
||||
}, // Mainnet genesis
|
||||
{
|
||||
0xc1, 0x5b, 0x71, 0xfe, 0x20, 0x70, 0x0f, 0xd0,
|
||||
0x08, 0x49, 0x88, 0x1b, 0x32, 0xb5, 0xbd, 0x13,
|
||||
0x17, 0xbe, 0x75, 0xe7, 0x29, 0x46, 0xdd, 0x03,
|
||||
0x01, 0x92, 0x90, 0xf1, 0xca, 0x8a, 0x88, 0x11,
|
||||
}}, // SimNet genesis
|
||||
}}, // Simnet genesis
|
||||
HashMerkleRoot: &daghash.Hash{
|
||||
0x66, 0x57, 0xa9, 0x25, 0x2a, 0xac, 0xd5, 0xc0,
|
||||
0xb2, 0x94, 0x09, 0x96, 0xec, 0xff, 0x95, 0x22,
|
||||
@ -1794,7 +1794,7 @@ var dummyBlock = wire.MsgBlock{
|
||||
}
|
||||
|
||||
func TestTransactionGas(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
tc, spendableOuts, teardownFunc, err := newPoolHarness(t, ¶ms, 6, "TestTransactionGas")
|
||||
if err != nil {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNewBlockTemplate(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestNewBlockTemplate", blockdag.Config{
|
||||
@ -215,7 +215,7 @@ func TestNewBlockTemplate(t *testing.T) {
|
||||
gasLimitPatch.Unpatch()
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("NewBlockTemplate: unexpected error: %v", err)
|
||||
t.Fatalf("NewBlockTemplate: unexpected error: %v", err)
|
||||
}
|
||||
|
||||
expectedTxs := map[daghash.TxID]bool{
|
||||
|
@ -29,7 +29,7 @@ func (dd testTxDescDefinition) String() string {
|
||||
}
|
||||
|
||||
func TestSelectTxs(t *testing.T) {
|
||||
params := dagconfig.SimNetParams
|
||||
params := dagconfig.SimnetParams
|
||||
params.BlockCoinbaseMaturity = 0
|
||||
|
||||
dag, teardownFunc, err := blockdag.DAGSetup("TestSelectTxs", blockdag.Config{
|
||||
|
@ -22,7 +22,7 @@ func mockRemotePeer() error {
|
||||
peerCfg := &peer.Config{
|
||||
UserAgentName: "peer", // User agent name to advertise.
|
||||
UserAgentVersion: "1.0.0", // User agent version to advertise.
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
SelectedTip: fakeSelectedTipFn,
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ func Example_newOutboundPeer() {
|
||||
peerCfg := &peer.Config{
|
||||
UserAgentName: "peer", // User agent name to advertise.
|
||||
UserAgentVersion: "1.0.0", // User agent version to advertise.
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
DAGParams: &dagconfig.SimnetParams,
|
||||
Services: 0,
|
||||
Listeners: peer.MessageListeners{
|
||||
OnVersion: func(p *peer.Peer, msg *wire.MsgVersion) {
|
||||
|
@ -1094,7 +1094,7 @@ func (p *Peer) writeMessage(msg wire.Message) error {
|
||||
// to send malformed messages without the peer being disconnected.
|
||||
func (p *Peer) isAllowedReadError(err error) bool {
|
||||
// Only allow read errors in regression test mode.
|
||||
if p.cfg.DAGParams.Net != wire.RegTest {
|
||||
if p.cfg.DAGParams.Net != wire.Regtest {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -1963,7 +1963,7 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
|
||||
|
||||
// Set the DAG parameters to testnet if the caller did not specify any.
|
||||
if cfg.DAGParams == nil {
|
||||
cfg.DAGParams = &dagconfig.TestNetParams
|
||||
cfg.DAGParams = &dagconfig.TestnetParams
|
||||
}
|
||||
|
||||
p := Peer{
|
||||
|
@ -215,7 +215,7 @@ func TestPeerConnection(t *testing.T) {
|
||||
UserAgentName: "peer",
|
||||
UserAgentVersion: "1.0",
|
||||
UserAgentComments: []string{"comment"},
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
ProtocolVersion: wire.ProtocolVersion, // Configure with older version
|
||||
Services: 0,
|
||||
SelectedTip: fakeSelectedTipFn,
|
||||
@ -225,7 +225,7 @@ func TestPeerConnection(t *testing.T) {
|
||||
UserAgentName: "peer",
|
||||
UserAgentVersion: "1.0",
|
||||
UserAgentComments: []string{"comment"},
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
ProtocolVersion: wire.ProtocolVersion + 1,
|
||||
Services: wire.SFNodeNetwork,
|
||||
SelectedTip: fakeSelectedTipFn,
|
||||
@ -401,7 +401,7 @@ func TestPeerListeners(t *testing.T) {
|
||||
UserAgentName: "peer",
|
||||
UserAgentVersion: "1.0",
|
||||
UserAgentComments: []string{"comment"},
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
Services: wire.SFNodeBloom,
|
||||
SelectedTip: fakeSelectedTipFn,
|
||||
}
|
||||
@ -534,7 +534,7 @@ func TestOutboundPeer(t *testing.T) {
|
||||
UserAgentName: "peer",
|
||||
UserAgentVersion: "1.0",
|
||||
UserAgentComments: []string{"comment"},
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
Services: 0,
|
||||
}
|
||||
|
||||
@ -643,7 +643,7 @@ func TestUnsupportedVersionPeer(t *testing.T) {
|
||||
UserAgentName: "peer",
|
||||
UserAgentVersion: "1.0",
|
||||
UserAgentComments: []string{"comment"},
|
||||
DAGParams: &dagconfig.MainNetParams,
|
||||
DAGParams: &dagconfig.MainnetParams,
|
||||
Services: 0,
|
||||
SelectedTip: fakeSelectedTipFn,
|
||||
}
|
||||
|
@ -403,8 +403,8 @@ type GetMiningInfoResult struct {
|
||||
GenProcLimit int32 `json:"genProcLimit"`
|
||||
HashesPerSec int64 `json:"hashesPerSec"`
|
||||
PooledTx uint64 `json:"pooledTx"`
|
||||
TestNet bool `json:"testNet"`
|
||||
DevNet bool `json:"devNet"`
|
||||
Testnet bool `json:"testnet"`
|
||||
Devnet bool `json:"devnet"`
|
||||
}
|
||||
|
||||
// GetWorkResult models the data from the getwork command.
|
||||
@ -424,8 +424,8 @@ type InfoDAGResult struct {
|
||||
Connections int32 `json:"connections"`
|
||||
Proxy string `json:"proxy"`
|
||||
Difficulty float64 `json:"difficulty"`
|
||||
TestNet bool `json:"testNet"`
|
||||
DevNet bool `json:"devNet"`
|
||||
Testnet bool `json:"testnet"`
|
||||
Devnet bool `json:"devnet"`
|
||||
RelayFee float64 `json:"relayFee"`
|
||||
Errors string `json:"errors"`
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ func (sp *Peer) OnAddr(_ *peer.Peer, msg *wire.MsgAddr) {
|
||||
// helps prevent the network from becoming another public test network
|
||||
// since it will not be able to learn about other peers that have not
|
||||
// specifically been provided.
|
||||
if config.ActiveConfig().SimNet {
|
||||
if config.ActiveConfig().Simnet {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ func (sp *Peer) OnGetAddr(_ *peer.Peer, msg *wire.MsgGetAddr) {
|
||||
// network. This helps prevent the network from becoming another
|
||||
// public test network since it will not be able to learn about other
|
||||
// peers that have not specifically been provided.
|
||||
if config.ActiveConfig().SimNet {
|
||||
if config.ActiveConfig().Simnet {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ func (sp *Peer) OnVersion(_ *peer.Peer, msg *wire.MsgVersion) {
|
||||
// on the simulation test network since it is only intended to connect
|
||||
// to specified peers and actively avoids advertising and connecting to
|
||||
// discovered peers.
|
||||
if !config.ActiveConfig().SimNet {
|
||||
if !config.ActiveConfig().Simnet {
|
||||
addrManager := sp.server.addrManager
|
||||
|
||||
// Outbound connections.
|
||||
|
@ -1692,7 +1692,7 @@ func NewServer(listenAddrs []string, db database.DB, dagParams *dagconfig.Params
|
||||
// discovered peers in order to prevent it from becoming a public test
|
||||
// network.
|
||||
var newAddressFunc func() (net.Addr, error)
|
||||
if !config.ActiveConfig().SimNet && len(config.ActiveConfig().ConnectPeers) == 0 {
|
||||
if !config.ActiveConfig().Simnet && len(config.ActiveConfig().ConnectPeers) == 0 {
|
||||
newAddressFunc = func() (net.Addr, error) {
|
||||
for tries := 0; tries < 100; tries++ {
|
||||
addr := s.addrManager.GetAddress()
|
||||
|
@ -173,7 +173,7 @@ func handleGetBlockTemplateRequest(s *Server, request *rpcmodel.TemplateRequest,
|
||||
// way to relay a found block or receive transactions to work on.
|
||||
// However, allow this state when running in the regression test or
|
||||
// simulation test mode.
|
||||
if !(config.ActiveConfig().RegressionTest || config.ActiveConfig().SimNet) &&
|
||||
if !(config.ActiveConfig().RegressionTest || config.ActiveConfig().Simnet) &&
|
||||
s.cfg.ConnMgr.ConnectedCount() == 0 {
|
||||
|
||||
return nil, &rpcmodel.RPCError{
|
||||
|
@ -17,8 +17,8 @@ func handleGetInfo(s *Server, cmd interface{}, closeChan <-chan struct{}) (inter
|
||||
Connections: s.cfg.ConnMgr.ConnectedCount(),
|
||||
Proxy: config.ActiveConfig().Proxy,
|
||||
Difficulty: getDifficultyRatio(s.cfg.DAG.CurrentBits(), s.cfg.DAGParams),
|
||||
TestNet: config.ActiveConfig().TestNet,
|
||||
DevNet: config.ActiveConfig().DevNet,
|
||||
Testnet: config.ActiveConfig().Testnet,
|
||||
Devnet: config.ActiveConfig().Devnet,
|
||||
RelayFee: config.ActiveConfig().MinRelayTxFee.ToKAS(),
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ func handleGetMiningInfo(s *Server, cmd interface{}, closeChan <-chan struct{})
|
||||
GenProcLimit: s.cfg.CPUMiner.NumWorkers(),
|
||||
HashesPerSec: int64(s.cfg.CPUMiner.HashesPerSecond()),
|
||||
PooledTx: uint64(s.cfg.TxMemPool.Count()),
|
||||
TestNet: config.ActiveConfig().TestNet,
|
||||
DevNet: config.ActiveConfig().DevNet,
|
||||
Testnet: config.ActiveConfig().Testnet,
|
||||
Devnet: config.ActiveConfig().Devnet,
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
@ -401,8 +401,8 @@ var helpDescsEnUS = map[string]string{
|
||||
"infoDagResult-connections": "The number of connected peers",
|
||||
"infoDagResult-proxy": "The proxy used by the server",
|
||||
"infoDagResult-difficulty": "The current target difficulty",
|
||||
"infoDagResult-testNet": "Whether or not server is using testnet",
|
||||
"infoDagResult-devNet": "Whether or not server is using devnet",
|
||||
"infoDagResult-testnet": "Whether or not server is using testnet",
|
||||
"infoDagResult-devnet": "Whether or not server is using devnet",
|
||||
"infoDagResult-relayFee": "The minimum relay fee for non-free transactions in KAS/KB",
|
||||
"infoDagResult-errors": "Any current errors",
|
||||
|
||||
@ -437,8 +437,8 @@ var helpDescsEnUS = map[string]string{
|
||||
"getMiningInfoResult-genProcLimit": "Number of processors to use for coin generation (-1 when disabled)",
|
||||
"getMiningInfoResult-hashesPerSec": "Recent hashes per second performance measurement while generating coins",
|
||||
"getMiningInfoResult-pooledTx": "Number of transactions in the memory pool",
|
||||
"getMiningInfoResult-testNet": "Whether or not server is using testnet",
|
||||
"getMiningInfoResult-devNet": "Whether or not server is using devnet",
|
||||
"getMiningInfoResult-testnet": "Whether or not server is using testnet",
|
||||
"getMiningInfoResult-devnet": "Whether or not server is using devnet",
|
||||
|
||||
// GetMiningInfoCmd help.
|
||||
"getMiningInfo--synopsis": "Returns a JSON object containing mining-related information.",
|
||||
|
@ -61,7 +61,7 @@ func ExampleExtractScriptPubKeyAddress() {
|
||||
|
||||
// Extract and print details from the script.
|
||||
scriptClass, address, err := txscript.ExtractScriptPubKeyAddress(
|
||||
script, &dagconfig.MainNetParams)
|
||||
script, &dagconfig.MainnetParams)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
|
@ -76,7 +76,7 @@ func signAndCheck(msg string, tx *wire.MsgTx, idx int, scriptPubKey []byte,
|
||||
hashType SigHashType, kdb KeyDB, sdb ScriptDB,
|
||||
previousScript []byte) error {
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams, tx, idx,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestnetParams, tx, idx,
|
||||
scriptPubKey, hashType, kdb, sdb, nil)
|
||||
if err != nil {
|
||||
return errors.Errorf("failed to sign output %s: %v", msg, err)
|
||||
@ -199,7 +199,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
"for %s: %v", msg, err)
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -212,7 +212,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -298,7 +298,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
"for %s: %v", msg, err)
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
@ -311,7 +311,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
@ -432,7 +432,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -447,7 +447,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, false},
|
||||
@ -569,7 +569,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err := SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
@ -584,7 +584,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
// by the above loop, this should be valid, now sign
|
||||
// again and merge.
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
|
||||
sigScript, err = SignTxOutput(&dagconfig.TestnetParams,
|
||||
tx, i, scriptScriptPubKey, hashType,
|
||||
mkGetKey(map[string]addressToKey{
|
||||
address.EncodeAddress(): {key, true},
|
||||
|
@ -137,7 +137,7 @@ func TestExtractScriptPubKeyAddrs(t *testing.T) {
|
||||
t.Logf("Running %d tests.", len(tests))
|
||||
for i, test := range tests {
|
||||
class, addr, err := ExtractScriptPubKeyAddress(
|
||||
test.script, &dagconfig.MainNetParams)
|
||||
test.script, &dagconfig.MainnetParams)
|
||||
if err != nil {
|
||||
}
|
||||
|
||||
|
@ -312,13 +312,13 @@ var Block100000 = wire.MsgBlock{
|
||||
0x78, 0x6b, 0x03, 0x1d, 0xa3, 0x48, 0x3c, 0x45,
|
||||
0x3f, 0xc3, 0x2e, 0xd4, 0x53, 0x5b, 0x6f, 0x26,
|
||||
0x26, 0xb0, 0x48, 0x4f, 0x09, 0x00, 0x00, 0x00,
|
||||
}, // MainNet genesis
|
||||
}, // Mainnet genesis
|
||||
{
|
||||
0xc1, 0x5b, 0x71, 0xfe, 0x20, 0x70, 0x0f, 0xd0,
|
||||
0x08, 0x49, 0x88, 0x1b, 0x32, 0xb5, 0xbd, 0x13,
|
||||
0x17, 0xbe, 0x75, 0xe7, 0x29, 0x46, 0xdd, 0x03,
|
||||
0x01, 0x92, 0x90, 0xf1, 0xca, 0x8a, 0x88, 0x11,
|
||||
}}, // SimNet genesis
|
||||
}}, // Simnet genesis
|
||||
HashMerkleRoot: &daghash.Hash{
|
||||
0x66, 0x57, 0xa9, 0x25, 0x2a, 0xac, 0xd5, 0xc0,
|
||||
0xb2, 0x94, 0x09, 0x96, 0xec, 0xff, 0x95, 0x22,
|
||||
|
@ -13,9 +13,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// mainNetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// mainnetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// main network (genesis block).
|
||||
var mainNetGenesisHash = Hash([HashSize]byte{
|
||||
var mainnetGenesisHash = Hash([HashSize]byte{
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25,
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
@ -153,14 +153,14 @@ func TestNewHashFromStr(t *testing.T) {
|
||||
// Genesis hash.
|
||||
{
|
||||
"63bbcfdd699ffd8cb19878564b14d3af8ba4d7ee4d1dd54925a7c21d5b5b5fdc",
|
||||
mainNetGenesisHash,
|
||||
mainnetGenesisHash,
|
||||
nil,
|
||||
},
|
||||
|
||||
// Genesis hash with stripped leading zeros.
|
||||
{
|
||||
"63bbcfdd699ffd8cb19878564b14d3af8ba4d7ee4d1dd54925a7c21d5b5b5fdc",
|
||||
mainNetGenesisHash,
|
||||
mainnetGenesisHash,
|
||||
nil,
|
||||
},
|
||||
|
||||
|
@ -22,7 +22,7 @@ func ExampleNewMaster() {
|
||||
}
|
||||
|
||||
// Generate a new master node using the seed.
|
||||
key, err := hdkeychain.NewMaster(seed, hdkeychain.HDKeyPairMainNet.PrivateKeyID)
|
||||
key, err := hdkeychain.NewMaster(seed, hdkeychain.HDKeyPairMainnet.PrivateKeyID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
|
@ -370,11 +370,11 @@ type HDKeyIDPair struct {
|
||||
|
||||
// HDKeyPairs for all kinds of nets
|
||||
var (
|
||||
HDKeyPairMainNet = HDKeyIDPair{
|
||||
HDKeyPairMainnet = HDKeyIDPair{
|
||||
PrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4}, // starts with xprv
|
||||
PublicKeyID: [4]byte{0x04, 0x88, 0xb2, 0x1e}, // starts with xpub
|
||||
}
|
||||
HDKeyPairTestNet = HDKeyIDPair{
|
||||
HDKeyPairTestnet = HDKeyIDPair{
|
||||
PrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv
|
||||
PublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with tpub
|
||||
}
|
||||
@ -382,11 +382,11 @@ var (
|
||||
PrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv
|
||||
PublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with tpub
|
||||
}
|
||||
HDKeyPairSimNet = HDKeyIDPair{
|
||||
HDKeyPairSimnet = HDKeyIDPair{
|
||||
PrivateKeyID: [4]byte{0x04, 0x20, 0xb9, 0x00}, // starts with sprv
|
||||
PublicKeyID: [4]byte{0x04, 0x20, 0xbd, 0x3a}, // starts with spub
|
||||
}
|
||||
HDKeyPairDevNet = HDKeyIDPair{
|
||||
HDKeyPairDevnet = HDKeyIDPair{
|
||||
PrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4}, // starts with xprv
|
||||
PublicKeyID: [4]byte{0x04, 0x88, 0xb2, 0x1e}, // starts with xpub
|
||||
}
|
||||
@ -636,9 +636,9 @@ func GenerateSeed(length uint8) ([]byte, error) {
|
||||
|
||||
func init() {
|
||||
// Register all default keyPairIDs when the package is initialized.
|
||||
RegisterHDKeyIDPair(HDKeyPairMainNet)
|
||||
RegisterHDKeyIDPair(HDKeyPairTestNet)
|
||||
RegisterHDKeyIDPair(HDKeyPairMainnet)
|
||||
RegisterHDKeyIDPair(HDKeyPairTestnet)
|
||||
RegisterHDKeyIDPair(HDKeyPairRegressionNet)
|
||||
RegisterHDKeyIDPair(HDKeyPairSimNet)
|
||||
RegisterHDKeyIDPair(HDKeyPairDevNet)
|
||||
RegisterHDKeyIDPair(HDKeyPairSimnet)
|
||||
RegisterHDKeyIDPair(HDKeyPairDevnet)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{},
|
||||
wantPub: "xpub661MyMwAqRbcGTTa4Jdtmttwg6yq1xoxNMPqCMT4iasLkbMDJHwHX6GGExBu9TXWSs2W7YNtQciJWhDuE2yJSDbHKSptjnBNnHMGxg5ybMW",
|
||||
wantPriv: "xprv9s21ZrQH143K3yP6xH6tQkxD859LcW6718UEPy3TAFLMso24kkd2yHwnPeKuxD5MyK3YvXTJsqgXVp6hdrhYNabhhgxSPNbh3N69w5WrGT1",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H",
|
||||
@ -52,7 +52,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart},
|
||||
wantPub: "xpub69KEapfQ6NaCMD2hCspTKoAv2or3Ti3Uu5mXf84w5pFskMpPvNKWyBELokM6pCz51Pjw6gLor1troP7eeUgczktnzewPcdXVh9j6aPJhfH8",
|
||||
wantPriv: "xprv9vKtBK8WG11u8ixE6rHSxfEBUn1Z4FKdXrqvrjfKXUitsZVFNq1GRNurxUUZ5Rhrw5MpM6nbBQJJMnA2qoQD3j2JbbG4BS594GcQsToQaiB",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1",
|
||||
@ -60,7 +60,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1},
|
||||
wantPub: "xpub6AjVQFnusUq1NAzf6s5HAfHnxPZAaXNvCD2dxb5mr68GYMYSTBsGYL1sqe1NERKsdZPA2CQeASih53Ms3XXQgwagHCVCM8jwvMTsrdBTUsi",
|
||||
wantPriv: "xprv9wk8zkG237Gi9gvBzqYGoXM4QMigB4f4pz73ACgAHkbHfZDHueZ1zXhPzMWScvVYsHvckXUViA3BfUiKiyTJuRnbWEkKCD1LNvzYQkjzAg6",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H",
|
||||
@ -68,7 +68,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1, hkStart + 2},
|
||||
wantPub: "xpub6BqBypWNhDSbEmsBUrkmQhBfpxAQN4HvStjopj7pdQSTHcG5z5yQhxR2qYQQa4J3FAfjK5nzPocGKzkjWxtEKDL5Gom4rfWkqxzR26QnsSk",
|
||||
wantPriv: "xprv9xqqaJyUrqtJ2HniNqDm3ZEwGvKuxba55fpD2LiD54uUQovwSYfAAA6YzHAPgpojwoc4webEpkbhyzrq6xKY18HrfZYbTb5F1ZchyoNTSJh",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H/2",
|
||||
@ -76,7 +76,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1, hkStart + 2, 2},
|
||||
wantPub: "xpub6EgqrrZKS9A48mXpZtsWQ57Evxzt3sPHwP41p3TmqynQABtGcspvs1ivvHTiQWnuarDsCBPvMK6hf3rnqefXkVTtcs1JZdYSrL5WFtmm92b",
|
||||
wantPriv: "xprvA1hVTM2RbmbkvHTMTsLW2wAWNwAPeQfSaA8R1f4AHeFRHPZ85LWgKDQT53tf7QeCfrh679CxyJZSasHJHJg6Tqed8qo4gTDmapTY9RQEQLJ",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H/2/1000000000",
|
||||
@ -84,7 +84,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1, hkStart + 2, 2, 1000000000},
|
||||
wantPub: "xpub6HJ4G6aN3TxzUM7jp992qnKyJR3eSwvPAL2YASqBmR3GnoxUGFjZWdCv8ZfuY3XxkJiq4ukTdfzMDLDrcSGL9QE51a6pWSNFi579DEGbdqQ",
|
||||
wantPriv: "xprvA4Jhrb3UD6QhFs3Gi7c2UePEkPDA3VCXo76wN4RaD5WHv1dKiiRJxptSHJYEBqf9DnhBy5Acj9ECL2Fi3vcr78ivPMes5qoELfw9xuENti1",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
|
||||
// Test vector 2
|
||||
@ -94,7 +94,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{},
|
||||
wantPub: "xpub661MyMwAqRbcGgMhBVBjF9Nmm7gem3XyVKNwpxEUVoreyzfksY8hvVjTHvxgNw5fZznRPrGE9xf1WR2vHkBB3Gc8oBDpiaC2vScCKGcdA1d",
|
||||
wantPriv: "xprv9s21ZrQH143K4CHE5Teit1S3D5rAMap886TM2ZprwUKg7CLcKzpTNhQySeBnY7R7LL6kZyZPjHGkc9ouLY4Dhy6e9UFP2KJ6j3TiBXACRSB",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 2 chain m/0",
|
||||
@ -102,7 +102,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{0},
|
||||
wantPub: "xpub6912QQoTAjwVLJiaMFhPbu4maaaieUN2FQrSWCYSBtBSeM5yd6eK7pCFFHXLUPeh6iAaGR6ErHjJ8x2VKW7F4Htu9iVWzAtvj88UQKNvxj6",
|
||||
wantPriv: "xprv9v1fzuGZLNPC7pe7FEAPEm832YkEF1eAtBvqhp8pdYeTmYkq5ZL4a1smPzv3LKVArYkYvPgLgP947tJmH38NqCWcpkzNbXvQ9joq6FQePaw",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 2 chain m/0/2147483647H",
|
||||
@ -110,7 +110,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{0, hkStart + 2147483647},
|
||||
wantPub: "xpub6B9QvMX5vvu5y1aEfyJHpPymeL81y9cdU3eo8EA55ftMuqaJG6HNaznyxDXX1WaQPWQjRahRz5VsGNtJRRWTkhtxgKHCm4PhTsrYz11cdm7",
|
||||
wantPriv: "xprv9xA4WqzC6ZLnkXVmZwmHTG336JHXZgtn6pjCKqkTXLMP33F9iYy83CUW6ySkBGQtHhBGqZpqzStP5C3Xq5rvqNrhPCuPEsqUXPNQnTKyiax",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 2 chain m/0/2147483647H/1",
|
||||
@ -118,7 +118,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{0, hkStart + 2147483647, 1},
|
||||
wantPub: "xpub6CPAoCUuVd4VKDE39r1aGoRndRdBqD9QXWXt4hYxKWDznaR1nJXgjbnb5DQNmzYt83SmvCe9zmGXWRwi1M5rqCUkwNDLsjc4jUJcjqbKgSW",
|
||||
wantPriv: "xprv9yPpPgx1fFWC6j9a3pUZufV45PnhRkRZAHcHGK9LmAh1un5sEmDSBoU7DwtYAvgsUoewLkJRhXhWZjxJ6TuPDSL3tXSuAkz3nFEw83F9PNX",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 2 chain m/0/2147483647H/1/2147483646H",
|
||||
@ -126,7 +126,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{0, hkStart + 2147483647, 1, hkStart + 2147483646},
|
||||
wantPub: "xpub6EGnnakCt69xbT83sUN5BhrRr933BtTd4cMUiqzyrkRWkNhnKeMifJN1G9gjbART8QA86KxyYSijp9DpEi12oFnznwS7H1vFjGVcta65Ru1",
|
||||
wantPriv: "xprvA1HSP5DK3ibfNy3amSq4pZuhJ7CYnRjmhPRsvTbNJQtXsaNdn73U7W3XQszDCEKwRrgGTSe8R2nFcTje7eBeyP9V8264EHeuvt8mXLbdQWQ",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 2 chain m/0/2147483647H/1/2147483646H/2",
|
||||
@ -134,7 +134,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{0, hkStart + 2147483647, 1, hkStart + 2147483646, 2},
|
||||
wantPub: "xpub6GyY8YKU9JoxnwgqbusBYvJByXBiY2FWE2HMrXQDunVs61Rr5ojSBkeLxwnsQ9mMkMY1JVvRdMtoY5KHSwv8jWypeFX5tWzkhiH4qj5xEhr",
|
||||
wantPriv: "xprvA3zBj2naJwFfaTcNVtLBBnMTRVME8ZXeroMm48zcMSxtDD6hYGRBdxKs7e1j3oih75fyXXkPLPcCoBt6GmfdgZQqTw3Zt7i18j1CTQnDCYs",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
|
||||
// Test vector 3
|
||||
@ -144,7 +144,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{},
|
||||
wantPub: "xpub661MyMwAqRbcH1Qh3yC3Zk1eESmJ1QpoXt8HK2h3MTA5QTMsKYD4guWkaqDdrmiHFRssCPRaUA9CD2tXhNtmN1aT7eV18q8BoExXbo4mEtZ",
|
||||
wantPriv: "xprv9s21ZrQH143K4XLDwwf3Cc4ugQvobx6xAfCgWeHRo7d6Xf2imztp97CGjX9Yu7gpv9tfoNNx99bEUTkinzeXKrdafDkuhqwK5TeViwMWZ6i",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 3 chain m/0H",
|
||||
@ -152,7 +152,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart},
|
||||
wantPub: "xpub68sNRZc1xTrER4A1q2buYUQyfaRMv8FgXDvR2xQhtEhCzVMaFoXbquRd5JPfCQv3dN48d7Cuq3fCdTXzrxXZxbZoEwhBAz6xKwFUc3vRgg4",
|
||||
wantPriv: "xprv9ut2245886HwCa5Yj14uBLUF7YasWfXq9zzpEa16KuAE7h2RiGDMJ779E4cv62x55XQNiZ4jaUbes1G9nYoBKAE8b6Ud8mrhABo9fxLRuad",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
|
||||
// Test vector 1 - Testnet
|
||||
@ -162,7 +162,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{},
|
||||
wantPub: "tpubD6NzVbkrYhZ4YFeRWVcyypEK1E5V1MK1uyz8YuWD4VdEVt1vNWnNfXw6UzGgfxUkEmZQj7tkwiYMCsiWctpYKf3aP3aCRJqcNEwgienHE4w",
|
||||
wantPriv: "tprv8ZgxMBicQKsPencdcqxPaQaCSCZYr287LgPMGPTueDpqfPm9k7xnV3KEJpVZxaTgLkaKvd553CGKxfeSm53VBdsJELAk3jKjxTqaNj93jhF",
|
||||
hdKeyIDPair: HDKeyPairTestNet,
|
||||
hdKeyIDPair: HDKeyPairTestnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H - testnet",
|
||||
@ -170,7 +170,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart},
|
||||
wantPub: "tpubD9gs74V5oeXed1DYf4oYXiWHMvwhT6YYSiMq1g85Rj1mVeV6zbAc7cuB3nRtLhwJoJGqiFrgP7iuVZcG3LXrtCM64FghJABjH7KWLRMoCvo",
|
||||
wantPriv: "tprv8czpxeSqfGqyjYBkmR8x8JrAnuRmHmMdsQm3jA5n1TDNfAELNCM1w8HJseeD5o6BJWtbMCQMLkt6pdhmy1k9rnHu8EUMqnoByNMqKA1yKAG",
|
||||
hdKeyIDPair: HDKeyPairTestNet,
|
||||
hdKeyIDPair: HDKeyPairTestnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1 - testnet",
|
||||
@ -178,7 +178,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1},
|
||||
wantPub: "tpubDB77vVcbaknTdyBWZ44NNadAHWepZusyjqcwK98vBztAHeD9XQiMgmgi5g69kvH7RTv4dmvWhYYjmDrUSPNeaP2yLoEW2fQBWK4HceSHWLM",
|
||||
wantPriv: "tprv8eR5n5aMSP6nkW9ifQPmyAy3iV8tQah5AY2A2d6cmj5mT9xNu1tmWH4quXg6dHssEjTPkd6FsWcz8LG4rBoFiV4C2sxcrZjPJ2jxrRiSdSz",
|
||||
hdKeyIDPair: HDKeyPairTestNet,
|
||||
hdKeyIDPair: HDKeyPairTestnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H - testnet",
|
||||
@ -186,7 +186,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1, hkStart + 2},
|
||||
wantPub: "tpubDCCpW4L4QVQ3Wa42w3jrccX3A5G4MSnyzXL7BHAxyKCM2tvo4JpVrQ5s5aVC6ZFH35CdvfJrvuSK2BFLupjUCenNLQWNYCAzRvapn4MGur7",
|
||||
wantPriv: "tprv8fWnMeHpG7iNd72F3Q5GDCrvb3k8C7c5RDjKtm8fZ3PxCQg2RuzufuTzuTL3hCC4KF8qwkCzz7BWSrQaEAfUpBZTCCku7woHvfN8RSEDVA8",
|
||||
hdKeyIDPair: HDKeyPairTestNet,
|
||||
hdKeyIDPair: HDKeyPairTestnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H/2 - testnet",
|
||||
@ -194,7 +194,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1, hkStart + 2, 2},
|
||||
wantPub: "tpubDF4UP6P19R7WQZig25rbbzScG66Y3FtMV1eKAbWvBtYHuUYyh6g21TPmAKYVw1k9NkkmokuntQvkMEMQEWWmdvvBgTkcFACgSHfv1ze714s",
|
||||
wantPriv: "tprv8iNSEgLm13RqX6gt8SC1CanVh4absvhSui3Xt5Ucmcju4zJD4hrRpxmtzE4K7n2X3JDs7Epj8f9F3iq3QX23GtvDfV1NLowpVvCxb7VMUpG",
|
||||
hdKeyIDPair: HDKeyPairTestNet,
|
||||
hdKeyIDPair: HDKeyPairTestnet,
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H/2/1000000000 - testnet",
|
||||
@ -202,7 +202,7 @@ func TestBIP0032Vectors(t *testing.T) {
|
||||
path: []uint32{hkStart, 1, hkStart + 2, 2, 1000000000},
|
||||
wantPub: "tpubDHfgnLQ3kjvSk9JbGL883hfLdY9JSLRShxcqWztL7KoAY6dBLUaef4skNbkh4YVCYDFjgVGLAmpPuWiU1J7a2qgN5Ar8By2VJ2hYyEPjRX2",
|
||||
wantPriv: "tprv8kyedvMocNEmrgGoNgTXeJ1E4WdNH1EY8f24EUr2h3zmhcNQi5m4UaFtCUhtCD3TbEDxyAnNtVoznsoTB8xnvBzWuzsAkCXHFmgaQbL7CbH",
|
||||
hdKeyIDPair: HDKeyPairTestNet,
|
||||
hdKeyIDPair: HDKeyPairTestnet,
|
||||
},
|
||||
}
|
||||
|
||||
@ -679,8 +679,8 @@ func TestNet(t *testing.T) {
|
||||
{
|
||||
name: "mainnet -> simnet",
|
||||
key: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi",
|
||||
origHDKeyIDPair: HDKeyPairMainNet,
|
||||
newHDKeyIDPair: HDKeyPairSimNet,
|
||||
origHDKeyIDPair: HDKeyPairMainnet,
|
||||
newHDKeyIDPair: HDKeyPairSimnet,
|
||||
newPriv: "sprv8Erh3X3hFeKunvVdAGQQtambRPapECWiTDtvsTGdyrhzhbYgnSZajRRWbihzvq4AM4ivm6uso31VfKaukwJJUs3GYihXP8ebhMb3F2AHu3P",
|
||||
newPub: "spub4Tr3T2ab61tD1Qa6GHwRFiiKyRRJdfEZpSpXfqgFYCEyaPsqKysqHDjzSzMJSiUEGbcsG3w2SLMoTqn44B8x6u3MLRRkYfACTUBnHK79THk",
|
||||
isPrivate: true,
|
||||
@ -688,8 +688,8 @@ func TestNet(t *testing.T) {
|
||||
{
|
||||
name: "simnet -> mainnet",
|
||||
key: "sprv8Erh3X3hFeKunvVdAGQQtambRPapECWiTDtvsTGdyrhzhbYgnSZajRRWbihzvq4AM4ivm6uso31VfKaukwJJUs3GYihXP8ebhMb3F2AHu3P",
|
||||
origHDKeyIDPair: HDKeyPairSimNet,
|
||||
newHDKeyIDPair: HDKeyPairMainNet,
|
||||
origHDKeyIDPair: HDKeyPairSimnet,
|
||||
newHDKeyIDPair: HDKeyPairMainnet,
|
||||
newPriv: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi",
|
||||
newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
|
||||
isPrivate: true,
|
||||
@ -697,7 +697,7 @@ func TestNet(t *testing.T) {
|
||||
{
|
||||
name: "mainnet -> regtest",
|
||||
key: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi",
|
||||
origHDKeyIDPair: HDKeyPairMainNet,
|
||||
origHDKeyIDPair: HDKeyPairMainnet,
|
||||
newHDKeyIDPair: HDKeyPairRegressionNet,
|
||||
newPriv: "tprv8ZgxMBicQKsPeDgjzdC36fs6bMjGApWDNLR9erAXMs5skhMv36j9MV5ecvfavji5khqjWaWSFhN3YcCUUdiKH6isR4Pwy3U5y5egddBr16m",
|
||||
newPub: "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp",
|
||||
@ -707,7 +707,7 @@ func TestNet(t *testing.T) {
|
||||
name: "regtest -> mainnet",
|
||||
key: "tprv8ZgxMBicQKsPeDgjzdC36fs6bMjGApWDNLR9erAXMs5skhMv36j9MV5ecvfavji5khqjWaWSFhN3YcCUUdiKH6isR4Pwy3U5y5egddBr16m",
|
||||
origHDKeyIDPair: HDKeyPairRegressionNet,
|
||||
newHDKeyIDPair: HDKeyPairMainNet,
|
||||
newHDKeyIDPair: HDKeyPairMainnet,
|
||||
newPriv: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi",
|
||||
newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
|
||||
isPrivate: true,
|
||||
@ -717,23 +717,23 @@ func TestNet(t *testing.T) {
|
||||
{
|
||||
name: "mainnet -> simnet",
|
||||
key: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
|
||||
origHDKeyIDPair: HDKeyPairMainNet,
|
||||
newHDKeyIDPair: HDKeyPairSimNet,
|
||||
origHDKeyIDPair: HDKeyPairMainnet,
|
||||
newHDKeyIDPair: HDKeyPairSimnet,
|
||||
newPub: "spub4Tr3T2ab61tD1Qa6GHwRFiiKyRRJdfEZpSpXfqgFYCEyaPsqKysqHDjzSzMJSiUEGbcsG3w2SLMoTqn44B8x6u3MLRRkYfACTUBnHK79THk",
|
||||
isPrivate: false,
|
||||
},
|
||||
{
|
||||
name: "simnet -> mainnet",
|
||||
key: "spub4Tr3T2ab61tD1Qa6GHwRFiiKyRRJdfEZpSpXfqgFYCEyaPsqKysqHDjzSzMJSiUEGbcsG3w2SLMoTqn44B8x6u3MLRRkYfACTUBnHK79THk",
|
||||
origHDKeyIDPair: HDKeyPairSimNet,
|
||||
newHDKeyIDPair: HDKeyPairMainNet,
|
||||
origHDKeyIDPair: HDKeyPairSimnet,
|
||||
newHDKeyIDPair: HDKeyPairMainnet,
|
||||
newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
|
||||
isPrivate: false,
|
||||
},
|
||||
{
|
||||
name: "mainnet -> regtest",
|
||||
key: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
|
||||
origHDKeyIDPair: HDKeyPairMainNet,
|
||||
origHDKeyIDPair: HDKeyPairMainnet,
|
||||
newHDKeyIDPair: HDKeyPairRegressionNet,
|
||||
newPub: "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp",
|
||||
isPrivate: false,
|
||||
@ -742,7 +742,7 @@ func TestNet(t *testing.T) {
|
||||
name: "regtest -> mainnet",
|
||||
key: "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp",
|
||||
origHDKeyIDPair: HDKeyPairRegressionNet,
|
||||
newHDKeyIDPair: HDKeyPairMainNet,
|
||||
newHDKeyIDPair: HDKeyPairMainnet,
|
||||
newPub: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8",
|
||||
isPrivate: false,
|
||||
},
|
||||
@ -802,7 +802,7 @@ func TestNet(t *testing.T) {
|
||||
// the errors are handled properly.
|
||||
func TestErrors(t *testing.T) {
|
||||
// Should get an error when seed has too few bytes.
|
||||
hdKeyIDPair := HDKeyPairMainNet
|
||||
hdKeyIDPair := HDKeyPairMainnet
|
||||
_, err := NewMaster(bytes.Repeat([]byte{0x00}, 15), hdKeyIDPair.PrivateKeyID)
|
||||
if err != ErrInvalidSeedLen {
|
||||
t.Fatalf("NewMaster: mismatched error -- got: %v, want: %v",
|
||||
@ -903,7 +903,7 @@ func TestZero(t *testing.T) {
|
||||
name: "test vector 1 chain m",
|
||||
master: "000102030405060708090a0b0c0d0e0f",
|
||||
extKey: "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
|
||||
// Test vector 2
|
||||
@ -911,7 +911,7 @@ func TestZero(t *testing.T) {
|
||||
name: "test vector 2 chain m",
|
||||
master: "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542",
|
||||
extKey: "xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U",
|
||||
hdKeyIDPair: HDKeyPairMainNet,
|
||||
hdKeyIDPair: HDKeyPairMainnet,
|
||||
},
|
||||
}
|
||||
|
||||
@ -1042,7 +1042,7 @@ func TestZero(t *testing.T) {
|
||||
// uint8 to encode the depth. This implicitly bounds the depth of the tree to
|
||||
// 255 derivations. Here we test that an error is returned after 'max uint8'.
|
||||
func TestMaximumDepth(t *testing.T) {
|
||||
extKey, err := NewMaster([]byte(`abcd1234abcd1234abcd1234abcd1234`), HDKeyPairMainNet.PrivateKeyID)
|
||||
extKey, err := NewMaster([]byte(`abcd1234abcd1234abcd1234abcd1234`), HDKeyPairMainnet.PrivateKeyID)
|
||||
if err != nil {
|
||||
t.Fatalf("NewMaster: unexpected error: %v", err)
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ func TestEncodeDecodeWIF(t *testing.T) {
|
||||
0x4e, 0x39, 0x6f, 0xb5, 0xdc, 0x29, 0x5f, 0xe9,
|
||||
0x94, 0xb9, 0x67, 0x89, 0xb2, 0x1a, 0x03, 0x98})
|
||||
|
||||
wif1, err := NewWIF(priv1, dagconfig.MainNetParams.PrivateKeyID, false)
|
||||
wif1, err := NewWIF(priv1, dagconfig.MainnetParams.PrivateKeyID, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wif2, err := NewWIF(priv2, dagconfig.TestNetParams.PrivateKeyID, true)
|
||||
wif2, err := NewWIF(priv2, dagconfig.TestnetParams.PrivateKeyID, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ to a remote node running a kaspa peer. Example syntax is:
|
||||
// Use the most recent protocol version supported by the package and the
|
||||
// main kaspa network.
|
||||
pver := wire.ProtocolVersion
|
||||
kaspanet := wire.MainNet
|
||||
kaspanet := wire.Mainnet
|
||||
|
||||
// Reads and validates the next kaspa message from conn using the
|
||||
// protocol version pver and the kaspa network kaspanet. The returns
|
||||
@ -57,7 +57,7 @@ from a remote peer is:
|
||||
// Use the most recent protocol version supported by the package and the
|
||||
// main bitcoin network.
|
||||
pver := wire.ProtocolVersion
|
||||
kaspanet := wire.MainNet
|
||||
kaspanet := wire.Mainnet
|
||||
|
||||
// Create a new getaddr kaspa message.
|
||||
msg := wire.NewMsgGetAddr()
|
||||
|
@ -22,9 +22,9 @@ func TestBlockHeader(t *testing.T) {
|
||||
t.Errorf("random.Uint64: Error generating nonce: %v", err)
|
||||
}
|
||||
|
||||
hashes := []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash}
|
||||
hashes := []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash}
|
||||
|
||||
merkleHash := mainNetGenesisMerkleRoot
|
||||
merkleHash := mainnetGenesisMerkleRoot
|
||||
acceptedIDMerkleRoot := exampleAcceptedIDMerkleRoot
|
||||
bits := uint32(0x1d00ffff)
|
||||
bh := NewBlockHeader(1, hashes, merkleHash, acceptedIDMerkleRoot, exampleUTXOCommitment, bits, nonce)
|
||||
@ -58,8 +58,8 @@ func TestBlockHeaderWire(t *testing.T) {
|
||||
bits := uint32(0x1d00ffff)
|
||||
baseBlockHdr := &BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
ParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: exampleAcceptedIDMerkleRoot,
|
||||
UTXOCommitment: exampleUTXOCommitment,
|
||||
Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST
|
||||
@ -71,11 +71,11 @@ func TestBlockHeaderWire(t *testing.T) {
|
||||
baseBlockHdrEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainNetGenesisHash
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainnetGenesisHash
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
@ -174,8 +174,8 @@ func TestBlockHeaderSerialize(t *testing.T) {
|
||||
bits := uint32(0x1d00ffff)
|
||||
baseBlockHdr := &BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
ParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: exampleAcceptedIDMerkleRoot,
|
||||
UTXOCommitment: exampleUTXOCommitment,
|
||||
Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 12:15:05 -0600 CST
|
||||
@ -187,11 +187,11 @@ func TestBlockHeaderSerialize(t *testing.T) {
|
||||
baseBlockHdrEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainNetGenesisHash
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainnetGenesisHash
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
@ -263,8 +263,8 @@ func TestBlockHeaderSerializeSize(t *testing.T) {
|
||||
timestamp := time.Unix(0x495fab29, 0) // 2009-01-03 12:15:05 -0600 CST
|
||||
baseBlockHdr := &BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
ParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: &daghash.ZeroHash,
|
||||
UTXOCommitment: &daghash.ZeroHash,
|
||||
Timestamp: timestamp,
|
||||
@ -275,7 +275,7 @@ func TestBlockHeaderSerializeSize(t *testing.T) {
|
||||
genesisBlockHdr := &BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: &daghash.ZeroHash,
|
||||
UTXOCommitment: &daghash.ZeroHash,
|
||||
Timestamp: timestamp,
|
||||
@ -312,8 +312,8 @@ func TestIsGenesis(t *testing.T) {
|
||||
|
||||
baseBlockHdr := &BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
ParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
Timestamp: timestamp,
|
||||
Bits: bits,
|
||||
Nonce: nonce,
|
||||
@ -321,7 +321,7 @@ func TestIsGenesis(t *testing.T) {
|
||||
genesisBlockHdr := &BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
Timestamp: timestamp,
|
||||
Bits: bits,
|
||||
Nonce: nonce,
|
||||
|
@ -15,27 +15,27 @@ import (
|
||||
"github.com/kaspanet/kaspad/util/daghash"
|
||||
)
|
||||
|
||||
// mainNetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// mainnetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// main network (genesis block).
|
||||
var mainNetGenesisHash = &daghash.Hash{
|
||||
var mainnetGenesisHash = &daghash.Hash{
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25,
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,
|
||||
}
|
||||
|
||||
// simNetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// simnetGenesisHash is the hash of the first block in the block DAG for the
|
||||
// simulation test network.
|
||||
var simNetGenesisHash = &daghash.Hash{
|
||||
var simnetGenesisHash = &daghash.Hash{
|
||||
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,
|
||||
}
|
||||
|
||||
// mainNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
// mainnetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
// block for the main network.
|
||||
var mainNetGenesisMerkleRoot = &daghash.Hash{
|
||||
var mainnetGenesisMerkleRoot = &daghash.Hash{
|
||||
0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a,
|
||||
0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,
|
||||
0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,
|
||||
@ -131,7 +131,7 @@ func TestElementWire(t *testing.T) {
|
||||
[]byte{0x01, 0x00, 0x00, 0x00},
|
||||
},
|
||||
{
|
||||
KaspaNet(MainNet),
|
||||
KaspaNet(Mainnet),
|
||||
[]byte{0x1d, 0xf7, 0xdc, 0x3d},
|
||||
},
|
||||
// Type not supported by the "fast" path and requires reflection.
|
||||
@ -218,7 +218,7 @@ func TestElementWireErrors(t *testing.T) {
|
||||
},
|
||||
{ServiceFlag(SFNodeNetwork), 0, io.ErrShortWrite, io.EOF},
|
||||
{InvType(InvTypeTx), 0, io.ErrShortWrite, io.EOF},
|
||||
{KaspaNet(MainNet), 0, io.ErrShortWrite, io.EOF},
|
||||
{KaspaNet(Mainnet), 0, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
|
10
wire/doc.go
10
wire/doc.go
@ -66,11 +66,11 @@ The kaspa network is a magic number which is used to identify the start of a
|
||||
message and which kaspa network the message applies to. This package provides
|
||||
the following constants:
|
||||
|
||||
wire.MainNet
|
||||
wire.TestNet (Test network)
|
||||
wire.RegTest (Regression test network)
|
||||
wire.SimNet (Simulation test network)
|
||||
wire.DevNet (Development network)
|
||||
wire.Mainnet
|
||||
wire.Testnet (Test network)
|
||||
wire.Regtest (Regression test network)
|
||||
wire.Simnet (Simulation test network)
|
||||
wire.Devnet (Development network)
|
||||
|
||||
Determining Message Type
|
||||
|
||||
|
@ -68,7 +68,7 @@ func TestMessage(t *testing.T) {
|
||||
msgFilterAdd := NewMsgFilterAdd([]byte{0x01})
|
||||
msgFilterClear := NewMsgFilterClear()
|
||||
msgFilterLoad := NewMsgFilterLoad([]byte{0x01}, 10, 0, BloomUpdateNone)
|
||||
bh := NewBlockHeader(1, []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash}, &daghash.Hash{}, &daghash.Hash{}, &daghash.Hash{}, 0, 0)
|
||||
bh := NewBlockHeader(1, []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash}, &daghash.Hash{}, &daghash.Hash{}, &daghash.Hash{}, 0, 0)
|
||||
msgMerkleBlock := NewMsgMerkleBlock(bh)
|
||||
msgReject := NewMsgReject("block", RejectDuplicate, "duplicate block")
|
||||
|
||||
@ -79,29 +79,29 @@ func TestMessage(t *testing.T) {
|
||||
kaspaNet KaspaNet // Network to use for wire encoding
|
||||
bytes int // Expected num bytes read/written
|
||||
}{
|
||||
{msgVersion, msgVersion, pver, MainNet, 153},
|
||||
{msgVerack, msgVerack, pver, MainNet, 24},
|
||||
{msgGetAddr, msgGetAddr, pver, MainNet, 26},
|
||||
{msgAddr, msgAddr, pver, MainNet, 27},
|
||||
{msgGetBlockInvs, msgGetBlockInvs, pver, MainNet, 88},
|
||||
{msgBlock, msgBlock, pver, MainNet, 372},
|
||||
{msgInv, msgInv, pver, MainNet, 25},
|
||||
{msgGetData, msgGetData, pver, MainNet, 25},
|
||||
{msgNotFound, msgNotFound, pver, MainNet, 25},
|
||||
{msgTx, msgTx, pver, MainNet, 58},
|
||||
{msgPing, msgPing, pver, MainNet, 32},
|
||||
{msgPong, msgPong, pver, MainNet, 32},
|
||||
{msgGetHeaders, msgGetHeaders, pver, MainNet, 88},
|
||||
{msgGetBlockLocator, msgGetBlockLocator, pver, MainNet, 88},
|
||||
{msgBlockLocator, msgBlockLocator, pver, MainNet, 25},
|
||||
{msgSendHeaders, msgSendHeaders, pver, MainNet, 24},
|
||||
{msgFeeFilter, msgFeeFilter, pver, MainNet, 32},
|
||||
{msgHeaders, msgHeaders, pver, MainNet, 25},
|
||||
{msgFilterAdd, msgFilterAdd, pver, MainNet, 26},
|
||||
{msgFilterClear, msgFilterClear, pver, MainNet, 24},
|
||||
{msgFilterLoad, msgFilterLoad, pver, MainNet, 35},
|
||||
{msgMerkleBlock, msgMerkleBlock, pver, MainNet, 215},
|
||||
{msgReject, msgReject, pver, MainNet, 79},
|
||||
{msgVersion, msgVersion, pver, Mainnet, 153},
|
||||
{msgVerack, msgVerack, pver, Mainnet, 24},
|
||||
{msgGetAddr, msgGetAddr, pver, Mainnet, 26},
|
||||
{msgAddr, msgAddr, pver, Mainnet, 27},
|
||||
{msgGetBlockInvs, msgGetBlockInvs, pver, Mainnet, 88},
|
||||
{msgBlock, msgBlock, pver, Mainnet, 372},
|
||||
{msgInv, msgInv, pver, Mainnet, 25},
|
||||
{msgGetData, msgGetData, pver, Mainnet, 25},
|
||||
{msgNotFound, msgNotFound, pver, Mainnet, 25},
|
||||
{msgTx, msgTx, pver, Mainnet, 58},
|
||||
{msgPing, msgPing, pver, Mainnet, 32},
|
||||
{msgPong, msgPong, pver, Mainnet, 32},
|
||||
{msgGetHeaders, msgGetHeaders, pver, Mainnet, 88},
|
||||
{msgGetBlockLocator, msgGetBlockLocator, pver, Mainnet, 88},
|
||||
{msgBlockLocator, msgBlockLocator, pver, Mainnet, 25},
|
||||
{msgSendHeaders, msgSendHeaders, pver, Mainnet, 24},
|
||||
{msgFeeFilter, msgFeeFilter, pver, Mainnet, 32},
|
||||
{msgHeaders, msgHeaders, pver, Mainnet, 25},
|
||||
{msgFilterAdd, msgFilterAdd, pver, Mainnet, 26},
|
||||
{msgFilterClear, msgFilterClear, pver, Mainnet, 24},
|
||||
{msgFilterLoad, msgFilterLoad, pver, Mainnet, 35},
|
||||
{msgMerkleBlock, msgMerkleBlock, pver, Mainnet, 215},
|
||||
{msgReject, msgReject, pver, Mainnet, 79},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -173,7 +173,7 @@ func TestMessage(t *testing.T) {
|
||||
// concrete messages to confirm error paths work correctly.
|
||||
func TestReadMessageWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
kaspaNet := MainNet
|
||||
kaspaNet := Mainnet
|
||||
|
||||
// Ensure message errors are as expected with no function specified.
|
||||
wantErr := "something bad happened"
|
||||
@ -192,7 +192,7 @@ func TestReadMessageWireErrors(t *testing.T) {
|
||||
}
|
||||
|
||||
// Wire encoded bytes for main and testnet networks magic identifiers.
|
||||
testNetBytes := makeHeader(TestNet, "", 0, 0)
|
||||
testnetBytes := makeHeader(Testnet, "", 0, 0)
|
||||
|
||||
// Wire encoded bytes for a message that exceeds max overall message
|
||||
// length.
|
||||
@ -250,12 +250,12 @@ func TestReadMessageWireErrors(t *testing.T) {
|
||||
0,
|
||||
},
|
||||
|
||||
// Wrong network. Want MainNet, but giving TestNet.
|
||||
// Wrong network. Want Mainnet, but giving Testnet.
|
||||
{
|
||||
testNetBytes,
|
||||
testnetBytes,
|
||||
pver,
|
||||
kaspaNet,
|
||||
len(testNetBytes),
|
||||
len(testnetBytes),
|
||||
&MessageError{},
|
||||
24,
|
||||
},
|
||||
@ -375,7 +375,7 @@ func TestReadMessageWireErrors(t *testing.T) {
|
||||
// concrete messages to confirm error paths work correctly.
|
||||
func TestWriteMessageWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
kaspaNet := MainNet
|
||||
kaspaNet := Mainnet
|
||||
wireErr := &MessageError{}
|
||||
|
||||
// Fake message with a command that is too long.
|
||||
|
@ -409,11 +409,11 @@ func TestBlockOverflowErrors(t *testing.T) {
|
||||
[]byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // mainNetGenesisHash
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // mainnetGenesisHash
|
||||
0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f,
|
||||
0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c,
|
||||
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
@ -503,8 +503,8 @@ func TestBlockSerializeSize(t *testing.T) {
|
||||
var blockOne = MsgBlock{
|
||||
Header: BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash},
|
||||
HashMerkleRoot: mainNetGenesisMerkleRoot,
|
||||
ParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},
|
||||
HashMerkleRoot: mainnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: exampleAcceptedIDMerkleRoot,
|
||||
UTXOCommitment: exampleUTXOCommitment,
|
||||
Timestamp: time.Unix(0x4966bc61, 0), // 2009-01-08 20:54:25 -0600 CST
|
||||
@ -550,11 +550,11 @@ var blockOne = MsgBlock{
|
||||
var blockOneBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainNetGenesisHash
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainnetGenesisHash
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
|
@ -195,10 +195,10 @@ func TestBlockLocatorWireErrors(t *testing.T) {
|
||||
// block locator hashes.
|
||||
maxGetBlocks := NewMsgBlockLocator()
|
||||
for i := 0; i < MaxBlockLocatorsPerMsg; i++ {
|
||||
maxGetBlocks.AddBlockLocatorHash(mainNetGenesisHash)
|
||||
maxGetBlocks.AddBlockLocatorHash(mainnetGenesisHash)
|
||||
}
|
||||
maxGetBlocks.BlockLocatorHashes = append(maxGetBlocks.BlockLocatorHashes,
|
||||
mainNetGenesisHash)
|
||||
mainnetGenesisHash)
|
||||
maxGetBlocksEncoded := []byte{
|
||||
0xfd, 0xf5, 0x01, // Varint for number of block loc hashes (501)
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func TestHeaders(t *testing.T) {
|
||||
// TestHeadersWire tests the MsgHeaders wire encode and decode for various
|
||||
// numbers of headers and protocol versions.
|
||||
func TestHeadersWire(t *testing.T) {
|
||||
hashes := []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash}
|
||||
hashes := []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash}
|
||||
hashMerkleRoot := blockOne.Header.HashMerkleRoot
|
||||
acceptedIDMerkleRoot := blockOne.Header.AcceptedIDMerkleRoot
|
||||
utxoCommitment := blockOne.Header.UTXOCommitment
|
||||
@ -84,11 +84,11 @@ func TestHeadersWire(t *testing.T) {
|
||||
0x01, // VarInt for number of headers.
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainNetGenesisHash
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainnetGenesisHash
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
@ -170,7 +170,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
wireErr := &MessageError{}
|
||||
|
||||
hashes := []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash}
|
||||
hashes := []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash}
|
||||
hashMerkleRoot := blockOne.Header.HashMerkleRoot
|
||||
acceptedIDMerkleRoot := blockOne.Header.AcceptedIDMerkleRoot
|
||||
utxoCommitment := blockOne.Header.UTXOCommitment
|
||||
@ -187,11 +187,11 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
0x01, // VarInt for number of headers.
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // mainNetGenesisHash
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // mainnetGenesisHash
|
||||
0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f,
|
||||
0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c,
|
||||
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
@ -236,11 +236,11 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
0x01, // VarInt for number of headers.
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // mainNetGenesisHash
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, // mainnetGenesisHash
|
||||
0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f,
|
||||
0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c,
|
||||
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
|
@ -323,7 +323,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
|
||||
var merkleBlockOne = MsgMerkleBlock{
|
||||
Header: BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []*daghash.Hash{mainNetGenesisHash, simNetGenesisHash},
|
||||
ParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},
|
||||
HashMerkleRoot: &daghash.Hash{
|
||||
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44,
|
||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||
@ -353,11 +353,11 @@ var merkleBlockOne = MsgMerkleBlock{
|
||||
var merkleBlockOneBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version 1
|
||||
0x02, // NumParentBlocks
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainNetGenesisHash
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainnetGenesisHash
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simNetGenesisHash
|
||||
0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
|
@ -51,7 +51,7 @@ func TestRejectLatest(t *testing.T) {
|
||||
rejCommand := (&MsgBlock{}).Command()
|
||||
rejCode := RejectDuplicate
|
||||
rejReason := "duplicate block"
|
||||
rejHash := mainNetGenesisHash
|
||||
rejHash := mainnetGenesisHash
|
||||
|
||||
// Ensure we get the correct data back out.
|
||||
msg := NewMsgReject(rejCommand, rejCode, rejReason)
|
||||
@ -125,7 +125,7 @@ func TestRejectCrossProtocol(t *testing.T) {
|
||||
rejCommand := (&MsgBlock{}).Command()
|
||||
rejCode := RejectDuplicate
|
||||
rejReason := "duplicate block"
|
||||
rejHash := mainNetGenesisHash
|
||||
rejHash := mainnetGenesisHash
|
||||
|
||||
msg := NewMsgReject(rejCommand, rejCode, rejReason)
|
||||
msg.Hash = rejHash
|
||||
@ -168,7 +168,7 @@ func TestRejectWire(t *testing.T) {
|
||||
Cmd: "block",
|
||||
Code: RejectDuplicate,
|
||||
Reason: "duplicate block",
|
||||
Hash: mainNetGenesisHash,
|
||||
Hash: mainnetGenesisHash,
|
||||
},
|
||||
[]byte{
|
||||
0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, // "block"
|
||||
@ -178,7 +178,7 @@ func TestRejectWire(t *testing.T) {
|
||||
0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25,
|
||||
0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,
|
||||
0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63, // mainNetGenesisHash
|
||||
0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63, // mainnetGenesisHash
|
||||
},
|
||||
ProtocolVersion,
|
||||
},
|
||||
@ -221,7 +221,7 @@ func TestRejectWireErrors(t *testing.T) {
|
||||
pver := ProtocolVersion
|
||||
|
||||
baseReject := NewMsgReject("block", RejectDuplicate, "duplicate block")
|
||||
baseReject.Hash = mainNetGenesisHash
|
||||
baseReject.Hash = mainnetGenesisHash
|
||||
baseRejectEncoded := []byte{
|
||||
0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, // "block"
|
||||
0x12, // RejectDuplicate
|
||||
@ -230,7 +230,7 @@ func TestRejectWireErrors(t *testing.T) {
|
||||
0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72,
|
||||
0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f,
|
||||
0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c,
|
||||
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, // mainNetGenesisHash
|
||||
0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, // mainnetGenesisHash
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
|
@ -97,30 +97,30 @@ type KaspaNet uint32
|
||||
// this package does not provide that functionality since it's generally a
|
||||
// better idea to simply disconnect clients that are misbehaving over TCP.
|
||||
const (
|
||||
// MainNet represents the main kaspa network.
|
||||
MainNet KaspaNet = 0x3ddcf71d
|
||||
// Mainnet represents the main kaspa network.
|
||||
Mainnet KaspaNet = 0x3ddcf71d
|
||||
|
||||
// TestNet represents the test network.
|
||||
TestNet KaspaNet = 0xddb8af8f
|
||||
// Testnet represents the test network.
|
||||
Testnet KaspaNet = 0xddb8af8f
|
||||
|
||||
// RegTest represents the regression test network.
|
||||
RegTest KaspaNet = 0xf396cdd6
|
||||
// Regtest represents the regression test network.
|
||||
Regtest KaspaNet = 0xf396cdd6
|
||||
|
||||
// SimNet represents the simulation test network.
|
||||
SimNet KaspaNet = 0x374dcf1c
|
||||
// Simnet represents the simulation test network.
|
||||
Simnet KaspaNet = 0x374dcf1c
|
||||
|
||||
// DevNet represents the development test network.
|
||||
DevNet KaspaNet = 0x732d87e1
|
||||
// Devnet represents the development test network.
|
||||
Devnet KaspaNet = 0x732d87e1
|
||||
)
|
||||
|
||||
// bnStrings is a map of kaspa networks back to their constant names for
|
||||
// pretty printing.
|
||||
var bnStrings = map[KaspaNet]string{
|
||||
MainNet: "MainNet",
|
||||
TestNet: "TestNet",
|
||||
RegTest: "RegTest",
|
||||
SimNet: "SimNet",
|
||||
DevNet: "DevNet",
|
||||
Mainnet: "Mainnet",
|
||||
Testnet: "Testnet",
|
||||
Regtest: "Regtest",
|
||||
Simnet: "Simnet",
|
||||
Devnet: "Devnet",
|
||||
}
|
||||
|
||||
// String returns the KaspaNet in human-readable form.
|
||||
|
@ -39,10 +39,10 @@ func TestKaspaNetStringer(t *testing.T) {
|
||||
in KaspaNet
|
||||
want string
|
||||
}{
|
||||
{MainNet, "MainNet"},
|
||||
{RegTest, "RegTest"},
|
||||
{TestNet, "TestNet"},
|
||||
{SimNet, "SimNet"},
|
||||
{Mainnet, "Mainnet"},
|
||||
{Regtest, "Regtest"},
|
||||
{Testnet, "Testnet"},
|
||||
{Simnet, "Simnet"},
|
||||
{0xffffffff, "Unknown KaspaNet (4294967295)"},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user