Documentation
¶
Overview ¶
Package tests implements execution of Ethereum JSON tests.
Index ¶
- Variables
- func BenchStateTest(ruleSet RuleSet, p string, conf bconf, b *testing.B) error
- func BenchVmTest(p string, conf bconf, b *testing.B) error
- func CreateStateTests(f string) (map[string]StateTest, error)
- func LoadBlockTests(file string) (map[string]*BlockTest, error)
- func RunBlockTest(homesteadBlock, gasPriceFork *big.Int, file string, skipTests []string) error
- func RunBlockTestWithReader(homesteadBlock, gasPriceFork *big.Int, r io.Reader, skipTests []string) error
- func RunRLPTest(file string, skip []string) error
- func RunRLPTestWithReader(r io.Reader, skip []string) error
- func RunState(ruleSet RuleSet, db ethdb.Database, statedb *state.StateDB, ...) ([]byte, vm.Logs, *big.Int, error)
- func RunStateTest(ruleSet RuleSet, p string, skipTests []string) error
- func RunStateTestWithReader(ruleSet RuleSet, r io.Reader, skipTests []string) error
- func RunTransactionTests(file string, skipTests []string) error
- func RunTransactionTestsWithReader(r io.Reader, skipTests []string) error
- func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, vm.Logs, *big.Int, error)
- func RunVmTest(p string, skipTests []string) error
- func RunVmTestWithReader(r io.Reader, skipTests []string) error
- type Account
- type BlockTest
- func (t *BlockTest) InsertPreState(db ethdb.Database) (*state.StateDB, error)
- func (t *BlockTest) TryBlocksInsert(blockchain *core.BlockChain) ([]btBlock, error)
- func (test *BlockTest) ValidateImportedHeaders(cm *core.BlockChain, validBlocks []btBlock) error
- func (t *BlockTest) ValidatePostState(statedb *state.StateDB) error
- type DifficultyTest
- type Env
- func (self *Env) AddLog(log *vm.Log)
- func (self *Env) BlockNumber() *big.Int
- func (self *Env) Call(caller vm.ContractRef, addr common.Address, data []byte, ...) ([]byte, error)
- func (self *Env) CallCode(caller vm.ContractRef, addr common.Address, data []byte, ...) ([]byte, error)
- func (self *Env) CanTransfer(from common.Address, balance *big.Int) bool
- func (self *Env) Coinbase() common.Address
- func (self *Env) Create(caller vm.ContractRef, data []byte, gas, price, value *big.Int) ([]byte, common.Address, error)
- func (self *Env) Db() vm.Database
- func (self *Env) DelegateCall(caller vm.ContractRef, addr common.Address, data []byte, gas, price *big.Int) ([]byte, error)
- func (self *Env) Depth() int
- func (self *Env) Difficulty() *big.Int
- func (self *Env) GasLimit() *big.Int
- func (self *Env) GetHash(n uint64) common.Hash
- func (self *Env) Origin() common.Address
- func (self *Env) ReturnData() []byte
- func (self *Env) RevertToSnapshot(snapshot int)
- func (self *Env) RuleSet() vm.RuleSet
- func (self *Env) SetDepth(i int)
- func (self *Env) SetReturnData(data []byte)
- func (self *Env) SnapshotDatabase() int
- func (self *Env) StaticCall(caller vm.ContractRef, addr common.Address, data []byte, gas, price *big.Int) ([]byte, error)
- func (self *Env) Time() *big.Int
- func (self *Env) Transfer(from, to vm.Account, amount *big.Int)
- func (self *Env) Vm() vm.Vm
- func (self *Env) VmType() vm.Type
- type GenesisAccount
- type Log
- type Message
- func (self Message) Data() []byte
- func (self Message) From() (common.Address, error)
- func (self Message) FromFrontier() (common.Address, error)
- func (self Message) Gas() *big.Int
- func (self Message) GasPrice() *big.Int
- func (self Message) Hash() []byte
- func (self Message) Nonce() uint64
- func (self Message) To() *common.Address
- func (self Message) Value() *big.Int
- type RLPTest
- type RuleSet
- type StateSubtest
- type StateTest
- type TransactionTest
- type TtTransaction
- type UnsupportedForkError
- type VmEnv
- type VmTest
Constants ¶
This section is empty.
Variables ¶
var ( BlockSkipTests = initBlockSkipTests() /* Go client does not support transaction (account) nonces above 2^64. This technically breaks consensus but is regarded as "reasonable engineering constraint" as accounts cannot easily reach such high nonce values in practice */ TransSkipTests = []string{"TransactionWithHihghNonce256"} StateSkipTests = []string{} VmSkipTests = []string{} )
var ChainConfigs = map[string]core.ChainConfig{ "difficultyFrontier.json": {}, "difficultyHomestead.json": { Forks: []*core.Fork{ { Name: "Homestead", Block: big.NewInt(0), Features: []*core.ForkFeature{ { ID: "difficulty", Options: core.ChainFeatureConfigOptions{ "type": "homestead", }, }, { ID: "gastable", Options: core.ChainFeatureConfigOptions{ "type": "homestead", }, }, }, }, }, }, "difficultyByzantium.json": { Forks: []*core.Fork{ { Name: "Atlantis", Block: big.NewInt(0), Features: []*core.ForkFeature{ { ID: "difficulty", Options: core.ChainFeatureConfigOptions{ "type": "atlantis", "length": 3000000, }, }, }, }, }, }, }
ChainConfigs table used to map configs to difficulty test files
var Forks = map[string]RuleSet{ "Frontier": {}, "Homestead": { HomesteadBlock: big.NewInt(0), }, "EIP150": { HomesteadBlock: big.NewInt(0), HomesteadGasRepriceBlock: big.NewInt(0), }, "Byzantium": { HomesteadBlock: big.NewInt(0), HomesteadGasRepriceBlock: big.NewInt(0), DiehardBlock: big.NewInt(0), Hardfork2Block: big.NewInt(0), AtlantisBlock: big.NewInt(0), }, }
Forks table defines supported forks and their chain config.
Functions ¶
func BenchStateTest ¶
func CreateStateTests ¶ added in v0.9.9
func RunBlockTest ¶
func RunBlockTestWithReader ¶
func RunRLPTest ¶
RunRLPTest runs the tests in the given file, skipping tests by name.
func RunRLPTestWithReader ¶
RunRLPTest runs the tests encoded in r, skipping tests by name.
func RunStateTestWithReader ¶
func RunTransactionTests ¶
Types ¶
type BlockTest ¶
type BlockTest struct { Genesis *types.Block Json *btJSON // contains filtered or unexported fields }
Block Test JSON Format
func (*BlockTest) InsertPreState ¶
InsertPreState populates the given database with the genesis accounts defined by the test.
func (*BlockTest) TryBlocksInsert ¶
func (t *BlockTest) TryBlocksInsert(blockchain *core.BlockChain) ([]btBlock, error)
See https://github.com/ethereum/tests/wiki/Blockchain-Tests-II
Whether a block is valid or not is a bit subtle, it's defined by presence of blockHeader, transactions and uncleHeaders fields. If they are missing, the block is invalid and we must verify that we do not accept it. Since some tests mix valid and invalid blocks we need to check this for every block. If a block is invalid it does not necessarily fail the test, if it's invalidness is expected we are expected to ignore it and continue processing and then validate the post state.
func (*BlockTest) ValidateImportedHeaders ¶
func (test *BlockTest) ValidateImportedHeaders(cm *core.BlockChain, validBlocks []btBlock) error
type DifficultyTest ¶ added in v0.9.9
type DifficultyTest struct { ParentTimestamp string `json:"parentTimestamp"` ParentDifficulty string `json:"parentDifficulty"` UncleHash common.Hash `json:"parentUncles"` CurrentTimestamp string `json:"currentTimestamp"` CurrentBlockNumber string `json:"currentBlockNumber"` CurrentDifficulty string `json:"currentDifficulty"` }
DifficultyTest is the structure of JSON from test files
type Env ¶
func NewEnvFromMap ¶
func (*Env) BlockNumber ¶
func (*Env) DelegateCall ¶
func (*Env) Difficulty ¶
func (*Env) ReturnData ¶ added in v0.9.9
func (*Env) RevertToSnapshot ¶
func (*Env) SetReturnData ¶ added in v0.9.9
func (*Env) SnapshotDatabase ¶
func (*Env) StaticCall ¶ added in v0.9.9
type GenesisAccount ¶ added in v0.9.9
type GenesisAccount struct { Code string `json:"code,omitempty"` Storage map[string]string `json:"storage,omitempty"` Balance string `json:"balance" gencodec:"required"` Nonce string `json:"nonce,omitempty"` PrivateKey string `json:"secretKey,omitempty"` // for tests }
GenesisAccount is an account in the state of the genesis block.
type Log ¶
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 RuleSet ¶
type StateSubtest ¶ added in v0.9.9
StateSubtest selects a specific configuration of a General State Test.
type StateTest ¶ added in v0.9.9
type StateTest struct { Env VmEnv `json:"env"` Pre map[string]Account `json:"pre"` Tx stTransaction `json:"transaction"` Out string `json:"out"` Post map[string][]stPostState `json:"post"` }
StateTest object that matches the General State Test json file
func (*StateTest) Subtests ¶ added in v0.9.9
func (t *StateTest) Subtests() []StateSubtest
Subtests returns all valid subtests of the test.
type TransactionTest ¶
type TransactionTest struct { Blocknumber string Rlp string Sender string Transaction TtTransaction }
type TtTransaction ¶
type TtTransaction struct { Data string GasLimit string GasPrice string Nonce string R string S string To string V string Value string }
Transaction Test JSON Format
type UnsupportedForkError ¶ added in v0.9.9
type UnsupportedForkError struct {
Name string
}
UnsupportedForkError is returned when a test requests a fork that isn't implemented.
func (UnsupportedForkError) Error ¶ added in v0.9.9
func (e UnsupportedForkError) Error() string