mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
tests(consensus/ubqhash): fix TestSizeCalculations and TestConcurrentDiskCacheGeneration
This commit is contained in:
parent
b82d77c399
commit
29ee8e58ba
4 changed files with 35 additions and 19 deletions
|
|
@ -132,8 +132,6 @@ func blakeHasher(h hash.Hash) hasher {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// seedHash is the seed to use for generating a verification cache and the mining
|
||||
// dataset.
|
||||
func seedHash(block uint64) []byte {
|
||||
|
|
@ -1062,7 +1060,7 @@ var cacheSizes = [maxEpoch]uint64{
|
|||
200014016, 200146624, 200276672, 200408128, 200540096, 200671168,
|
||||
200801984, 200933312, 201062464, 201194944, 201326144, 201457472,
|
||||
201588544, 201719744, 201850816, 201981632, 202111552, 202244032,
|
||||
202374464, 202505152, 202636352, 202767808, 202898368, 203038836,
|
||||
202374464, 202505152, 202636352, 202767808, 202898368, 203030336,
|
||||
203159872, 203292608, 203423296, 203553472, 203685824, 203816896,
|
||||
203947712, 204078272, 204208192, 204341056, 204472256, 204603328,
|
||||
204733888, 204864448, 204996544, 205125568, 205258304, 205388864,
|
||||
|
|
|
|||
|
|
@ -706,20 +706,20 @@ func TestConcurrentDiskCacheGeneration(t *testing.T) {
|
|||
|
||||
// Define a heavy enough block, one from mainnet should do
|
||||
block := types.NewBlockWithHeader(&types.Header{
|
||||
Number: big.NewInt(3311058),
|
||||
ParentHash: common.HexToHash("0xd783efa4d392943503f28438ad5830b2d5964696ffc285f338585e9fe0a37a05"),
|
||||
Number: big.NewInt(1047270),
|
||||
ParentHash: common.HexToHash("0x50162f5bb86b04d36ad3c0972942f3ad12012681364a9ecfd851163893973b1e"),
|
||||
UncleHash: common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"),
|
||||
Coinbase: common.HexToAddress("0xc0ea08a2d404d3172d2add29a45be56da40e2949"),
|
||||
Root: common.HexToHash("0x77d14e10470b5850332524f8cd6f69ad21f070ce92dca33ab2858300242ef2f1"),
|
||||
TxHash: common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
|
||||
ReceiptHash: common.HexToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"),
|
||||
Difficulty: big.NewInt(167925187834220),
|
||||
GasLimit: 4015682,
|
||||
GasUsed: 0,
|
||||
Time: 1488928920,
|
||||
Extra: []byte("www.bw.com"),
|
||||
MixDigest: common.HexToHash("0x3e140b0784516af5e5ec6730f2fb20cca22f32be399b9e4ad77d32541f798cd0"),
|
||||
Nonce: types.EncodeNonce(0xf400cd0006070c49),
|
||||
Coinbase: common.HexToAddress("0xaeb7897adf9b1309d7ef2dca6f3f6afb65358abd"),
|
||||
Root: common.HexToHash("0x48450163a72087d7f7c7f8e479ca5f9b46ba2dea65af31374869330438f092bc"),
|
||||
TxHash: common.HexToHash("0xf3d988c1ba77b327ffe99f8f24d183f1dcca0a858dea397da90d19511f3e5243"),
|
||||
ReceiptHash: common.HexToHash("0x51f3538babf4e6315ac5843cbb6585b57024cfda57a3fbe51413549944496dcc"),
|
||||
Difficulty: big.NewInt(4399410101192),
|
||||
GasLimit: 8000000,
|
||||
GasUsed: 21000,
|
||||
Time: 1576671205,
|
||||
Extra: []byte("ubiqpool.maxhash.org"),
|
||||
MixDigest: common.HexToHash("0x8ce33f23cc18c394542ab28d35065706293eaf9c101007beb800f7e273266f82"),
|
||||
Nonce: types.EncodeNonce(0x2b00b2d234c5134e),
|
||||
})
|
||||
// Simulate multiple processes sharing the same datadir
|
||||
var pend sync.WaitGroup
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/ubiq/go-ubiq/core/types"
|
||||
)
|
||||
|
||||
var errEthashStopped = errors.New("ubqhash stopped")
|
||||
var errUbqhashStopped = errors.New("ubqhash stopped")
|
||||
|
||||
// API exposes ubqhash related methods for the RPC interface.
|
||||
type API struct {
|
||||
|
|
@ -51,7 +51,7 @@ func (api *API) GetWork() ([4]string, error) {
|
|||
select {
|
||||
case api.ubqhash.fetchWorkCh <- &sealWork{errc: errc, res: workCh}:
|
||||
case <-api.ubqhash.exitCh:
|
||||
return [4]string{}, errEthashStopped
|
||||
return [4]string{}, errUbqhashStopped
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/ubiq/go-ubiq/common/math"
|
||||
"github.com/ubiq/go-ubiq/core"
|
||||
"github.com/ubiq/go-ubiq/core/types"
|
||||
"github.com/ubiq/go-ubiq/core/vm"
|
||||
"github.com/ubiq/go-ubiq/ethdb"
|
||||
"github.com/ubiq/go-ubiq/params"
|
||||
)
|
||||
|
||||
|
|
@ -72,9 +75,24 @@ func TestCalcDifficulty(t *testing.T) {
|
|||
|
||||
config := ¶ms.ChainConfig{HomesteadBlock: big.NewInt(1150000)}
|
||||
|
||||
var (
|
||||
testdb = ethdb.NewMemDatabase()
|
||||
gspec = &core.Genesis{Config: config}
|
||||
genesis = gspec.MustCommit(testdb)
|
||||
blocks, _ = core.GenerateChain(config, genesis, NewFaker(), testdb, 88, nil)
|
||||
)
|
||||
|
||||
headers := make([]*types.Header, len(blocks))
|
||||
for i, block := range blocks {
|
||||
headers[i] = block.Header()
|
||||
}
|
||||
// Run the header checker for blocks one-by-one, checking for both valid and invalid nonces
|
||||
chain, _ := core.NewBlockChain(testdb, nil, config, NewFaker(), vm.Config{}, nil)
|
||||
defer chain.Stop()
|
||||
|
||||
for name, test := range tests {
|
||||
number := new(big.Int).Sub(test.CurrentBlocknumber, big.NewInt(1))
|
||||
diff := CalcDifficulty(config, test.CurrentTimestamp, &types.Header{
|
||||
diff := CalcDifficulty(chain, test.CurrentTimestamp, &types.Header{
|
||||
Number: number,
|
||||
Time: test.ParentTimestamp,
|
||||
Difficulty: test.ParentDifficulty,
|
||||
|
|
|
|||
Loading…
Reference in a new issue