Documentation
¶
Index ¶
- Constants
- func JSONBytesValues(jbs []JSONBytes) [][]byte
- func JSONCheckBytesString(jcbs []JSONCheckBytes) string
- func ResultAsString(result [][]byte) string
- func ResultEqual(expected JSONBytes, actual []byte) bool
- type Account
- type Block
- type BlockHeader
- type BlockInfo
- type CheckAccount
- type CheckAccounts
- type CheckStateStep
- type ExternalStepsStep
- type JSONBigInt
- type JSONBytes
- type JSONCheckBigInt
- type JSONCheckBytes
- type JSONCheckUint64
- type JSONUint64
- type LogEntry
- type NewAddressMock
- type Scenario
- type SetStateStep
- type Step
- type StorageKeyValuePair
- type Test
- type Transaction
- type TransactionResult
- type TransactionType
- type TxStep
Constants ¶
const StepNameCheckState = "checkState"
StepNameCheckState is a json step type name.
const StepNameExternalSteps = "externalSteps"
StepNameExternalSteps is a json step type name.
const StepNameScCall = "scCall"
StepNameScCall is a json step type name.
const StepNameScDeploy = "scDeploy"
StepNameScDeploy is a json step type name.
const StepNameSetState = "setState"
StepNameSetState is a json step type name.
const StepNameTransfer = "transfer"
StepNameTransfer is a json step type name.
const StepNameValidatorReward = "validatorReward"
StepNameValidatorReward is a json step type name.
Variables ¶
This section is empty.
Functions ¶
func JSONBytesValues ¶
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 ¶
ResultAsString helps create nicer error messages.
func ResultEqual ¶
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 ¶
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 ¶
JSONBigInt stores the parsed big int value but also the original parsed string
type JSONCheckBigInt ¶
JSONCheckBigInt holds a big int condition. Values are checked for equality. "*" allows all values.
type JSONCheckBytes ¶
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 ¶
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 ¶
JSONUint64 stores the parsed uint64 value but also the original parsed string
type NewAddressMock ¶
type NewAddressMock struct { CreatorAddress JSONBytes CreatorNonce JSONUint64 NewAddress JSONBytes }
NewAddressMock allows tests to specify what new addresses to generate
type Scenario ¶
Scenario is a json object representing a test scenario with steps.
func ConvertTestToScenario ¶
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 StorageKeyValuePair ¶
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.