aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-04-03 04:28:48 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-04-08 17:00:42 +0800
commitaf401d03a395c21fdb297edb687edf8af3470cb2 (patch)
treed2ee3476c9005ffe1aca7abbe7152765da0efe32 /tests
parent80a2a35bc3aaf208b5f91a1fb1d803975d4bb01c (diff)
downloadgo-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar
go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.gz
go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.bz2
go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.lz
go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.xz
go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.tar.zst
go-tangerine-af401d03a395c21fdb297edb687edf8af3470cb2.zip
all: simplify timestamps to uint64 (#19372)
* all: simplify timestamps to uint64 * tests: update definitions * clef, faucet, mobile: leftover uint64 fixups * ethash: fix tests * graphql: update schema for timestamp * ethash: remove unused variable
Diffstat (limited to 'tests')
-rw-r--r--tests/block_test_util.go8
-rw-r--r--tests/difficulty_test_util.go10
-rw-r--r--tests/gen_btheader.go10
-rw-r--r--tests/gen_difficultytest.go18
4 files changed, 25 insertions, 21 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go
index 9fa69bf4e..3a1644497 100644
--- a/tests/block_test_util.go
+++ b/tests/block_test_util.go
@@ -82,7 +82,7 @@ type btHeader struct {
Difficulty *big.Int
GasLimit uint64
GasUsed uint64
- Timestamp *big.Int
+ Timestamp uint64
}
type btHeaderMarshaling struct {
@@ -91,7 +91,7 @@ type btHeaderMarshaling struct {
Difficulty *math.HexOrDecimal256
GasLimit math.HexOrDecimal64
GasUsed math.HexOrDecimal64
- Timestamp *math.HexOrDecimal256
+ Timestamp math.HexOrDecimal64
}
func (t *BlockTest) Run() error {
@@ -146,7 +146,7 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis {
return &core.Genesis{
Config: config,
Nonce: t.json.Genesis.Nonce.Uint64(),
- Timestamp: t.json.Genesis.Timestamp.Uint64(),
+ Timestamp: t.json.Genesis.Timestamp,
ParentHash: t.json.Genesis.ParentHash,
ExtraData: t.json.Genesis.ExtraData,
GasLimit: t.json.Genesis.GasLimit,
@@ -248,7 +248,7 @@ func validateHeader(h *btHeader, h2 *types.Header) error {
if h.GasUsed != h2.GasUsed {
return fmt.Errorf("GasUsed: want: %d have: %d", h.GasUsed, h2.GasUsed)
}
- if h.Timestamp.Cmp(h2.Time) != 0 {
+ if h.Timestamp != h2.Time {
return fmt.Errorf("Timestamp: want: %v have: %v", h.Timestamp, h2.Time)
}
return nil
diff --git a/tests/difficulty_test_util.go b/tests/difficulty_test_util.go
index 00d699cf7..fe6e90b02 100644
--- a/tests/difficulty_test_util.go
+++ b/tests/difficulty_test_util.go
@@ -30,18 +30,18 @@ import (
//go:generate gencodec -type DifficultyTest -field-override difficultyTestMarshaling -out gen_difficultytest.go
type DifficultyTest struct {
- ParentTimestamp *big.Int `json:"parentTimestamp"`
+ ParentTimestamp uint64 `json:"parentTimestamp"`
ParentDifficulty *big.Int `json:"parentDifficulty"`
UncleHash common.Hash `json:"parentUncles"`
- CurrentTimestamp *big.Int `json:"currentTimestamp"`
+ CurrentTimestamp uint64 `json:"currentTimestamp"`
CurrentBlockNumber uint64 `json:"currentBlockNumber"`
CurrentDifficulty *big.Int `json:"currentDifficulty"`
}
type difficultyTestMarshaling struct {
- ParentTimestamp *math.HexOrDecimal256
+ ParentTimestamp math.HexOrDecimal64
ParentDifficulty *math.HexOrDecimal256
- CurrentTimestamp *math.HexOrDecimal256
+ CurrentTimestamp math.HexOrDecimal64
CurrentDifficulty *math.HexOrDecimal256
UncleHash common.Hash
CurrentBlockNumber math.HexOrDecimal64
@@ -56,7 +56,7 @@ func (test *DifficultyTest) Run(config *params.ChainConfig) error {
UncleHash: test.UncleHash,
}
- actual := ethash.CalcDifficulty(config, test.CurrentTimestamp.Uint64(), parent)
+ actual := ethash.CalcDifficulty(config, test.CurrentTimestamp, parent)
exp := test.CurrentDifficulty
if actual.Cmp(exp) != 0 {
diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go
index 5cfd4bd0a..f2e086a7b 100644
--- a/tests/gen_btheader.go
+++ b/tests/gen_btheader.go
@@ -14,6 +14,7 @@ import (
var _ = (*btHeaderMarshaling)(nil)
+// MarshalJSON marshals as JSON.
func (b btHeader) MarshalJSON() ([]byte, error) {
type btHeader struct {
Bloom types.Bloom
@@ -31,7 +32,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
Difficulty *math.HexOrDecimal256
GasLimit math.HexOrDecimal64
GasUsed math.HexOrDecimal64
- Timestamp *math.HexOrDecimal256
+ Timestamp math.HexOrDecimal64
}
var enc btHeader
enc.Bloom = b.Bloom
@@ -49,10 +50,11 @@ func (b btHeader) MarshalJSON() ([]byte, error) {
enc.Difficulty = (*math.HexOrDecimal256)(b.Difficulty)
enc.GasLimit = math.HexOrDecimal64(b.GasLimit)
enc.GasUsed = math.HexOrDecimal64(b.GasUsed)
- enc.Timestamp = (*math.HexOrDecimal256)(b.Timestamp)
+ enc.Timestamp = math.HexOrDecimal64(b.Timestamp)
return json.Marshal(&enc)
}
+// UnmarshalJSON unmarshals from JSON.
func (b *btHeader) UnmarshalJSON(input []byte) error {
type btHeader struct {
Bloom *types.Bloom
@@ -70,7 +72,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
Difficulty *math.HexOrDecimal256
GasLimit *math.HexOrDecimal64
GasUsed *math.HexOrDecimal64
- Timestamp *math.HexOrDecimal256
+ Timestamp *math.HexOrDecimal64
}
var dec btHeader
if err := json.Unmarshal(input, &dec); err != nil {
@@ -122,7 +124,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error {
b.GasUsed = uint64(*dec.GasUsed)
}
if dec.Timestamp != nil {
- b.Timestamp = (*big.Int)(dec.Timestamp)
+ b.Timestamp = uint64(*dec.Timestamp)
}
return nil
}
diff --git a/tests/gen_difficultytest.go b/tests/gen_difficultytest.go
index 88f36ce99..cd15ae31b 100644
--- a/tests/gen_difficultytest.go
+++ b/tests/gen_difficultytest.go
@@ -12,31 +12,33 @@ import (
var _ = (*difficultyTestMarshaling)(nil)
+// MarshalJSON marshals as JSON.
func (d DifficultyTest) MarshalJSON() ([]byte, error) {
type DifficultyTest struct {
- ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
+ ParentTimestamp math.HexOrDecimal64 `json:"parentTimestamp"`
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
UncleHash common.Hash `json:"parentUncles"`
- CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
+ CurrentTimestamp math.HexOrDecimal64 `json:"currentTimestamp"`
CurrentBlockNumber math.HexOrDecimal64 `json:"currentBlockNumber"`
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
}
var enc DifficultyTest
- enc.ParentTimestamp = (*math.HexOrDecimal256)(d.ParentTimestamp)
+ enc.ParentTimestamp = math.HexOrDecimal64(d.ParentTimestamp)
enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
enc.UncleHash = d.UncleHash
- enc.CurrentTimestamp = (*math.HexOrDecimal256)(d.CurrentTimestamp)
+ enc.CurrentTimestamp = math.HexOrDecimal64(d.CurrentTimestamp)
enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
return json.Marshal(&enc)
}
+// UnmarshalJSON unmarshals from JSON.
func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
type DifficultyTest struct {
- ParentTimestamp *math.HexOrDecimal256 `json:"parentTimestamp"`
+ ParentTimestamp *math.HexOrDecimal64 `json:"parentTimestamp"`
ParentDifficulty *math.HexOrDecimal256 `json:"parentDifficulty"`
UncleHash *common.Hash `json:"parentUncles"`
- CurrentTimestamp *math.HexOrDecimal256 `json:"currentTimestamp"`
+ CurrentTimestamp *math.HexOrDecimal64 `json:"currentTimestamp"`
CurrentBlockNumber *math.HexOrDecimal64 `json:"currentBlockNumber"`
CurrentDifficulty *math.HexOrDecimal256 `json:"currentDifficulty"`
}
@@ -45,7 +47,7 @@ func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
return err
}
if dec.ParentTimestamp != nil {
- d.ParentTimestamp = (*big.Int)(dec.ParentTimestamp)
+ d.ParentTimestamp = uint64(*dec.ParentTimestamp)
}
if dec.ParentDifficulty != nil {
d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
@@ -54,7 +56,7 @@ func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
d.UncleHash = *dec.UncleHash
}
if dec.CurrentTimestamp != nil {
- d.CurrentTimestamp = (*big.Int)(dec.CurrentTimestamp)
+ d.CurrentTimestamp = uint64(*dec.CurrentTimestamp)
}
if dec.CurrentBlockNumber != nil {
d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)