mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
Merge 27e3dea685 into a0aa071ca6
This commit is contained in:
commit
5f69e1ba20
2 changed files with 194 additions and 0 deletions
|
|
@ -0,0 +1,95 @@
|
|||
{
|
||||
"ContractCreationSpam" : {
|
||||
"env" : {
|
||||
"currentCoinbase" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty" : "0x20000",
|
||||
"currentGasLimit" : "0x174876e800",
|
||||
"currentNumber" : "0x1",
|
||||
"currentTimestamp" : "0x3e8",
|
||||
"previousHash" : "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
|
||||
},
|
||||
"post" : {
|
||||
"EIP150" : [
|
||||
{
|
||||
"hash" : "0x7e7ff82e1c33ffbeb3dedb679498c9716f83c697f497d75aca467ae936b8ae45",
|
||||
"indexes" : {
|
||||
"data" : 0,
|
||||
"gas" : 0,
|
||||
"value" : 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"EIP158" : [
|
||||
{
|
||||
"hash" : "0x7e7ff82e1c33ffbeb3dedb679498c9716f83c697f497d75aca467ae936b8ae45",
|
||||
"indexes" : {
|
||||
"data" : 0,
|
||||
"gas" : 0,
|
||||
"value" : 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"Frontier" : [
|
||||
{
|
||||
"hash" : "0xe6b8c416b01e463186ae6661211f5e6c3ee69a1975e8f4a4d2d65ed0ff1faf2d",
|
||||
"indexes" : {
|
||||
"data" : 0,
|
||||
"gas" : 0,
|
||||
"value" : 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"Homestead" : [
|
||||
{
|
||||
"hash" : "0xe6b8c416b01e463186ae6661211f5e6c3ee69a1975e8f4a4d2d65ed0ff1faf2d",
|
||||
"indexes" : {
|
||||
"data" : 0,
|
||||
"gas" : 0,
|
||||
"value" : 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"Metropolis" : [
|
||||
{
|
||||
"hash" : "0x7e7ff82e1c33ffbeb3dedb679498c9716f83c697f497d75aca467ae936b8ae45",
|
||||
"indexes" : {
|
||||
"data" : 0,
|
||||
"gas" : 0,
|
||||
"value" : 0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"pre" : {
|
||||
"0x6a0a0fc761c612c340a0e98d33b37a75e5268472" : {
|
||||
"balance" : "0xde0b6b3a7640000",
|
||||
"code" : "0x7f6004600c60003960046000f3600035ff00000000000000000000000000000000600052602060006000f0600054805b6001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1506001018060005260008060208180876006f1505a616000106200002f57600055",
|
||||
"nonce" : "0x0",
|
||||
"storage" : {
|
||||
}
|
||||
},
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||
"balance" : "0xe8d4a51000",
|
||||
"code" : "0x00",
|
||||
"nonce" : "0x0",
|
||||
"storage" : {
|
||||
}
|
||||
}
|
||||
},
|
||||
"transaction" : {
|
||||
"data" : [
|
||||
""
|
||||
],
|
||||
"gasLimit" : [
|
||||
"800000"
|
||||
],
|
||||
"gasPrice" : "0x1",
|
||||
"nonce" : "0x0",
|
||||
"secretKey" : "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
|
||||
"to" : "0x6a0a0fc761c612C340a0e98d33b37a75e5268472",
|
||||
"value" : [
|
||||
"0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
99
tests/generic_test.go
Normal file
99
tests/generic_test.go
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
package tests
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
var (
|
||||
genericTestDir = filepath.Join(baseDir, "GeneralStateTests")
|
||||
)
|
||||
|
||||
func TestGenericState(t *testing.T) {
|
||||
runDir(genericTestDir, t)
|
||||
}
|
||||
|
||||
func runDir(path string, t *testing.T) {
|
||||
files, err := ioutil.ReadDir(path)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
t.Run(file.Name(), func(t *testing.T) {
|
||||
fpath := filepath.Join(path, file.Name())
|
||||
if file.IsDir() {
|
||||
runDir(fpath, t)
|
||||
} else {
|
||||
if err := runTests(fpath, t); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func runTests(path string, t *testing.T) error {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading JSON file: %v", err)
|
||||
}
|
||||
|
||||
test := make(map[string]StateTest)
|
||||
|
||||
if err = json.Unmarshal(data, &test); err != nil {
|
||||
if syntaxerr, ok := err.(*json.SyntaxError); ok {
|
||||
line := findLine(data, syntaxerr.Offset)
|
||||
return fmt.Errorf("JSON syntax error at line %v: %v", line, err)
|
||||
}
|
||||
return fmt.Errorf("JSON unmarshal error: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type hardfork string
|
||||
|
||||
const (
|
||||
EIP150 hardfork = "EIP150"
|
||||
EIP158 = "EIP158"
|
||||
Frontier = "Frontier"
|
||||
Homestead = "Homestead"
|
||||
Metropolis = "Metropolis"
|
||||
)
|
||||
|
||||
type StateTest struct {
|
||||
Aux AuxiliaryData `json:"env"`
|
||||
PreState map[common.Address]StateObject `json:"pre"`
|
||||
PostState map[hardfork][]PostState `json:"post"`
|
||||
}
|
||||
|
||||
type AuxiliaryData struct {
|
||||
Coinbase common.Address `json:"currentCoinbase"`
|
||||
Difficulty hexutil.Big `json:"currentDifficulty"`
|
||||
GasLimit hexutil.Big `json:"currentGasLimit"`
|
||||
Number hexutil.Big `json:"Number"`
|
||||
Timestamp hexutil.Uint64 `json:"currentTimestamp"`
|
||||
ParentHash common.Hash `json:"previousHash"`
|
||||
}
|
||||
|
||||
type StateObject struct {
|
||||
Balance hexutil.Big `json:"balance"`
|
||||
Code hexutil.Bytes `json:"code"`
|
||||
Nonce hexutil.Uint64 `json:"nonce"`
|
||||
Storage map[common.Hash]common.Hash `json:"storage"`
|
||||
}
|
||||
|
||||
type PostState struct {
|
||||
Hash common.Hash `json:"hash"`
|
||||
Indices struct {
|
||||
//Data hexutil.Uint64 `json:"data"`
|
||||
//Gas hexutil.Uint64 `json:"Gas"`
|
||||
//Value hexutil.Uint64 `json:"Value"`
|
||||
} `json:"indexes"`
|
||||
}
|
||||
Loading…
Reference in a new issue