mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-06 22:26:47 +00:00
[NOD-557] Remove RegTest (#889)
* [NOD-557] Remove regTest network. * [NOD-557] Remove remaining references to regTest. * [NOD-557] Move newHashFromStr from params.go to params_test.go. * [NOD-557] Rename test to network in register_test.go. * [NOD-557] Replaced removed tests in TestDecodeAddressErrorConditions.
This commit is contained in:
parent
53ab906ea8
commit
667b2d46e9
@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
||||||
// the main network, regression test network, and test network.
|
// the main network and test network.
|
||||||
var genesisCoinbaseTxIns = []*TxIn{
|
var genesisCoinbaseTxIns = []*TxIn{
|
||||||
{
|
{
|
||||||
PreviousOutpoint: Outpoint{
|
PreviousOutpoint: Outpoint{
|
||||||
|
@ -68,7 +68,6 @@ the following constants:
|
|||||||
|
|
||||||
appmessage.Mainnet
|
appmessage.Mainnet
|
||||||
appmessage.Testnet (Test network)
|
appmessage.Testnet (Test network)
|
||||||
appmessage.Regtest (Regression test network)
|
|
||||||
appmessage.Simnet (Simulation test network)
|
appmessage.Simnet (Simulation test network)
|
||||||
appmessage.Devnet (Development network)
|
appmessage.Devnet (Development network)
|
||||||
|
|
||||||
|
@ -107,9 +107,6 @@ const (
|
|||||||
// Testnet represents the test network.
|
// Testnet represents the test network.
|
||||||
Testnet KaspaNet = 0xddb8af8f
|
Testnet KaspaNet = 0xddb8af8f
|
||||||
|
|
||||||
// Regtest represents the regression test network.
|
|
||||||
Regtest KaspaNet = 0xf396cdd6
|
|
||||||
|
|
||||||
// Simnet represents the simulation test network.
|
// Simnet represents the simulation test network.
|
||||||
Simnet KaspaNet = 0x374dcf1c
|
Simnet KaspaNet = 0x374dcf1c
|
||||||
|
|
||||||
@ -122,7 +119,6 @@ const (
|
|||||||
var bnStrings = map[KaspaNet]string{
|
var bnStrings = map[KaspaNet]string{
|
||||||
Mainnet: "Mainnet",
|
Mainnet: "Mainnet",
|
||||||
Testnet: "Testnet",
|
Testnet: "Testnet",
|
||||||
Regtest: "Regtest",
|
|
||||||
Simnet: "Simnet",
|
Simnet: "Simnet",
|
||||||
Devnet: "Devnet",
|
Devnet: "Devnet",
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ func TestKaspaNetStringer(t *testing.T) {
|
|||||||
want string
|
want string
|
||||||
}{
|
}{
|
||||||
{Mainnet, "Mainnet"},
|
{Mainnet, "Mainnet"},
|
||||||
{Regtest, "Regtest"},
|
|
||||||
{Testnet, "Testnet"},
|
{Testnet, "Testnet"},
|
||||||
{Simnet, "Simnet"},
|
{Simnet, "Simnet"},
|
||||||
{0xffffffff, "Unknown KaspaNet (4294967295)"},
|
{0xffffffff, "Unknown KaspaNet (4294967295)"},
|
||||||
|
@ -172,7 +172,6 @@ func TestFinalityInterval(t *testing.T) {
|
|||||||
&dagconfig.MainnetParams,
|
&dagconfig.MainnetParams,
|
||||||
&dagconfig.TestnetParams,
|
&dagconfig.TestnetParams,
|
||||||
&dagconfig.DevnetParams,
|
&dagconfig.DevnetParams,
|
||||||
&dagconfig.RegressionNetParams,
|
|
||||||
&dagconfig.SimnetParams,
|
&dagconfig.SimnetParams,
|
||||||
}
|
}
|
||||||
for _, params := range netParams {
|
for _, params := range netParams {
|
||||||
|
@ -10,7 +10,6 @@ func TestIsDAGCurrentMaxDiff(t *testing.T) {
|
|||||||
&dagconfig.MainnetParams,
|
&dagconfig.MainnetParams,
|
||||||
&dagconfig.TestnetParams,
|
&dagconfig.TestnetParams,
|
||||||
&dagconfig.DevnetParams,
|
&dagconfig.DevnetParams,
|
||||||
&dagconfig.RegressionNetParams,
|
|
||||||
&dagconfig.SimnetParams,
|
&dagconfig.SimnetParams,
|
||||||
}
|
}
|
||||||
for _, params := range netParams {
|
for _, params := range netParams {
|
||||||
|
@ -6,7 +6,6 @@ of monetary value, there also exists the following standard networks:
|
|||||||
* testnet
|
* testnet
|
||||||
* simnet
|
* simnet
|
||||||
* devnet
|
* devnet
|
||||||
* regression test
|
|
||||||
These networks are incompatible with each other (each sharing a different
|
These networks are incompatible with each other (each sharing a different
|
||||||
genesis block) and software should handle errors where input intended for
|
genesis block) and software should handle errors where input intended for
|
||||||
one network is used on an application instance running on a different
|
one network is used on an application instance running on a different
|
||||||
|
@ -108,55 +108,6 @@ var devnetGenesisBlock = appmessage.MsgBlock{
|
|||||||
Transactions: []*appmessage.MsgTx{devnetGenesisCoinbaseTx},
|
Transactions: []*appmessage.MsgTx{devnetGenesisCoinbaseTx},
|
||||||
}
|
}
|
||||||
|
|
||||||
var regtestGenesisTxOuts = []*appmessage.TxOut{}
|
|
||||||
|
|
||||||
var regtestGenesisTxPayload = []byte{
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Blue score
|
|
||||||
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 = appmessage.NewSubnetworkMsgTx(1, []*appmessage.TxIn{}, 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{
|
|
||||||
0xda, 0x23, 0x61, 0x5e, 0xf6, 0x2a, 0x95, 0x27,
|
|
||||||
0x7f, 0x5a, 0x40, 0xd5, 0x91, 0x97, 0x1c, 0xef,
|
|
||||||
0xd5, 0x86, 0xac, 0xac, 0x82, 0xb3, 0xc9, 0x43,
|
|
||||||
0xd3, 0x49, 0x5f, 0x7e, 0x93, 0x0b, 0x35, 0x2d,
|
|
||||||
}
|
|
||||||
|
|
||||||
// regtestGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
|
||||||
// for the regtest.
|
|
||||||
var regtestGenesisMerkleRoot = daghash.Hash{
|
|
||||||
0x1e, 0x08, 0xae, 0x1f, 0x43, 0xf5, 0xfc, 0x24,
|
|
||||||
0xe6, 0xec, 0x54, 0x5b, 0xf7, 0x52, 0x99, 0xe4,
|
|
||||||
0xcc, 0x4c, 0xa0, 0x79, 0x41, 0xfc, 0xbe, 0x76,
|
|
||||||
0x72, 0x4c, 0x7e, 0xd8, 0xa3, 0x43, 0x65, 0x94,
|
|
||||||
}
|
|
||||||
|
|
||||||
// regtestGenesisBlock defines the genesis block of the block DAG which serves as the
|
|
||||||
// public transaction ledger for the development network.
|
|
||||||
var regtestGenesisBlock = appmessage.MsgBlock{
|
|
||||||
Header: appmessage.BlockHeader{
|
|
||||||
Version: 0x10000000,
|
|
||||||
ParentHashes: []*daghash.Hash{},
|
|
||||||
HashMerkleRoot: ®testGenesisMerkleRoot,
|
|
||||||
AcceptedIDMerkleRoot: &daghash.Hash{},
|
|
||||||
UTXOCommitment: &daghash.ZeroHash,
|
|
||||||
Timestamp: mstime.UnixMilliseconds(0x1730a958ac4),
|
|
||||||
Bits: 0x207fffff,
|
|
||||||
Nonce: 0x0,
|
|
||||||
},
|
|
||||||
Transactions: []*appmessage.MsgTx{regtestGenesisCoinbaseTx},
|
|
||||||
}
|
|
||||||
|
|
||||||
var simnetGenesisTxOuts = []*appmessage.TxOut{}
|
var simnetGenesisTxOuts = []*appmessage.TxOut{}
|
||||||
|
|
||||||
var simnetGenesisTxPayload = []byte{
|
var simnetGenesisTxPayload = []byte{
|
||||||
|
@ -37,33 +37,6 @@ func TestGenesisBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestRegtestGenesisBlock tests the genesis block of the regression test
|
|
||||||
// network for validity by checking the encoded bytes and hashes.
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the encoded block matches the expected bytes.
|
|
||||||
if !bytes.Equal(buf.Bytes(), regtestGenesisBlockBytes) {
|
|
||||||
t.Fatalf("TestRegtestGenesisBlock: Genesis block does not "+
|
|
||||||
"appear valid - got %v, want %v",
|
|
||||||
spew.Sdump(buf.Bytes()),
|
|
||||||
spew.Sdump(regtestGenesisBlockBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check hash of the block against expected hash.
|
|
||||||
hash := RegressionNetParams.GenesisBlock.BlockHash()
|
|
||||||
if !RegressionNetParams.GenesisHash.IsEqual(hash) {
|
|
||||||
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.
|
// validity by checking the encoded bytes and hashes.
|
||||||
func TestTestnetGenesisBlock(t *testing.T) {
|
func TestTestnetGenesisBlock(t *testing.T) {
|
||||||
@ -165,27 +138,6 @@ var genesisBlockBytes = []byte{
|
|||||||
0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
||||||
}
|
}
|
||||||
|
|
||||||
// regtestGenesisBlockBytes are the encoded bytes for the genesis block of
|
|
||||||
// the regression test network as of protocol version 1.
|
|
||||||
var regtestGenesisBlockBytes = []byte{
|
|
||||||
0x00, 0x00, 0x00, 0x10, 0x00, 0x1e, 0x08, 0xae, 0x1f, 0x43, 0xf5, 0xfc, 0x24, 0xe6, 0xec, 0x54,
|
|
||||||
0x5b, 0xf7, 0x52, 0x99, 0xe4, 0xcc, 0x4c, 0xa0, 0x79, 0x41, 0xfc, 0xbe, 0x76, 0x72, 0x4c, 0x7e,
|
|
||||||
0xd8, 0xa3, 0x43, 0x65, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x8a, 0x95, 0x0a, 0x73, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
|
||||||
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 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, 0xd4, 0xc4, 0x87, 0x77, 0xf2, 0xe7, 0x5d, 0xf7, 0xff, 0x2d, 0xbb, 0xb6,
|
|
||||||
0x2a, 0x73, 0x1f, 0x54, 0x36, 0x33, 0xa7, 0x99, 0xad, 0xb1, 0x09, 0x65, 0xc0, 0xf0, 0xf4, 0x53,
|
|
||||||
0xba, 0xfb, 0x88, 0xae, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 encoded bytes for the genesis block of
|
// testnetGenesisBlockBytes are the encoded bytes for the genesis block of
|
||||||
// the test network as of protocol version 1.
|
// the test network as of protocol version 1.
|
||||||
var testnetGenesisBlockBytes = []byte{
|
var testnetGenesisBlockBytes = []byte{
|
||||||
|
@ -27,10 +27,6 @@ var (
|
|||||||
// have for the main network. It is the value 2^255 - 1.
|
// have for the main network. It is the value 2^255 - 1.
|
||||||
mainPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
mainPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||||
|
|
||||||
// regressionPowMax is the highest proof of work value a Kaspa block
|
|
||||||
// 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^239 - 1.
|
// can have for the test network. It is the value 2^239 - 1.
|
||||||
testnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
|
testnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
|
||||||
@ -53,37 +49,6 @@ const (
|
|||||||
targetTimePerBlock = 1 * time.Second
|
targetTimePerBlock = 1 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsensusDeployment defines details related to a specific consensus rule
|
|
||||||
// change that is voted in. This is part of BIP0009.
|
|
||||||
type ConsensusDeployment struct {
|
|
||||||
// BitNumber defines the specific bit number within the block version
|
|
||||||
// this particular soft-fork deployment refers to.
|
|
||||||
BitNumber uint8
|
|
||||||
|
|
||||||
// StartTime is the median block time after which voting on the
|
|
||||||
// deployment starts.
|
|
||||||
StartTime uint64
|
|
||||||
|
|
||||||
// ExpireTime is the median block time after which the attempted
|
|
||||||
// deployment expires.
|
|
||||||
ExpireTime uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constants that define the deployment offset in the deployments field of the
|
|
||||||
// parameters for each deployment. This is useful to be able to get the details
|
|
||||||
// of a specific deployment by name.
|
|
||||||
const (
|
|
||||||
// DeploymentTestDummy defines the rule change deployment ID for testing
|
|
||||||
// purposes.
|
|
||||||
DeploymentTestDummy = iota
|
|
||||||
|
|
||||||
// NOTE: DefinedDeployments must always come last since it is used to
|
|
||||||
// determine how many defined deployments there currently are.
|
|
||||||
|
|
||||||
// DefinedDeployments is the number of currently defined deployments.
|
|
||||||
DefinedDeployments
|
|
||||||
)
|
|
||||||
|
|
||||||
// KType defines the size of GHOSTDAG consensus algorithm K parameter.
|
// KType defines the size of GHOSTDAG consensus algorithm K parameter.
|
||||||
type KType uint8
|
type KType uint8
|
||||||
|
|
||||||
@ -232,54 +197,6 @@ var MainnetParams = Params{
|
|||||||
DisableDifficultyAdjustment: false,
|
DisableDifficultyAdjustment: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegressionNetParams defines the network parameters for the regression test
|
|
||||||
// Kaspa network. Not to be confused with the test Kaspa network (version
|
|
||||||
// 3), this network is sometimes simply called "testnet".
|
|
||||||
var RegressionNetParams = Params{
|
|
||||||
K: ghostdagK,
|
|
||||||
Name: "kaspa-regtest",
|
|
||||||
Net: appmessage.Regtest,
|
|
||||||
RPCPort: "16210",
|
|
||||||
DefaultPort: "16211",
|
|
||||||
DNSSeeds: []string{},
|
|
||||||
|
|
||||||
// DAG parameters
|
|
||||||
GenesisBlock: ®testGenesisBlock,
|
|
||||||
GenesisHash: ®testGenesisHash,
|
|
||||||
PowMax: regressionPowMax,
|
|
||||||
BlockCoinbaseMaturity: 100,
|
|
||||||
SubsidyReductionInterval: 150,
|
|
||||||
TargetTimePerBlock: targetTimePerBlock,
|
|
||||||
FinalityDuration: finalityDuration,
|
|
||||||
DifficultyAdjustmentWindowSize: difficultyAdjustmentWindowSize,
|
|
||||||
TimestampDeviationTolerance: timestampDeviationTolerance,
|
|
||||||
|
|
||||||
// Consensus rule change deployments.
|
|
||||||
//
|
|
||||||
// The miner confirmation window is defined as:
|
|
||||||
// target proof of work timespan / target proof of work spacing
|
|
||||||
RuleChangeActivationThreshold: 108, // 75% of MinerConfirmationWindow
|
|
||||||
MinerConfirmationWindow: 144,
|
|
||||||
|
|
||||||
// Mempool parameters
|
|
||||||
RelayNonStdTxs: true,
|
|
||||||
|
|
||||||
// AcceptUnroutable specifies whether this network accepts unroutable
|
|
||||||
// IP addresses, such as 10.0.0.0/8
|
|
||||||
AcceptUnroutable: false,
|
|
||||||
|
|
||||||
// Human-readable part for Bech32 encoded addresses
|
|
||||||
Prefix: util.Bech32PrefixKaspaReg,
|
|
||||||
|
|
||||||
// Address encoding magics
|
|
||||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
|
||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
|
||||||
EnableNonNativeSubnetworks: false,
|
|
||||||
|
|
||||||
DisableDifficultyAdjustment: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||||
var TestnetParams = Params{
|
var TestnetParams = Params{
|
||||||
K: ghostdagK,
|
K: ghostdagK,
|
||||||
@ -459,29 +376,9 @@ func mustRegister(params *Params) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHashFromStr converts the passed big-endian hex string into a
|
|
||||||
// daghash.Hash. It only differs from the one available in daghash in that
|
|
||||||
// it panics on an error since it will only (and must only) be called with
|
|
||||||
// hard-coded, and therefore known good, hashes.
|
|
||||||
func newHashFromStr(hexStr string) *daghash.Hash {
|
|
||||||
hash, err := daghash.NewHashFromStr(hexStr)
|
|
||||||
if err != nil {
|
|
||||||
// Ordinarily I don't like panics in library code since it
|
|
||||||
// can take applications down without them having a chance to
|
|
||||||
// recover which is extremely annoying, however an exception is
|
|
||||||
// being made in this case because the only way this can panic
|
|
||||||
// is if there is an error in the hard-coded hashes. Thus it
|
|
||||||
// will only ever potentially panic on init and therefore is
|
|
||||||
// 100% predictable.
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return hash
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Register all default networks when the package is initialized.
|
// Register all default networks when the package is initialized.
|
||||||
mustRegister(&MainnetParams)
|
mustRegister(&MainnetParams)
|
||||||
mustRegister(&TestnetParams)
|
mustRegister(&TestnetParams)
|
||||||
mustRegister(&RegressionNetParams)
|
|
||||||
mustRegister(&SimnetParams)
|
mustRegister(&SimnetParams)
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,17 @@ func TestNewHashFromStr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newHashFromStr converts the passed big-endian hex string into a
|
||||||
|
// daghash.Hash. It only differs from the one available in daghash in that
|
||||||
|
// it panics on an error since it will only be called from tests.
|
||||||
|
func newHashFromStr(hexStr string) *daghash.Hash {
|
||||||
|
hash, err := daghash.NewHashFromStr(hexStr)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return hash
|
||||||
|
}
|
||||||
|
|
||||||
// TestMustRegisterPanic ensures the mustRegister function panics when used to
|
// TestMustRegisterPanic ensures the mustRegister function panics when used to
|
||||||
// register an invalid network.
|
// register an invalid network.
|
||||||
func TestMustRegisterPanic(t *testing.T) {
|
func TestMustRegisterPanic(t *testing.T) {
|
||||||
|
@ -33,11 +33,6 @@ func TestRegister(t *testing.T) {
|
|||||||
params: &MainnetParams,
|
params: &MainnetParams,
|
||||||
err: ErrDuplicateNet,
|
err: ErrDuplicateNet,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "duplicate regtest",
|
|
||||||
params: &RegressionNetParams,
|
|
||||||
err: ErrDuplicateNet,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "duplicate testnet",
|
name: "duplicate testnet",
|
||||||
params: &TestnetParams,
|
params: &TestnetParams,
|
||||||
@ -68,11 +63,6 @@ func TestRegister(t *testing.T) {
|
|||||||
params: &MainnetParams,
|
params: &MainnetParams,
|
||||||
err: ErrDuplicateNet,
|
err: ErrDuplicateNet,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "duplicate regtest",
|
|
||||||
params: &RegressionNetParams,
|
|
||||||
err: ErrDuplicateNet,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "duplicate testnet",
|
name: "duplicate testnet",
|
||||||
params: &TestnetParams,
|
params: &TestnetParams,
|
||||||
@ -93,12 +83,12 @@ func TestRegister(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
for _, regtest := range test.register {
|
for _, network := range test.register {
|
||||||
err := Register(regtest.params)
|
err := Register(network.params)
|
||||||
|
|
||||||
if err != regtest.err {
|
if err != network.err {
|
||||||
t.Errorf("%s:%s: Registered network with unexpected error: got %v expected %v",
|
t.Errorf("%s:%s: Registered network with unexpected error: got %v expected %v",
|
||||||
test.name, regtest.name, err, regtest.err)
|
network.name, network.name, err, network.err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,8 +171,8 @@ func (b *ScriptBuilder) addData(data []byte) *ScriptBuilder {
|
|||||||
// AddFullData should not typically be used by ordinary users as it does not
|
// AddFullData should not typically be used by ordinary users as it does not
|
||||||
// include the checks which prevent data pushes larger than the maximum allowed
|
// include the checks which prevent data pushes larger than the maximum allowed
|
||||||
// sizes which leads to scripts that can't be executed. This is provided for
|
// sizes which leads to scripts that can't be executed. This is provided for
|
||||||
// testing purposes such as regression tests where sizes are intentionally made
|
// testing purposes such as tests where sizes are intentionally made larger
|
||||||
// larger than allowed.
|
// than allowed.
|
||||||
//
|
//
|
||||||
// Use AddData instead.
|
// Use AddData instead.
|
||||||
func (b *ScriptBuilder) AddFullData(data []byte) *ScriptBuilder {
|
func (b *ScriptBuilder) AddFullData(data []byte) *ScriptBuilder {
|
||||||
|
@ -247,7 +247,7 @@ func TestScriptBuilderAddData(t *testing.T) {
|
|||||||
|
|
||||||
// Additional tests for the PushFullData function that
|
// Additional tests for the PushFullData function that
|
||||||
// intentionally allows data pushes to exceed the limit for
|
// intentionally allows data pushes to exceed the limit for
|
||||||
// regression testing purposes.
|
// testing purposes.
|
||||||
|
|
||||||
// 3-byte data push via OP_PUSHDATA_2.
|
// 3-byte data push via OP_PUSHDATA_2.
|
||||||
{
|
{
|
||||||
|
@ -262,7 +262,7 @@ func LoadConfig() (cfg *Config, remainingArgs []string, err error) {
|
|||||||
cfg = &Config{
|
cfg = &Config{
|
||||||
Flags: cfgFlags,
|
Flags: cfgFlags,
|
||||||
}
|
}
|
||||||
if !(preCfg.RegressionTest || preCfg.Simnet) || preCfg.ConfigFile !=
|
if !preCfg.Simnet || preCfg.ConfigFile !=
|
||||||
defaultConfigFile {
|
defaultConfigFile {
|
||||||
|
|
||||||
if _, err := os.Stat(preCfg.ConfigFile); os.IsNotExist(err) {
|
if _, err := os.Stat(preCfg.ConfigFile); os.IsNotExist(err) {
|
||||||
@ -285,11 +285,6 @@ func LoadConfig() (cfg *Config, remainingArgs []string, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't add peers from the config file when in regression test mode.
|
|
||||||
if preCfg.RegressionTest && len(cfg.AddPeers) > 0 {
|
|
||||||
cfg.AddPeers = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse command line options again to ensure they take precedence.
|
// Parse command line options again to ensure they take precedence.
|
||||||
remainingArgs, err = parser.Parse()
|
remainingArgs, err = parser.Parse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
// NetworkFlags holds the network configuration, that is which network is selected.
|
// NetworkFlags holds the network configuration, that is which network is selected.
|
||||||
type NetworkFlags struct {
|
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"`
|
Simnet bool `long:"simnet" description:"Use the simulation test network"`
|
||||||
Devnet bool `long:"devnet" description:"Use the development test network"`
|
Devnet bool `long:"devnet" description:"Use the development test network"`
|
||||||
ActiveNetParams *dagconfig.Params
|
ActiveNetParams *dagconfig.Params
|
||||||
@ -31,10 +30,6 @@ func (networkFlags *NetworkFlags) ResolveNetwork(parser *flags.Parser) error {
|
|||||||
numNets++
|
numNets++
|
||||||
networkFlags.ActiveNetParams = &dagconfig.TestnetParams
|
networkFlags.ActiveNetParams = &dagconfig.TestnetParams
|
||||||
}
|
}
|
||||||
if networkFlags.RegressionTest {
|
|
||||||
numNets++
|
|
||||||
networkFlags.ActiveNetParams = &dagconfig.RegressionNetParams
|
|
||||||
}
|
|
||||||
if networkFlags.Simnet {
|
if networkFlags.Simnet {
|
||||||
numNets++
|
numNets++
|
||||||
networkFlags.ActiveNetParams = &dagconfig.SimnetParams
|
networkFlags.ActiveNetParams = &dagconfig.SimnetParams
|
||||||
|
@ -102,10 +102,8 @@ func handleGetBlockTemplate(s *Server, cmd interface{}, closeChan <-chan struct{
|
|||||||
func handleGetBlockTemplateRequest(s *Server, request *model.TemplateRequest, closeChan <-chan struct{}) (interface{}, error) {
|
func handleGetBlockTemplateRequest(s *Server, request *model.TemplateRequest, closeChan <-chan struct{}) (interface{}, error) {
|
||||||
// Return an error if there are no peers connected since there is no
|
// Return an error if there are no peers connected since there is no
|
||||||
// way to relay a found block or receive transactions to work on.
|
// way to relay a found block or receive transactions to work on.
|
||||||
// However, allow this state when running in the regression test or
|
// However, allow this state when running in the simulation test mode.
|
||||||
// simulation test mode.
|
if !s.cfg.Simnet && s.connectionManager.ConnectionCount() == 0 {
|
||||||
if !(s.cfg.RegressionTest || s.cfg.Simnet) &&
|
|
||||||
s.connectionManager.ConnectionCount() == 0 {
|
|
||||||
|
|
||||||
return nil, &model.RPCError{
|
return nil, &model.RPCError{
|
||||||
Code: model.ErrRPCClientNotConnected,
|
Code: model.ErrRPCClientNotConnected,
|
||||||
|
3
main.go
3
main.go
@ -165,9 +165,6 @@ func removeDatabase(cfg *config.Config) error {
|
|||||||
return os.RemoveAll(dbPath)
|
return os.RemoveAll(dbPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeRegressionDB removes the existing regression test database if running
|
|
||||||
// in regression test mode and it already exists.
|
|
||||||
|
|
||||||
// dbPath returns the path to the block database given a database type.
|
// dbPath returns the path to the block database given a database type.
|
||||||
func blockDbPath(cfg *config.Config) string {
|
func blockDbPath(cfg *config.Config) string {
|
||||||
// The database name is based on the database type.
|
// The database name is based on the database type.
|
||||||
|
@ -12,10 +12,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrChecksumMismatch describes an error where decoding failed due
|
|
||||||
// to a bad checksum.
|
|
||||||
ErrChecksumMismatch = errors.New("checksum mismatch")
|
|
||||||
|
|
||||||
// ErrUnknownAddressType describes an error where an address can not
|
// ErrUnknownAddressType describes an error where an address can not
|
||||||
// decoded as a specific address type due to the string encoding
|
// decoded as a specific address type due to the string encoding
|
||||||
// begining with an identifier byte unknown to any standard or
|
// begining with an identifier byte unknown to any standard or
|
||||||
@ -46,9 +42,6 @@ const (
|
|||||||
// Prefix for the dev network.
|
// Prefix for the dev network.
|
||||||
Bech32PrefixKaspaDev
|
Bech32PrefixKaspaDev
|
||||||
|
|
||||||
// Prefix for the regression test network.
|
|
||||||
Bech32PrefixKaspaReg
|
|
||||||
|
|
||||||
// Prefix for the test network.
|
// Prefix for the test network.
|
||||||
Bech32PrefixKaspaTest
|
Bech32PrefixKaspaTest
|
||||||
|
|
||||||
@ -60,7 +53,6 @@ const (
|
|||||||
var stringsToBech32Prefixes = map[string]Bech32Prefix{
|
var stringsToBech32Prefixes = map[string]Bech32Prefix{
|
||||||
"kaspa": Bech32PrefixKaspa,
|
"kaspa": Bech32PrefixKaspa,
|
||||||
"kaspadev": Bech32PrefixKaspaDev,
|
"kaspadev": Bech32PrefixKaspaDev,
|
||||||
"kaspareg": Bech32PrefixKaspaReg,
|
|
||||||
"kaspatest": Bech32PrefixKaspaTest,
|
"kaspatest": Bech32PrefixKaspaTest,
|
||||||
"kaspasim": Bech32PrefixKaspaSim,
|
"kaspasim": Bech32PrefixKaspaSim,
|
||||||
}
|
}
|
||||||
|
@ -321,18 +321,13 @@ func TestDecodeAddressErrorConditions(t *testing.T) {
|
|||||||
"decoded address's prefix could not be parsed",
|
"decoded address's prefix could not be parsed",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kaspareg:qpm2qsznhks23z7629mms6s4cwef74vcwv4w75h796",
|
"kaspasim:raskzctpv9skzctpv9skzctpv9skzctpvy37ct7zaf",
|
||||||
util.Bech32PrefixKaspaTest,
|
util.Bech32PrefixKaspaSim,
|
||||||
"decoded address is of wrong network",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"kaspareg:raskzctpv9skzctpv9skzctpv9skzctpvyn6vmqa89",
|
|
||||||
util.Bech32PrefixKaspaReg,
|
|
||||||
"unknown address type",
|
"unknown address type",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kaspareg:raskzcgrjj7l73l",
|
"kaspasim:raskzcg58mth0an",
|
||||||
util.Bech32PrefixKaspaReg,
|
util.Bech32PrefixKaspaSim,
|
||||||
"decoded address is of unknown size",
|
"decoded address is of unknown size",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -360,7 +355,6 @@ func TestParsePrefix(t *testing.T) {
|
|||||||
expectedError bool
|
expectedError bool
|
||||||
}{
|
}{
|
||||||
{"kaspa", util.Bech32PrefixKaspa, false},
|
{"kaspa", util.Bech32PrefixKaspa, false},
|
||||||
{"kaspareg", util.Bech32PrefixKaspaReg, false},
|
|
||||||
{"kaspatest", util.Bech32PrefixKaspaTest, false},
|
{"kaspatest", util.Bech32PrefixKaspaTest, false},
|
||||||
{"kaspasim", util.Bech32PrefixKaspaSim, false},
|
{"kaspasim", util.Bech32PrefixKaspaSim, false},
|
||||||
{"blabla", util.Bech32PrefixUnknown, true},
|
{"blabla", util.Bech32PrefixUnknown, true},
|
||||||
@ -388,7 +382,6 @@ func TestPrefixToString(t *testing.T) {
|
|||||||
expectedPrefixStr string
|
expectedPrefixStr string
|
||||||
}{
|
}{
|
||||||
{util.Bech32PrefixKaspa, "kaspa"},
|
{util.Bech32PrefixKaspa, "kaspa"},
|
||||||
{util.Bech32PrefixKaspaReg, "kaspareg"},
|
|
||||||
{util.Bech32PrefixKaspaTest, "kaspatest"},
|
{util.Bech32PrefixKaspaTest, "kaspatest"},
|
||||||
{util.Bech32PrefixKaspaSim, "kaspasim"},
|
{util.Bech32PrefixKaspaSim, "kaspasim"},
|
||||||
{util.Bech32PrefixUnknown, ""},
|
{util.Bech32PrefixUnknown, ""},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user