Documentation ¶
Overview ¶
Package tests implements execution of Ethereum JSON tests.
Index ¶
- Variables
- func AvailableForks() []string
- func FromHex(s string) ([]byte, error)
- func GetChainConfig(forkString string) (baseConfig *chain.Config, eips []int, err error)
- func MakePreState(rules *chain.Rules, tx kv.RwTx, accounts types.GenesisAlloc, blockNr uint64) (*state.IntraBlockState, error)
- type BlockTest
- type DifficultyTest
- type RLPTest
- type StateSubtest
- type StateTest
- func (t *StateTest) Run(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Config, dirs datadir.Dirs) (*state.IntraBlockState, libcommon.Hash, error)
- func (t *StateTest) RunNoVerify(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Config, dirs datadir.Dirs) (*state.IntraBlockState, libcommon.Hash, error)
- func (t *StateTest) Subtests() []StateSubtest
- func (t *StateTest) UnmarshalJSON(in []byte) error
- type TransactionTest
- type UnsupportedForkError
Constants ¶
This section is empty.
Variables ¶
var Forks = map[string]*chain.Config{ "Frontier": { ChainID: big.NewInt(1), }, "Homestead": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), }, "EIP150": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), }, "EIP158": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), }, "Byzantium": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), }, "Constantinople": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(10000000), }, "ConstantinopleFix": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), }, "Istanbul": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), }, "FrontierToHomesteadAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(5), }, "HomesteadToEIP150At5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(5), }, "HomesteadToDaoAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), DAOForkBlock: big.NewInt(5), }, "EIP158ToByzantiumAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(5), }, "ByzantiumToConstantinopleAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(5), }, "ByzantiumToConstantinopleFixAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(5), PetersburgBlock: big.NewInt(5), }, "ConstantinopleFixToIstanbulAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(5), }, "EIP2384": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), }, "Berlin": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), }, "BerlinToLondonAt5": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(5), }, "London": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), }, "ArrowGlacier": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), }, "GrayGlacier": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), }, "Merge": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), }, "Paris": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), }, "ArrowGlacierToParisAtDiffC0000": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0xC0000), }, "Shanghai": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(0), }, "ParisToShanghaiAtTime15k": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(15_000), }, "Cancun": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(0), CancunTime: big.NewInt(0), }, "Cancun+1153": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(0), CancunTime: big.NewInt(0), }, "ShanghaiToCancunAtTime15k": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(0), CancunTime: big.NewInt(15_000), }, "Prague": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(0), CancunTime: big.NewInt(0), PragueTime: big.NewInt(0), DepositContract: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), }, "CancunToPragueAtTime15k": { ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), TangerineWhistleBlock: big.NewInt(0), SpuriousDragonBlock: big.NewInt(0), ByzantiumBlock: big.NewInt(0), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(0), LondonBlock: big.NewInt(0), ArrowGlacierBlock: big.NewInt(0), GrayGlacierBlock: big.NewInt(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, ShanghaiTime: big.NewInt(0), CancunTime: big.NewInt(0), PragueTime: big.NewInt(15_000), DepositContract: common.HexToAddress("0x00000000219ab540356cBB839Cbe05303d7705Fa"), }, }
Forks table defines supported forks and their chain config.
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x". This is copy-pasted from bytes.go, which does not return the error
func GetChainConfig ¶
GetChainConfig takes a fork definition and returns a chain config. The fork definition can be - a plain forkname, e.g. `Byzantium`, - a fork basename, and a list of EIPs to enable; e.g. `Byzantium+1884+1283`.
func MakePreState ¶
func MakePreState(rules *chain.Rules, tx kv.RwTx, accounts types.GenesisAlloc, blockNr uint64) (*state.IntraBlockState, error)
Types ¶
type BlockTest ¶
type BlockTest struct {
// contains filtered or unexported fields
}
A BlockTest checks handling of entire blocks.
func (*BlockTest) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.
type DifficultyTest ¶
type DifficultyTest struct { ParentTimestamp uint64 `json:"parentTimestamp"` ParentDifficulty *big.Int `json:"parentDifficulty"` ParentUncles uint64 `json:"parentUncles"` CurrentTimestamp uint64 `json:"currentTimestamp"` CurrentBlockNumber uint64 `json:"currentBlockNumber"` CurrentDifficulty *big.Int `json:"currentDifficulty"` }
func (DifficultyTest) MarshalJSON ¶
func (d DifficultyTest) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*DifficultyTest) UnmarshalJSON ¶
func (d *DifficultyTest) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type RLPTest ¶
type RLPTest struct { // If the value of In is "INVALID" or "VALID", the test // checks whether Out can be decoded into a value of // type interface{}. // // For other JSON values, In is treated as a driver for // calls to rlp.Stream. The test also verifies that encoding // In produces the bytes in Out. In interface{} // Out is a hex-encoded RLP value. Out string }
RLPTest is the JSON structure of a single RLP test.
type StateSubtest ¶
StateSubtest selects a specific configuration of a General State Test.
type StateTest ¶
type StateTest struct {
// contains filtered or unexported fields
}
StateTest checks transaction processing without block context. See https://github.com/ethereum/EIPs/issues/176 for the test format specification.
func (*StateTest) Run ¶
func (t *StateTest) Run(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Config, dirs datadir.Dirs) (*state.IntraBlockState, libcommon.Hash, error)
Run executes a specific subtest and verifies the post-state and logs
func (*StateTest) RunNoVerify ¶
func (t *StateTest) RunNoVerify(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Config, dirs datadir.Dirs) (*state.IntraBlockState, libcommon.Hash, error)
RunNoVerify runs a specific subtest and returns the statedb and post-state root
func (*StateTest) Subtests ¶
func (t *StateTest) Subtests() []StateSubtest
Subtests returns all valid subtests of the test.
func (*StateTest) UnmarshalJSON ¶
type TransactionTest ¶
type TransactionTest struct { RLP hexutility.Bytes `json:"txbytes"` Forks ttForks `json:"result"` }
TransactionTest checks RLP decoding and sender derivation of transactions.
type UnsupportedForkError ¶
type UnsupportedForkError struct {
Name string
}
UnsupportedForkError is returned when a test requests a fork that isn't implemented.
func (UnsupportedForkError) Error ¶
func (e UnsupportedForkError) Error() string