mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-05 13:46:42 +00:00
[NOD-1548] Remove PoW check from tests (#1105)
* [NOD-1548] Add TestDifficulty and remove PoW check from tests * [NOD-1548] Add TestSkipProofOfWork * [NOD-1548] Remove TestDifficulty
This commit is contained in:
parent
5b037950d8
commit
8500acd86b
@ -2,7 +2,6 @@ package consensus
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
@ -130,7 +129,7 @@ func (f *factory) NewConsensus(dagParams *dagconfig.Params, db infrastructuredat
|
||||
ghostdagDataStore)
|
||||
blockValidator := blockvalidator.New(
|
||||
dagParams.PowMax,
|
||||
false,
|
||||
dagParams.SkipProofOfWork,
|
||||
genesisHash,
|
||||
dagParams.EnableNonNativeSubnetworks,
|
||||
dagParams.DisableDifficultyAdjustment,
|
||||
@ -324,7 +323,6 @@ func (f *factory) NewTestConsensus(dagParams *dagconfig.Params, testName string)
|
||||
testConsensusStateManager := consensusstatemanager.NewTestConsensusStateManager(consensusAsImplementation.consensusStateManager)
|
||||
|
||||
tstConsensus := &testConsensus{
|
||||
rd: rand.New(rand.NewSource(0)),
|
||||
consensus: consensusAsImplementation,
|
||||
testConsensusStateManager: testConsensusStateManager,
|
||||
testReachabilityManager: reachabilitymanager.NewTestReachabilityManager(consensusAsImplementation.
|
||||
|
@ -19,8 +19,6 @@ type TestConsensus interface {
|
||||
AddBlock(parentHashes []*externalapi.DomainHash, coinbaseData *externalapi.DomainCoinbaseData,
|
||||
transactions []*externalapi.DomainTransaction) (*externalapi.DomainHash, error)
|
||||
|
||||
SolveAndAddBlock(block *externalapi.DomainBlock) (*externalapi.DomainHash, error)
|
||||
|
||||
DiscardAllStores()
|
||||
|
||||
AcceptanceDataStore() model.AcceptanceDataStore
|
||||
|
@ -145,8 +145,8 @@ func (bb *blockBuilder) newBlockTime() (int64, error) {
|
||||
// timestamp is truncated to a millisecond boundary before comparison since a
|
||||
// block timestamp does not supported a precision greater than one
|
||||
// millisecond.
|
||||
newTimestamp := mstime.Now().UnixMilliseconds() + 1
|
||||
minTimestamp, err := bb.pastMedianTimeManager.PastMedianTime(model.VirtualBlockHash)
|
||||
newTimestamp := mstime.Now().UnixMilliseconds()
|
||||
minTimestamp, err := bb.minBlockTime(model.VirtualBlockHash)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -156,6 +156,15 @@ func (bb *blockBuilder) newBlockTime() (int64, error) {
|
||||
return newTimestamp, nil
|
||||
}
|
||||
|
||||
func (bb *blockBuilder) minBlockTime(hash *externalapi.DomainHash) (int64, error) {
|
||||
pastMedianTime, err := bb.pastMedianTimeManager.PastMedianTime(hash)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return pastMedianTime + 1, nil
|
||||
}
|
||||
|
||||
func (bb *blockBuilder) newBlockDifficulty() (uint32, error) {
|
||||
return bb.difficultyManager.RequiredDifficulty(model.VirtualBlockHash)
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
type testBlockBuilder struct {
|
||||
*blockBuilder
|
||||
testConsensus testapi.TestConsensus
|
||||
nonceCounter uint64
|
||||
}
|
||||
|
||||
var tempBlockHash = &externalapi.DomainHash{
|
||||
@ -35,15 +36,16 @@ func (bb *testBlockBuilder) BuildBlockWithParents(parentHashes []*externalapi.Do
|
||||
return bb.buildBlockWithParents(parentHashes, coinbaseData, transactions)
|
||||
}
|
||||
|
||||
func (bb testBlockBuilder) buildHeaderWithParents(parentHashes []*externalapi.DomainHash,
|
||||
func (bb *testBlockBuilder) buildHeaderWithParents(parentHashes []*externalapi.DomainHash,
|
||||
transactions []*externalapi.DomainTransaction, acceptanceData model.AcceptanceData, multiset model.Multiset) (
|
||||
*externalapi.DomainBlockHeader, error) {
|
||||
|
||||
timeInMilliseconds, err := bb.pastMedianTimeManager.PastMedianTime(tempBlockHash)
|
||||
timeInMilliseconds, err := bb.minBlockTime(tempBlockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
bits, err := bb.newBlockDifficulty()
|
||||
|
||||
bits, err := bb.difficultyManager.RequiredDifficulty(tempBlockHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -54,6 +56,7 @@ func (bb testBlockBuilder) buildHeaderWithParents(parentHashes []*externalapi.Do
|
||||
}
|
||||
utxoCommitment := multiset.Hash()
|
||||
|
||||
bb.nonceCounter++
|
||||
return &externalapi.DomainBlockHeader{
|
||||
Version: constants.BlockVersion,
|
||||
ParentHashes: parentHashes,
|
||||
@ -62,6 +65,7 @@ func (bb testBlockBuilder) buildHeaderWithParents(parentHashes []*externalapi.Do
|
||||
UTXOCommitment: *utxoCommitment,
|
||||
TimeInMilliseconds: timeInMilliseconds,
|
||||
Bits: bits,
|
||||
Nonce: bb.nonceCounter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ func (v *blockValidator) validateMedianTime(header *externalapi.DomainBlockHeade
|
||||
return err
|
||||
}
|
||||
|
||||
if header.TimeInMilliseconds < pastMedianTime {
|
||||
if header.TimeInMilliseconds <= pastMedianTime {
|
||||
return errors.Wrapf(ruleerrors.ErrTimeTooOld, "block timestamp of %d is not after expected %d",
|
||||
header.TimeInMilliseconds, pastMedianTime)
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
func TestIsAncestorOf(t *testing.T) {
|
||||
testutils.ForAllNets(t, true, func(t *testing.T, params *dagconfig.Params) {
|
||||
factory := consensus.NewFactory()
|
||||
tc, tearDown, err := factory.NewTestConsensus(params, "TestIsInPast")
|
||||
tc, tearDown, err := factory.NewTestConsensus(params, "TestIsAncestorOf")
|
||||
if err != nil {
|
||||
t.Fatalf("NewTestConsensus: %s", err)
|
||||
}
|
||||
|
@ -108,12 +108,12 @@ func TestBlueBlockWindow(t *testing.T) {
|
||||
{
|
||||
parents: []string{"D", "C"},
|
||||
id: "E",
|
||||
expectedWindowWithGenesisPadding: []string{"D", "C", "B", "A", "A", "A", "A", "A", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"C", "D", "B", "A", "A", "A", "A", "A", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"D", "C"},
|
||||
id: "F",
|
||||
expectedWindowWithGenesisPadding: []string{"D", "C", "B", "A", "A", "A", "A", "A", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"C", "D", "B", "A", "A", "A", "A", "A", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"A"},
|
||||
@ -128,37 +128,37 @@ func TestBlueBlockWindow(t *testing.T) {
|
||||
{
|
||||
parents: []string{"H", "F"},
|
||||
id: "I",
|
||||
expectedWindowWithGenesisPadding: []string{"F", "D", "C", "B", "A", "A", "A", "A", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"F", "C", "D", "B", "A", "A", "A", "A", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"I"},
|
||||
id: "J",
|
||||
expectedWindowWithGenesisPadding: []string{"I", "F", "D", "C", "B", "A", "A", "A", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"I", "F", "C", "D", "B", "A", "A", "A", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"J"},
|
||||
id: "K",
|
||||
expectedWindowWithGenesisPadding: []string{"J", "I", "F", "D", "C", "B", "A", "A", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"J", "I", "F", "C", "D", "B", "A", "A", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"K"},
|
||||
id: "L",
|
||||
expectedWindowWithGenesisPadding: []string{"K", "J", "I", "F", "D", "C", "B", "A", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"K", "J", "I", "F", "C", "D", "B", "A", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"L"},
|
||||
id: "M",
|
||||
expectedWindowWithGenesisPadding: []string{"L", "K", "J", "I", "F", "D", "C", "B", "A", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"L", "K", "J", "I", "F", "C", "D", "B", "A", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"M"},
|
||||
id: "N",
|
||||
expectedWindowWithGenesisPadding: []string{"M", "L", "K", "J", "I", "F", "D", "C", "B", "A"},
|
||||
expectedWindowWithGenesisPadding: []string{"M", "L", "K", "J", "I", "F", "C", "D", "B", "A"},
|
||||
},
|
||||
{
|
||||
parents: []string{"N"},
|
||||
id: "O",
|
||||
expectedWindowWithGenesisPadding: []string{"N", "M", "L", "K", "J", "I", "F", "D", "C", "B"},
|
||||
expectedWindowWithGenesisPadding: []string{"N", "M", "L", "K", "J", "I", "F", "C", "D", "B"},
|
||||
},
|
||||
},
|
||||
"kaspa-devnet": {
|
||||
|
@ -3,6 +3,7 @@ package pastmediantimemanager_test
|
||||
import (
|
||||
"github.com/kaspanet/kaspad/domain/consensus"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/testutils"
|
||||
"github.com/kaspanet/kaspad/domain/dagconfig"
|
||||
"testing"
|
||||
@ -29,12 +30,12 @@ func TestPastMedianTime(t *testing.T) {
|
||||
}
|
||||
|
||||
block.Header.TimeInMilliseconds = blockTime
|
||||
blockHash, err := tc.SolveAndAddBlock(block)
|
||||
err = tc.ValidateAndInsertBlock(block)
|
||||
if err != nil {
|
||||
t.Fatalf("SolveAndAddBlock: %s", err)
|
||||
t.Fatalf("ValidateAndInsertBlock: %+v", err)
|
||||
}
|
||||
|
||||
blockHashes[i] = blockHash
|
||||
blockHashes[i] = consensusserialization.BlockHash(block)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
|
@ -1,18 +1,13 @@
|
||||
package consensus
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/mining"
|
||||
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization"
|
||||
)
|
||||
|
||||
type testConsensus struct {
|
||||
*consensus
|
||||
rd *rand.Rand
|
||||
|
||||
testBlockBuilder model.TestBlockBuilder
|
||||
testReachabilityManager model.TestReachabilityManager
|
||||
@ -41,13 +36,7 @@ func (tc *testConsensus) AddBlock(parentHashes []*externalapi.DomainHash, coinba
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return tc.SolveAndAddBlock(block)
|
||||
}
|
||||
|
||||
func (tc *testConsensus) SolveAndAddBlock(block *externalapi.DomainBlock) (*externalapi.DomainHash, error) {
|
||||
mining.SolveBlock(block, tc.rd)
|
||||
|
||||
err := tc.blockProcessor.ValidateAndInsertBlock(block)
|
||||
err = tc.blockProcessor.ValidateAndInsertBlock(block)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
// ForAllNets runs the passed testFunc with all available networks
|
||||
// if setDifficultyToMinumum = true - will modify the net params to have minimal difficulty, like in SimNet
|
||||
func ForAllNets(t *testing.T, setDifficultyToMinimum bool, testFunc func(*testing.T, *dagconfig.Params)) {
|
||||
func ForAllNets(t *testing.T, skipPow bool, testFunc func(*testing.T, *dagconfig.Params)) {
|
||||
allParams := []dagconfig.Params{
|
||||
dagconfig.MainnetParams,
|
||||
dagconfig.TestnetParams,
|
||||
@ -17,11 +17,8 @@ func ForAllNets(t *testing.T, setDifficultyToMinimum bool, testFunc func(*testin
|
||||
}
|
||||
|
||||
for _, params := range allParams {
|
||||
if setDifficultyToMinimum {
|
||||
params.DisableDifficultyAdjustment = dagconfig.SimnetParams.DisableDifficultyAdjustment
|
||||
params.TargetTimePerBlock = dagconfig.SimnetParams.TargetTimePerBlock
|
||||
}
|
||||
|
||||
t.Run(params.Name, func(t *testing.T) { testFunc(t, ¶ms) })
|
||||
params.SkipProofOfWork = skipPow
|
||||
t.Logf("Running test for %s", params.Name)
|
||||
testFunc(t, ¶ms)
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ var genesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1, []*externa
|
||||
// genesisHash is the hash of the first block in the block DAG for the main
|
||||
// network (genesis block).
|
||||
var genesisHash = externalapi.DomainHash{
|
||||
0x28, 0x31, 0x30, 0xca, 0xfe, 0x26, 0x47, 0xc1,
|
||||
0xa8, 0x43, 0x43, 0xb2, 0xcb, 0xa5, 0x7e, 0x97,
|
||||
0x4b, 0xa6, 0x62, 0x50, 0xd9, 0x8e, 0xff, 0x28,
|
||||
0xda, 0x9b, 0xf6, 0x96, 0xdd, 0x70, 0xe9, 0x1e,
|
||||
0xbb, 0xc1, 0x88, 0xdd, 0x56, 0x9d, 0x46, 0xbd,
|
||||
0x36, 0xb0, 0x31, 0x52, 0x49, 0x93, 0xac, 0x70,
|
||||
0x1d, 0x36, 0xf1, 0xb3, 0xd2, 0x2f, 0xe5, 0x51,
|
||||
0x7c, 0x8b, 0x1a, 0xaf, 0x3c, 0x82, 0x6f, 0x18,
|
||||
}
|
||||
|
||||
// genesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
@ -52,7 +52,7 @@ var genesisBlock = externalapi.DomainBlock{
|
||||
HashMerkleRoot: genesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
||||
UTXOCommitment: externalapi.DomainHash{},
|
||||
TimeInMilliseconds: 0x175d5fcb8f5,
|
||||
TimeInMilliseconds: 0x175bc9e305a,
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x0,
|
||||
},
|
||||
@ -79,10 +79,10 @@ var devnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1,
|
||||
// devGenesisHash is the hash of the first block in the block DAG for the development
|
||||
// network (genesis block).
|
||||
var devnetGenesisHash = externalapi.DomainHash{
|
||||
0x54, 0x2c, 0x9c, 0xe0, 0x82, 0x2d, 0x41, 0x51,
|
||||
0xcf, 0x13, 0x03, 0xb5, 0x19, 0x58, 0xea, 0x3e,
|
||||
0xe8, 0x5c, 0xaf, 0x2f, 0x67, 0x50, 0x3a, 0xc9,
|
||||
0x36, 0x6a, 0xf6, 0x66, 0x3a, 0x78, 0xc3, 0x50,
|
||||
0x92, 0xb5, 0x28, 0xd3, 0xaa, 0x6d, 0x8b, 0x30,
|
||||
0x49, 0x19, 0x53, 0x6f, 0x62, 0xce, 0x9a, 0x82,
|
||||
0x2f, 0x91, 0xd4, 0x33, 0x24, 0xbc, 0x39, 0xe6,
|
||||
0xad, 0x53, 0xe3, 0x97, 0x5f, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// devnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
@ -103,9 +103,9 @@ var devnetGenesisBlock = externalapi.DomainBlock{
|
||||
HashMerkleRoot: devnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
||||
UTXOCommitment: externalapi.DomainHash{},
|
||||
TimeInMilliseconds: 0x175d5fcb8f5,
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x3,
|
||||
TimeInMilliseconds: 0x175bca27b7f,
|
||||
Bits: 0x1e7fffff,
|
||||
Nonce: 0x1a9ba,
|
||||
},
|
||||
Transactions: []*externalapi.DomainTransaction{devnetGenesisCoinbaseTx},
|
||||
}
|
||||
@ -129,10 +129,10 @@ var simnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1,
|
||||
// simnetGenesisHash is the hash of the first block in the block DAG for
|
||||
// the simnet (genesis block).
|
||||
var simnetGenesisHash = externalapi.DomainHash{
|
||||
0xe0, 0xe2, 0x74, 0xea, 0xca, 0xcd, 0x52, 0x74,
|
||||
0xa8, 0x33, 0x7b, 0x4c, 0xc2, 0x53, 0xe8, 0xbb,
|
||||
0x7b, 0xc2, 0xa7, 0xcc, 0xf7, 0xfe, 0x4b, 0x10,
|
||||
0x9f, 0x87, 0x35, 0x51, 0x39, 0x79, 0xea, 0x32,
|
||||
0x84, 0x96, 0x38, 0xb6, 0x5c, 0x44, 0xc0, 0xb9,
|
||||
0x3c, 0x48, 0x03, 0x7c, 0x2e, 0xee, 0x0a, 0xbf,
|
||||
0xfb, 0x54, 0xc8, 0x5f, 0x99, 0xd6, 0x21, 0x3d,
|
||||
0x3f, 0xdd, 0xac, 0xb1, 0xe7, 0x30, 0x7e, 0x05,
|
||||
}
|
||||
|
||||
// simnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
@ -153,9 +153,9 @@ var simnetGenesisBlock = externalapi.DomainBlock{
|
||||
HashMerkleRoot: simnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
||||
UTXOCommitment: externalapi.DomainHash{},
|
||||
TimeInMilliseconds: 0x175d5fcb8f5,
|
||||
TimeInMilliseconds: 0x175bca27c39,
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x0,
|
||||
Nonce: 0x1,
|
||||
},
|
||||
Transactions: []*externalapi.DomainTransaction{simnetGenesisCoinbaseTx},
|
||||
}
|
||||
@ -177,10 +177,10 @@ var testnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1,
|
||||
// testnetGenesisHash is the hash of the first block in the block DAG for the test
|
||||
// network (genesis block).
|
||||
var testnetGenesisHash = externalapi.DomainHash{
|
||||
0x19, 0xbe, 0x88, 0x5e, 0x70, 0x11, 0xf1, 0x11,
|
||||
0x76, 0xa5, 0x81, 0x30, 0x16, 0xbd, 0x44, 0x42,
|
||||
0x42, 0xb7, 0xbd, 0x98, 0x4a, 0xdc, 0x57, 0xa5,
|
||||
0x71, 0x99, 0xb7, 0x85, 0x2d, 0x11, 0x96, 0x7e,
|
||||
0xa9, 0xbe, 0xa7, 0xd9, 0x0f, 0xd2, 0xbd, 0xfb,
|
||||
0xd8, 0x09, 0x4d, 0x6a, 0x49, 0xa7, 0x59, 0x93,
|
||||
0xd1, 0x35, 0xce, 0x61, 0x18, 0x07, 0x0b, 0xe6,
|
||||
0xb9, 0xec, 0xad, 0x68, 0xe4, 0x2d, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// testnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
@ -201,9 +201,9 @@ var testnetGenesisBlock = externalapi.DomainBlock{
|
||||
HashMerkleRoot: testnetGenesisMerkleRoot,
|
||||
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
||||
UTXOCommitment: externalapi.DomainHash{},
|
||||
TimeInMilliseconds: 0x175d5fcb8f5,
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x0,
|
||||
TimeInMilliseconds: 0x175bcac06ec,
|
||||
Bits: 0x1e7fffff,
|
||||
Nonce: 0x568f,
|
||||
},
|
||||
Transactions: []*externalapi.DomainTransaction{testnetGenesisCoinbaseTx},
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ var (
|
||||
mainPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
|
||||
// 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)
|
||||
// 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)
|
||||
|
||||
// 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.
|
||||
@ -41,8 +41,8 @@ var (
|
||||
|
||||
// devnetPowMax is the highest proof of work value a Kaspa block
|
||||
// can have for the development network. It is the value
|
||||
// 2^255 - 1.
|
||||
devnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
|
||||
// 2^239 - 1.
|
||||
devnetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
|
||||
)
|
||||
|
||||
const (
|
||||
@ -147,6 +147,9 @@ type Params struct {
|
||||
|
||||
// DisableDifficultyAdjustment determine whether to use difficulty
|
||||
DisableDifficultyAdjustment bool
|
||||
|
||||
// SkipProofOfWork indicates whether proof of work should be checked.
|
||||
SkipProofOfWork bool
|
||||
}
|
||||
|
||||
// NormalizeRPCServerAddress returns addr with the current network default
|
||||
|
@ -69,3 +69,20 @@ func TestMustRegisterPanic(t *testing.T) {
|
||||
// Intentionally try to register duplicate params to force a panic.
|
||||
mustRegister(&MainnetParams)
|
||||
}
|
||||
|
||||
// TestSkipProofOfWork ensures all of the hard coded network params don't set SkipProofOfWork as true.
|
||||
func TestSkipProofOfWork(t *testing.T) {
|
||||
allParams := []Params{
|
||||
MainnetParams,
|
||||
TestnetParams,
|
||||
SimnetParams,
|
||||
DevnetParams,
|
||||
}
|
||||
|
||||
for _, params := range allParams {
|
||||
if params.SkipProofOfWork {
|
||||
t.Errorf("SkipProofOfWork is enabled for %s. This option should be "+
|
||||
"used only for tests.", params.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user