aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gen_difficultytest.go
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2017-09-27 21:30:41 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-09-27 21:30:41 +0800
commita660685746db17a41cd67b05c614cdb29e49340c (patch)
tree908537ef6d13b575ab5e14b644256f39f3a49b71 /tests/gen_difficultytest.go
parent2ab2a9f13116748ca343892f851e3632861c994e (diff)
downloaddexon-a660685746db17a41cd67b05c614cdb29e49340c.tar.gz
dexon-a660685746db17a41cd67b05c614cdb29e49340c.tar.zst
dexon-a660685746db17a41cd67b05c614cdb29e49340c.zip
tests: add ethash difficulty tests (#15191)
Diffstat (limited to 'tests/gen_difficultytest.go')
-rw-r--r--tests/gen_difficultytest.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/gen_difficultytest.go b/tests/gen_difficultytest.go
new file mode 100644
index 000000000..88f36ce99
--- /dev/null
+++ b/tests/gen_difficultytest.go
@@ -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
+}