mandosjsonmodel

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const StepNameCheckState = "checkState"

StepNameCheckState is a json step type name.

View Source
const StepNameExternalSteps = "externalSteps"

StepNameExternalSteps is a json step type name.

View Source
const StepNameScCall = "scCall"

StepNameScCall is a json step type name.

View Source
const StepNameScDeploy = "scDeploy"

StepNameScDeploy is a json step type name.

View Source
const StepNameSetState = "setState"

StepNameSetState is a json step type name.

View Source
const StepNameTransfer = "transfer"

StepNameTransfer is a json step type name.

View Source
const StepNameValidatorReward = "validatorReward"

StepNameValidatorReward is a json step type name.

Variables

This section is empty.

Functions

func JSONBytesValues

func JSONBytesValues(jbs []JSONBytes) [][]byte

JSONBytesValues extracts values from a slice of JSONBytes into a list

func JSONCheckBytesString

func JSONCheckBytesString(jcbs []JSONCheckBytes) string

JSONCheckBytesString formats a list of JSONCheckBytes for printing to console.

func ResultAsString

func ResultAsString(result [][]byte) string

ResultAsString helps create nicer error messages.

func ResultEqual

func ResultEqual(expected JSONBytes, actual []byte) bool

ResultEqual returns true if result bytes encode the same number.

Types

type Account

type Account struct {
	Address       JSONBytes
	Comment       string
	Nonce         JSONUint64
	Balance       JSONBigInt
	Storage       []*StorageKeyValuePair
	Code          JSONBytes
	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 Block

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

Block is a json object representing a block.

type BlockHeader

type BlockHeader struct {
	Beneficiary JSONBigInt // "coinbase"
	Difficulty  JSONBigInt
	Number      JSONBigInt
	GasLimit    JSONBigInt
	Timestamp   JSONUint64
}

BlockHeader is a json object representing the block header.

type BlockInfo

type BlockInfo struct {
	BlockTimestamp JSONUint64
	BlockNonce     JSONUint64
	BlockRound     JSONUint64
	BlockEpoch     JSONUint64
}

BlockInfo contains data for the block info hooks

type CheckAccount

type CheckAccount struct {
	Address       JSONBytes
	Comment       string
	Nonce         JSONCheckUint64
	Balance       JSONCheckBigInt
	IgnoreStorage bool
	CheckStorage  []*StorageKeyValuePair
	Code          JSONCheckBytes
	AsyncCallData string
}

CheckAccount is a json object representing checks for an account.

func FindCheckAccount

func FindCheckAccount(accounts []*CheckAccount, address []byte) *CheckAccount

FindCheckAccount searches a check account list by address.

type CheckAccounts

type CheckAccounts struct {
	OtherAccountsAllowed bool
	Accounts             []*CheckAccount
}

CheckAccounts encodes rules to check mock accounts.

type CheckStateStep

type CheckStateStep struct {
	Comment       string
	CheckAccounts *CheckAccounts
}

CheckStateStep is a step where the state of the blockchain mock is verified.

func (*CheckStateStep) StepTypeName

func (*CheckStateStep) StepTypeName() string

StepTypeName type as string

type ExternalStepsStep

type ExternalStepsStep struct {
	Path string
}

ExternalStepsStep allows including steps from another file

func (*ExternalStepsStep) StepTypeName

func (*ExternalStepsStep) StepTypeName() string

StepTypeName type as string

type JSONBigInt

type JSONBigInt struct {
	Value    *big.Int
	Original string
}

JSONBigInt stores the parsed big int value but also the original parsed string

type JSONBytes

type JSONBytes struct {
	Value    []byte
	Original string
}

JSONBytes stores the parsed byte slice value but also the original parsed string

type JSONCheckBigInt

type JSONCheckBigInt struct {
	Value    *big.Int
	IsStar   bool
	Original string
}

JSONCheckBigInt holds a big int condition. Values are checked for equality. "*" allows all values.

func (JSONCheckBigInt) Check

func (jcbi JSONCheckBigInt) Check(other *big.Int) bool

Check returns true if condition expressed in object holds for another value. Explicit values are interpreted as equals assertion.

type JSONCheckBytes

type JSONCheckBytes struct {
	Value    []byte
	IsStar   bool
	Original string
}

JSONCheckBytes holds a byte slice condition. Values are checked for equality. "*" allows all values.

func (JSONCheckBytes) Check

func (jcbytes JSONCheckBytes) Check(other []byte) bool

Check returns true if condition expressed in object holds for another value. Explicit values are interpreted as equals assertion.

type JSONCheckUint64

type JSONCheckUint64 struct {
	Value    uint64
	IsStar   bool
	Original string
}

JSONCheckUint64 holds a uint64 condition. Values are checked for equality. "*" allows all values.

func (JSONCheckUint64) Check

func (jcu JSONCheckUint64) Check(other uint64) bool

Check returns true if condition expressed in object holds for another value. Explicit values are interpreted as equals assertion.

type JSONUint64

type JSONUint64 struct {
	Value    uint64
	Original string
}

JSONUint64 stores the parsed uint64 value but also the original parsed string

type LogEntry

type LogEntry struct {
	Address    JSONBytes
	Identifier JSONBytes
	Topics     []JSONBytes
	Data       JSONBytes
}

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

type NewAddressMock

type NewAddressMock struct {
	CreatorAddress JSONBytes
	CreatorNonce   JSONUint64
	NewAddress     JSONBytes
}

NewAddressMock allows tests to specify what new addresses to generate

type Scenario

type Scenario struct {
	Name     string
	Comment  string
	CheckGas bool
	Steps    []Step
}

Scenario is a json object representing a test scenario with steps.

func ConvertTestToScenario

func ConvertTestToScenario(top []*Test) (*Scenario, error)

ConvertTestToScenario converts the old test format to the new scenario format for tests.

type SetStateStep

type SetStateStep struct {
	Comment           string
	Accounts          []*Account
	PreviousBlockInfo *BlockInfo
	CurrentBlockInfo  *BlockInfo
	BlockHashes       []JSONBytes
	NewAddressMocks   []*NewAddressMock
}

SetStateStep is a step where data is saved to the blockchain mock.

func (*SetStateStep) StepTypeName

func (*SetStateStep) StepTypeName() string

StepTypeName type as string

type Step

type Step interface {
	StepTypeName() string
}

Step is the basic block of a scenario.

type StorageKeyValuePair

type StorageKeyValuePair struct {
	Key   JSONBytes
	Value JSONBytes
}

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 []JSONBytes
	PostState   *CheckAccounts
}

Test is a json object representing a test.

type Transaction

type Transaction struct {
	Type      TransactionType
	Nonce     JSONUint64
	Value     JSONBigInt
	From      JSONBytes
	To        JSONBytes
	Function  string
	Code      JSONBytes
	Arguments []JSONBytes
	GasPrice  JSONUint64
	GasLimit  JSONUint64
}

Transaction is a json object representing a transaction.

type TransactionResult

type TransactionResult struct {
	Out        []JSONCheckBytes
	Status     JSONBigInt
	Message    string
	Gas        JSONCheckUint64
	Refund     JSONCheckBigInt
	IgnoreLogs bool
	LogHash    string
	Logs       []*LogEntry
}

TransactionResult is a json object representing an expected transaction result.

type TransactionType

type TransactionType int

TransactionType describes the type of simulate transaction

const (
	// ScDeploy describes a transaction that deploys a new contract
	ScDeploy TransactionType = iota

	// ScCall describes a regular smart contract call
	ScCall

	// Transfer is an ERD transfer transaction without calling a smart contract
	Transfer

	// ValidatorReward is when the protocol sends a validator reward to the target account.
	// It increases the balance, but also increments "ELROND_Reward" in storage.
	ValidatorReward
)

func (TransactionType) HasReceiver

func (tt TransactionType) HasReceiver() bool

HasReceiver is a helper function to indicate if transaction has receiver.

func (TransactionType) HasSender

func (tt TransactionType) HasSender() bool

HasSender is a helper function to indicate if transaction has `to` field.

func (TransactionType) IsSmartContractTx

func (tt TransactionType) IsSmartContractTx() bool

IsSmartContractTx indicates whether tx type allows an `expect` field.

type TxStep

type TxStep struct {
	TxIdent        string
	Comment        string
	Tx             *Transaction
	ExpectedResult *TransactionResult
}

TxStep is a step where a transaction is executed.

func (*TxStep) StepTypeName

func (t *TxStep) StepTypeName() string

StepTypeName type as string

Jump to

Keyboard shortcuts

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