vmtestjson

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogToString

func LogToString(logEntry *LogEntry) string

LogToString returns a json representation of a log entry, we use it for debugging

func ResultAsString added in v0.0.8

func ResultAsString(result [][]byte) string

ResultAsString helps create nicer error messages.

func ResultEqual added in v0.0.8

func ResultEqual(expected, actual []byte) bool

ResultEqual returns true if result bytes encode the same number.

func ToJSONString

func ToJSONString(testTopLevel []*Test) string

ToJSONString converts a test object to its JSON representation.

func ToOrderedJSON

func ToOrderedJSON(testTopLevel []*Test) oj.OJsonObject

ToOrderedJSON converts a test object to an ordered JSON object.

Types

type Account

type Account struct {
	Address       []byte
	Nonce         *big.Int
	Balance       *big.Int
	Storage       []*StorageKeyValuePair
	Code          string
	OriginalCode  string
	AsyncCallData string
}

Account is a json object representing an account.

func FindAccount

func FindAccount(accounts []*Account, address []byte) *Account

FindAccount searches an account list by address.

type Argument added in v0.0.9

type Argument struct {
	// contains filtered or unexported fields
}

Argument encodes an argument in a transaction. Can distinguish values written explicitly as poitive or negative (e.g. -0x01, +0xFF), in order to provide some additional context on how to interpret them in an actual test.

func (Argument) ToBytes added in v0.0.9

func (arg Argument) ToBytes() []byte

ToBytes yields value as byte array. Can force sign if so specified in the test json.

func (Argument) ToBytesAlwaysForceSign added in v0.0.9

func (arg Argument) ToBytesAlwaysForceSign() []byte

ToBytesAlwaysForceSign yields value as byte array, always forcing the correct test bit, even if it means adding an extra byte.

type Block

type Block struct {
	Results      []*TransactionResult
	Transactions []*Transaction
	BlockHeader  *BlockHeader
}

Block is a json object representing a block.

type BlockHeader

type BlockHeader struct {
	Beneficiary *big.Int // "coinbase"
	Difficulty  *big.Int
	Number      *big.Int
	GasLimit    *big.Int
	Timestamp   uint64
}

BlockHeader is a json object representing the block header.

type LogEntry

type LogEntry struct {
	Address []byte
	Topics  [][]byte
	Data    []byte
}

LogEntry is a json object representing an expected transaction result log entry.

type StorageKeyValuePair

type StorageKeyValuePair struct {
	Key   []byte
	Value []byte
}

StorageKeyValuePair is a json key value pair in the storage map.

type Test

type Test struct {
	TestName    string
	CheckGas    bool
	Pre         []*Account
	Blocks      []*Block
	Network     string
	BlockHashes [][]byte
	PostState   []*Account
}

Test is a json object representing a test.

func ParseTopLevel

func ParseTopLevel(jsonString []byte) ([]*Test, error)

ParseTopLevel converts json string to object representation

type Transaction

type Transaction struct {
	Nonce         uint64
	Value         *big.Int
	IsCreate      bool
	From          []byte
	To            []byte
	Function      string
	ContractCode  string
	AssembledCode string
	Arguments     []Argument
	GasPrice      uint64
	GasLimit      uint64
}

Transaction is a json object representing a transaction.

type TransactionResult

type TransactionResult struct {
	Out        [][]byte
	Status     *big.Int
	Message    string
	CheckGas   bool
	Gas        uint64
	Refund     *big.Int
	IgnoreLogs bool
	LogHash    string
	Logs       []*LogEntry
}

TransactionResult is a json object representing an expected transaction result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL