mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
tests: Added new difficulty tests
This commit is contained in:
parent
673007d7ae
commit
e7325fac7b
4 changed files with 78 additions and 9 deletions
66
tests/gen_difficultytest.go
Normal file
66
tests/gen_difficultytest.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
||||
|
||||
package tests
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
)
|
||||
|
||||
var _ = (*difficultyTestMarshaling)(nil)
|
||||
|
||||
func (d difficultyTest) MarshalJSON() ([]byte, error) {
|
||||
type difficultyTest struct {
|
||||
ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
|
||||
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
|
||||
UncleHash common.Hash `json:"parentUncles"`
|
||||
CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
|
||||
CurrentBlockNumber math.HexOrDecimal64 `json:"currentBlockNumber"`
|
||||
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
|
||||
}
|
||||
var enc difficultyTest
|
||||
enc.ParentTimestamp = (*math.HexOrDecimal256)(d.ParentTimestamp)
|
||||
enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
|
||||
enc.UncleHash = d.UncleHash
|
||||
enc.CurrentTimestamp = (*math.HexOrDecimal256)(d.CurrentTimestamp)
|
||||
enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
|
||||
enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
||||
func (d *difficultyTest) UnmarshalJSON(input []byte) error {
|
||||
type difficultyTest struct {
|
||||
ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
|
||||
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
|
||||
UncleHash *common.Hash `json:"parentUncles"`
|
||||
CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
|
||||
CurrentBlockNumber *math.HexOrDecimal64 `json:"currentBlockNumber"`
|
||||
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
|
||||
}
|
||||
var dec difficultyTest
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
return err
|
||||
}
|
||||
if dec.ParentTimestamp != nil {
|
||||
d.ParentTimestamp = (*big.Int)(dec.ParentTimestamp)
|
||||
}
|
||||
if dec.ParentDifficulty != nil {
|
||||
d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
|
||||
}
|
||||
if dec.UncleHash != nil {
|
||||
d.UncleHash = *dec.UncleHash
|
||||
}
|
||||
if dec.CurrentTimestamp != nil {
|
||||
d.CurrentTimestamp = (*big.Int)(dec.CurrentTimestamp)
|
||||
}
|
||||
if dec.CurrentBlockNumber != nil {
|
||||
d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)
|
||||
}
|
||||
if dec.CurrentDifficulty != nil {
|
||||
d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -39,6 +39,7 @@ var (
|
|||
transactionTestDir = filepath.Join(baseDir, "TransactionTests")
|
||||
vmTestDir = filepath.Join(baseDir, "VMTests")
|
||||
rlpTestDir = filepath.Join(baseDir, "RLPTests")
|
||||
difficultyTestDir = filepath.Join(baseDir, "BasicTests")
|
||||
)
|
||||
|
||||
func readJson(reader io.Reader, value interface{}) error {
|
||||
|
|
|
|||
|
|
@ -45,8 +45,10 @@ func TestState(t *testing.T) {
|
|||
st.fails(`^stRandom/randomStatetest644\.json/EIP150/.*`, "known bug #15119")
|
||||
st.fails(`^stRandom/randomStatetest644\.json/Frontier/.*`, "known bug #15119")
|
||||
st.fails(`^stRandom/randomStatetest644\.json/Homestead/.*`, "known bug #15119")
|
||||
|
||||
|
||||
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/EIP158/2`, "known bug ")
|
||||
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/EIP158/3`, "known bug ")
|
||||
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/Byzantium/2`, "known bug ")
|
||||
st.fails(`^stCreateTest/TransactionCollisionToEmpty\.json/Byzantium/3`, "known bug ")
|
||||
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
|
||||
for _, subtest := range test.Subtests() {
|
||||
subtest := subtest
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit ca41e906351209481bce3a1b35501f25a79023c5
|
||||
Subproject commit da12f07176a1657e75fc251c8fb865e817b0d4a6
|
||||
Loading…
Reference in a new issue