aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gen_vmexec.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-07-11 19:49:14 +0800
committerGitHub <noreply@github.com>2017-07-11 19:49:14 +0800
commit225de7ca0a9e861696a5a43b666090b574c4c769 (patch)
tree68aff6fb74fece37626ced330fa9c5da91b483a4 /tests/gen_vmexec.go
parentbd01cd7183e771984fb9c008e7a7ebf0a0c3f9ba (diff)
downloadgo-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar
go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.gz
go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.bz2
go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.lz
go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.xz
go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.tar.zst
go-tangerine-225de7ca0a9e861696a5a43b666090b574c4c769.zip
tests: update tests and implement general state tests (#14734)
Tests are now included as a submodule. This should make updating easier and removes ~60MB of JSON data from the working copy. State tests are replaced by General State Tests, which run the same test with multiple fork configurations. With the new test runner, consensus tests are run as subtests by walking json files. Many hex issues have been fixed upstream since the last update and most custom parsing code is replaced by existing JSON hex types. Tests can now be marked as 'expected failures', ensuring that fixes for those tests will trigger an update to test configuration. The new test runner also supports parallel execution and the -short flag.
Diffstat (limited to 'tests/gen_vmexec.go')
-rw-r--r--tests/gen_vmexec.go88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/gen_vmexec.go b/tests/gen_vmexec.go
new file mode 100644
index 000000000..dd2d3d94e
--- /dev/null
+++ b/tests/gen_vmexec.go
@@ -0,0 +1,88 @@
+// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
+
+package tests
+
+import (
+ "encoding/json"
+ "errors"
+ "math/big"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/hexutil"
+ "github.com/ethereum/go-ethereum/common/math"
+)
+
+var _ = (*vmExecMarshaling)(nil)
+
+func (v vmExec) MarshalJSON() ([]byte, error) {
+ type vmExec struct {
+ Address common.UnprefixedAddress `json:"address" gencodec:"required"`
+ Caller common.UnprefixedAddress `json:"caller" gencodec:"required"`
+ Origin common.UnprefixedAddress `json:"origin" gencodec:"required"`
+ Code hexutil.Bytes `json:"code" gencodec:"required"`
+ Data hexutil.Bytes `json:"data" gencodec:"required"`
+ Value *math.HexOrDecimal256 `json:"value" gencodec:"required"`
+ GasLimit math.HexOrDecimal64 `json:"gas" gencodec:"required"`
+ GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"`
+ }
+ var enc vmExec
+ enc.Address = common.UnprefixedAddress(v.Address)
+ enc.Caller = common.UnprefixedAddress(v.Caller)
+ enc.Origin = common.UnprefixedAddress(v.Origin)
+ enc.Code = v.Code
+ enc.Data = v.Data
+ enc.Value = (*math.HexOrDecimal256)(v.Value)
+ enc.GasLimit = math.HexOrDecimal64(v.GasLimit)
+ enc.GasPrice = (*math.HexOrDecimal256)(v.GasPrice)
+ return json.Marshal(&enc)
+}
+
+func (v *vmExec) UnmarshalJSON(input []byte) error {
+ type vmExec struct {
+ Address *common.UnprefixedAddress `json:"address" gencodec:"required"`
+ Caller *common.UnprefixedAddress `json:"caller" gencodec:"required"`
+ Origin *common.UnprefixedAddress `json:"origin" gencodec:"required"`
+ Code hexutil.Bytes `json:"code" gencodec:"required"`
+ Data hexutil.Bytes `json:"data" gencodec:"required"`
+ Value *math.HexOrDecimal256 `json:"value" gencodec:"required"`
+ GasLimit *math.HexOrDecimal64 `json:"gas" gencodec:"required"`
+ GasPrice *math.HexOrDecimal256 `json:"gasPrice" gencodec:"required"`
+ }
+ var dec vmExec
+ if err := json.Unmarshal(input, &dec); err != nil {
+ return err
+ }
+ if dec.Address == nil {
+ return errors.New("missing required field 'address' for vmExec")
+ }
+ v.Address = common.Address(*dec.Address)
+ if dec.Caller == nil {
+ return errors.New("missing required field 'caller' for vmExec")
+ }
+ v.Caller = common.Address(*dec.Caller)
+ if dec.Origin == nil {
+ return errors.New("missing required field 'origin' for vmExec")
+ }
+ v.Origin = common.Address(*dec.Origin)
+ if dec.Code == nil {
+ return errors.New("missing required field 'code' for vmExec")
+ }
+ v.Code = dec.Code
+ if dec.Data == nil {
+ return errors.New("missing required field 'data' for vmExec")
+ }
+ v.Data = dec.Data
+ if dec.Value == nil {
+ return errors.New("missing required field 'value' for vmExec")
+ }
+ v.Value = (*big.Int)(dec.Value)
+ if dec.GasLimit == nil {
+ return errors.New("missing required field 'gas' for vmExec")
+ }
+ v.GasLimit = uint64(*dec.GasLimit)
+ if dec.GasPrice == nil {
+ return errors.New("missing required field 'gasPrice' for vmExec")
+ }
+ v.GasPrice = (*big.Int)(dec.GasPrice)
+ return nil
+}