Think in Coin | DEV Docs
  • Develop Documents
  • Networks
    • Fantom Network
      • quick-start
        • Short Guide
      • technology
        • Lachesis aBFT
        • Overview
        • Proof of Stake
        • Transaction Fees
        • FAQ
      • staking
        • Quick start
        • Overview
        • Stake on Fantom
        • Run a Validator Node
        • Run a Read-only node
        • Run a Testnet Validator
        • Troubleshooting
      • api
        • Public API endpoints
        • Getting Started
        • Installation
        • GraphQL Schema Basics
        • Schema Structure
        • Implementation Details and Notes
        • Covalent indexing and querying API
      • tutorials
        • Set up Metamask
        • Set up Metamask (testnet)
        • Deploy a Smart Contract
        • Create a Fixed-cap Asset
    • xDAI Chain
      • Welcome to xDai
      • untitled
        • About xdai
          • Projects & DApps
          • Features
          • Use Cases
          • News & Information
          • Roadmaps
          • FAQs
        • For users
          • xDai Token
          • Getting Started with xDai
          • Bridges
          • Wallets
          • Applications
          • Block Explorers
          • Governance
        • For stakers
          • STAKE Token
          • Staking on xDai
          • EasyStaking on Ethereum
          • POSDAO Staking Roadmap
        • For developers
          • Developer Resources & Tools
          • On-Chain Random Numbers
          • Install xDai Client - Run a Non-Validator Node
          • Stable Chain Network Deployment
          • Grants for building on xDai
          • Immunefi Bug Bounty
        • For validators
    • Polygon Network
      • About - Polygon
      • Technology
    • Huobi HECO Chain
      • Huobi Open Platform
    • Binance Chain
      • Create Address
      • Fees
      • Governance
      • Threshold Signature Scheme
      • Atomic Swap
      • WalletConnect
      • Wallets Support
        • WalletConnect Support
        • Trust Wallet User Guide
        • Ledger Wallet Guide
        • Trezor Wallet Guide
        • How to manage BEP8 token with Web Wallet
      • BEP8 Token Protocol
      • Binance DEX Trading
      • Binance Chain Testnet
      • Exchange Integration
      • List Instructions
    • Binance Smart Chain
      • Concepts
        • Consensus
        • Comparison
        • Genesis File
        • BC > BSC Cross-Chain
          • Mechanism
          • Cross-Chain Transfer
          • BSC Relayer
          • Oracle Module
          • Oracle Relayer
          • Relayer incentives
        • Build-in System Contract
        • Governance
      • Ecosystem
      • Gnosis
      • Binance Bridge
        • Release
        • Roadmap
        • User Guides
        • Developer
          • Widget
          • Swagger API reference
        • Partnership
        • Support
          • Customer Support
        • guides
          • Binance Bridge v2
          • Binance Bridge v1
          • Supported Assets
          • Buy BNB as Gas
    • Ethereum (ERC)
      • Ether - Introduction
        • The Ethereum Foundation
        • Community
        • History of Ethereum
        • The Homestead Release
        • What is Ethereum?
        • A platform for decentralized apps
      • The Ethereum network
        • Connecting to the Network
        • Test Networks
      • Mining
      • Contracts and Transactions
        • Account Types, Gas, and Transactions
        • Contracts
        • Accessing Contracts and Transactions
        • Dapps
        • Mix
          • Project Editor
          • Scenarios Editor
          • State Viewer
          • Transaction Explorer
          • JavaScript console
          • Transaction debugger
          • Dapps deployment
          • Code Editor
        • Ethereum Tests
          • Blockchain Tests
          • State Tests
        • Web3 Base Layer Services
    • Harmony ONE
      • developers
        • Getting Started
        • Network & Faucets
        • Deploying on Harmony
        • SDK
        • API
        • Wallets
        • Tools
        • Showcases
        • Hackathon & Bounties
        • Learn
      • network
        • Governance
        • Holders
        • Validators
        • Delegators
      • general
        • Grants
        • Introduction
          • What is Harmony?‌
          • Roadmap
          • Strategy & Architecture
          • Study Materials
          • FAQ
        • Technology
        • Horizon Bridge
        • DApps
        • Ecosystem
        • Community
    • TRON Network (TRC)
      • Introduction
      • Tron Protocol
        • Account
        • Resource Model
        • Super Representatives
          • Mechanism
          • Step to become a Candidate
          • Committee and Proposal
        • Transaction
        • Multi-Signature
          • Example Process Flow
        • Concensus
        • untitled
          • Build transaction locally
      • TRX AND TRC TOKEN
        • TRX
          • TRX Transfer
          • Query TRX balance
        • TRC-10
          • Issue TRC-10 token
          • Participate TRC-10
          • TRC-10 Transfer
          • Query TRC-10 balance
          • TRC-10 Transfer in Smart Contracts
          • Other TRC-10 Interfaces
        • TRC-20
          • Protocol Interface
          • Issuing TRC-20 tokens tutorial
          • TRC-20 Contract Interaction
        • TRC-721
  • Community
    • Github
    • Telegram DEVs
Powered by GitBook
On this page
  • State Tests¶​
  • Basic structure¶​
  • Sections¶​

Was this helpful?

  1. Networks
  2. Ethereum (ERC)
  3. Contracts and Transactions
  4. Ethereum Tests

State Tests

PreviousBlockchain TestsNextWeb3 Base Layer Services

Last updated 2 years ago

Was this helpful?

​​

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

The current block’s coinbase address, to be returned by the COINBASE instruction.

currentDifficulty

The current block’s difficulty, to be returned by the DIFFICULTY instruction.

currentGasLimit

The current block’s gas limit.

currentNumber

currentTimestamp

The current block’s timestamp.

previousHash

The previous block’s hash.

  • The transaction section:

data

The input data passed to the execution, as used by the CALLDATA... instructions. Given as an array of byte values. See $DATA_ARRAY.

gasLimit

The total amount of gas available for the execution, as would be returned by the GAS instruction were it be executed first.

gasPrice

The price of gas for the transaction, as used by the GASPRICE instruction.

nonce

Scalar value equal to the number of transactions sent by the sender.

address

The address of the account under which the code is executing, to be returned by the ADDRESS instruction.

secretKey

The secret key as can be derived by the v,r,s values if the transaction.

to

The address of the transaction’s recipient, to be returned by the ORIGIN instruction.

value

The value of the transaction (or the endowment of the create), to be returned by the CALLVALUE` instruction (if executed first, before any CALL).

  • The pre and post sections each have the same format of a mapping between addresses and accounts. Each account has the format:

balance

The balance of the account.

nonce

The nonce of the account.

code

The body code of the account, given as an array of byte values. See $DATA_ARRAY.

storage

The account’s storage, given as a mapping of keys to values. For key used notion of string as digital or hex number e.g: "1200" or "0x04B0" For values used $DATA_ARRAY.

The logs sections is a mapping between the blooms and their corresponding logentries.

Each logentry has the format:

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

The data, given as an array of bytes, returned from the execution (using the 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:

  1. number - (unsigned 64bit)

  2. “longnumber” - (any long number)

  3. “0xhex_num” - (hex format number)

e.g: [1, 2, 10000, "0xabc345dFF", "199999999999999999999999999999999999999"]

Ethereum Homestead
¶
¶
¶