State Tests¶
Found in /StateTest
, the state tests aim is to test the basic workings of the state in isolation.
It is based around the notion of executing a single transaction, described by the transaction
portion of the test. The overarching environment in which it is executed is described by the env
portion of the test and includes attributes of the current and previous blocks. A set of pre-existing accounts are detailed in the pre
portion and form the world state prior to execution. Similarly, a set of accounts are detailed in the post
portion to specify the end world state. Since the data of the blockchain is not given, the opcode BLOCKHASH
could not return the hashes of the corresponding blocks. Therefore we define the hash of block number n
to be SHA256("n")
.
The log entries (logs
) as well as any output returned from the code (output
) is also detailed.
It is generally expected that the test implementer will read env
, transaction
and pre
then check their results against logs
, out
, and post
.
Basic structure¶
{
"test name 1": {
"env": { ... },
"logs": { ... },
"out": { ... },
"post": { ... },
"pre": { ... },
"transaction": { ... },
},
"test name 2": {
"env": { ... },
"logs": { ... },
"out": { ... },
"post": { ... },
"pre": { ... },
"transaction": { ... },
},
...
}
Sections¶
- The
env
section:
currentCoinbase
currentDifficulty
currentGasLimit
currentNumber
currentTimestamp
previousHash
- The
transaction
section:
data
gasLimit
gasPrice
nonce
address
secretKey
to
value
- The
pre
andpost
sections each have the same format of a mapping between addresses and accounts. Each account has the format:
balance
nonce
code
storage
"1200"
or "0x04B0"
For values used $DATA_ARRAY.logs
sections is a mapping between the blooms and their corresponding logentries.address
The address of the logentry.data
The data of the logentry.topics
The topics of the logentry, given as an array of values.Finally, there is one simple key output
output
RETURN
instruction). See $DATA_ARRAY. In order to avoid big data files, there is one exception. If the output data is prefixed with #
, the following number represents the size of the output, and not the output directly.
- $DATA_ARRAY - type that intended to contain raw byte data
and for convenient of the users is populated with three types of numbers, all of them should be converted and concatenated to a byte array for VM execution.
The types are:
- number - (unsigned 64bit)
- “longnumber” - (any long number)
- “0xhex_num” - (hex format number)
e.g:````[1, 2, 10000, "0xabc345dFF", "199999999999999999999999999999999999999"]````