Documentation ¶
Index ¶
- Constants
- func JSONBytesFromTreeValues(jbs []JSONBytesFromTree) [][]byte
- func ResultEqual(expected JSONBytesFromString, actual []byte) bool
- type Account
- type Block
- type BlockHeader
- type BlockInfo
- type CheckAccount
- type CheckAccounts
- type CheckESDTData
- type CheckESDTInstance
- type CheckStateStep
- type CheckStorageKeyValuePair
- type DumpStateStep
- type ESDTData
- type ESDTInstance
- type ESDTTxData
- type ExternalStepsStep
- type GasSchedule
- type JSONBigInt
- type JSONBytesFromString
- type JSONBytesFromTree
- type JSONCheckBigInt
- type JSONCheckBytes
- type JSONCheckUint64
- type JSONCheckValueList
- type JSONUint64
- type JSONValueList
- type LogEntry
- type LogList
- type NewAddressMock
- type Scenario
- type SetStateStep
- type Step
- type StorageKeyValuePair
- type Test
- type TraceGasStatus
- type Transaction
- type TransactionResult
- type TransactionType
- func (tt TransactionType) HasESDT() bool
- func (tt TransactionType) HasFunction() bool
- func (tt TransactionType) HasGasLimit() bool
- func (tt TransactionType) HasGasPrice() bool
- func (tt TransactionType) HasReceiver() bool
- func (tt TransactionType) HasSender() bool
- func (tt TransactionType) HasValue() bool
- func (tt TransactionType) IsSmartContractTx() bool
- type TxStep
Constants ¶
const StepNameCheckState = "checkState"
StepNameCheckState is a json step type name.
const StepNameDumpState = "dumpState"
StepNameDumpState 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 StepNameScQuery = "scQuery"
StepNameScQuery 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 JSONBytesFromTreeValues ¶
func JSONBytesFromTreeValues(jbs []JSONBytesFromTree) [][]byte
JSONBytesFromTreeValues extracts values from a slice of JSONBytesFromTree into a list
func ResultEqual ¶
func ResultEqual(expected JSONBytesFromString, actual []byte) bool
ResultEqual returns true if result bytes encode the same number.
Types ¶
type Account ¶
type Account struct { Address JSONBytesFromString Shard JSONUint64 IsSmartContract bool Comment string Nonce JSONUint64 Balance JSONBigInt Username JSONBytesFromString Storage []*StorageKeyValuePair Code JSONBytesFromString Owner JSONBytesFromString AsyncCallData string ESDTData []*ESDTData Update bool DeveloperReward JSONBigInt }
Account is a json object representing an account.
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 BlockRandomSeed *JSONBytesFromTree }
BlockInfo contains data for the block info hooks
type CheckAccount ¶
type CheckAccount struct { Address JSONBytesFromString Comment string Nonce JSONCheckUint64 Balance JSONCheckBigInt Username JSONCheckBytes ExplicitStorage bool IgnoreStorage bool MoreStorageAllowed bool CheckStorage []*CheckStorageKeyValuePair Code JSONCheckBytes Owner JSONCheckBytes AsyncCallData JSONCheckBytes CheckESDTData []*CheckESDTData IgnoreESDT bool MoreESDTTokensAllowed bool DeveloperReward JSONCheckBigInt }
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 { Accounts []*CheckAccount MoreAccountsAllowed bool }
CheckAccounts encodes rules to check mock accounts.
type CheckESDTData ¶
type CheckESDTData struct { TokenIdentifier JSONBytesFromString Instances []*CheckESDTInstance LastNonce JSONCheckUint64 Roles []string Frozen JSONCheckUint64 }
CheckESDTData checks the ESDT tokens held by an account
type CheckESDTInstance ¶
type CheckESDTInstance struct { Nonce JSONUint64 Balance JSONCheckBigInt Creator JSONCheckBytes Royalties JSONCheckUint64 Hash JSONCheckBytes Uris JSONCheckValueList Attributes JSONCheckBytes }
CheckESDTInstance checks an instance of an NFT/SFT, with its own nonce
func NewCheckESDTInstance ¶
func NewCheckESDTInstance() *CheckESDTInstance
NewCheckESDTInstance creates an instance with all fields unspecified.
type CheckStateStep ¶
type CheckStateStep struct { CheckStateIdent string 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 CheckStorageKeyValuePair ¶
type CheckStorageKeyValuePair struct { Key JSONBytesFromString CheckValue JSONCheckBytes }
CheckStorageKeyValuePair checks a single entry in storage.
type DumpStateStep ¶
type DumpStateStep struct {
Comment string
}
DumpStateStep is a step that simply prints the entire state to console. Useful for debugging.
func (*DumpStateStep) StepTypeName ¶
func (*DumpStateStep) StepTypeName() string
StepTypeName type as string
type ESDTData ¶
type ESDTData struct { TokenIdentifier JSONBytesFromString Instances []*ESDTInstance LastNonce JSONUint64 Roles []string Frozen JSONUint64 }
ESDTData models an account holding an ESDT token
type ESDTInstance ¶
type ESDTInstance struct { Nonce JSONUint64 Balance JSONBigInt Creator JSONBytesFromString Royalties JSONUint64 Hash JSONBytesFromString Uris JSONValueList Attributes JSONBytesFromString }
ESDTInstance models an instance of an NFT/SFT, with its own nonce
type ESDTTxData ¶
type ESDTTxData struct { TokenIdentifier JSONBytesFromString Nonce JSONUint64 Value JSONBigInt }
ESDTTxData models the transfer of tokens in a tx
type ExternalStepsStep ¶
type ExternalStepsStep struct { Comment string TraceGas TraceGasStatus Path string }
ExternalStepsStep allows including steps from another file
func (*ExternalStepsStep) StepTypeName ¶
func (*ExternalStepsStep) StepTypeName() string
StepTypeName type as string
type GasSchedule ¶
type GasSchedule int
GasSchedule encodes the gas model to be used in scenario tests
const ( // GasScheduleDefault indicates that the scenario should use whatever the default gas model is. // Should be the latest version of the mainnet gas schedule. GasScheduleDefault GasSchedule = iota // GasScheduleDummy is a dummy model, with all costs set to 1. GasScheduleDummy // GasScheduleV3 is currently used on mainnet. GasScheduleV3 // GasScheduleV4 is currently used on mainnet. GasScheduleV4 )
type JSONBigInt ¶
JSONBigInt stores the parsed big int value but also the original parsed string
func JSONBigIntZero ¶
func JSONBigIntZero() JSONBigInt
JSONBigIntZero provides an unitialized zero value.
type JSONBytesFromString ¶
JSONBytesFromString stores a byte slice
func JSONBytesEmpty ¶
func JSONBytesEmpty() JSONBytesFromString
JSONBytesEmpty creates a new JSONBytesFromString instance with default values.
func NewJSONBytesFromString ¶
func NewJSONBytesFromString(value []byte, originalStr string) JSONBytesFromString
NewJSONBytesFromString creates a new JSONBytesFromString instance.
type JSONBytesFromTree ¶
type JSONBytesFromTree struct { Value []byte Original oj.OJsonObject Unspecified bool }
JSONBytesFromTree stores a parsed byte slice, either from a string, or from a list of strings. The list of strings representation can be used in storage, arguments or results, and it is designed to make it easier to express serialized objects. The strings in the list get simply concatenated to produce a value.
func (JSONBytesFromTree) OriginalEmpty ¶
func (jb JSONBytesFromTree) OriginalEmpty() bool
OriginalEmpty returns true if the object originates from "".
type JSONCheckBigInt ¶
JSONCheckBigInt holds a big int condition. Values are checked for equality. "*" allows all values.
func JSONCheckBigIntUnspecified ¶
func JSONCheckBigIntUnspecified() JSONCheckBigInt
JSONCheckBigIntUnspecified yields JSONCheckBigInt default "*" value.
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.
func (JSONCheckBigInt) IsUnspecified ¶
func (jcbi JSONCheckBigInt) IsUnspecified() bool
IsUnspecified yields true if the field was originally unspecified.
type JSONCheckBytes ¶
type JSONCheckBytes struct { Value []byte IsStar bool Original oj.OJsonObject Unspecified bool }
JSONCheckBytes holds a byte slice condition. Values are checked for equality. "*" allows all values.
func JSONCheckBytesReconstructed ¶
func JSONCheckBytesReconstructed(value []byte, originalString string) JSONCheckBytes
JSONCheckBytesReconstructed creates a JSONCheckBytes without an original JSON source.
func JSONCheckBytesStar ¶
func JSONCheckBytesStar() JSONCheckBytes
JSONCheckBytesStar yields JSONCheckBytes explicit "*" value.
func JSONCheckBytesUnspecified ¶
func JSONCheckBytesUnspecified() JSONCheckBytes
JSONCheckBytesUnspecified yields JSONCheckBytes that check that value is empty.
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.
func (JSONCheckBytes) IsUnspecified ¶
func (jcbytes JSONCheckBytes) IsUnspecified() bool
IsUnspecified yields true if the field was originally unspecified.
func (JSONCheckBytes) OriginalEmpty ¶
func (jcbytes JSONCheckBytes) OriginalEmpty() bool
OriginalEmpty returns true if original = "".
type JSONCheckUint64 ¶
JSONCheckUint64 holds a uint64 condition. Values are checked for equality. "*" allows all values.
func JSONCheckUint64Unspecified ¶
func JSONCheckUint64Unspecified() JSONCheckUint64
JSONCheckUint64Unspecified yields JSONCheckBigInt default "*" value.
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.
func (JSONCheckUint64) CheckBool ¶
func (jcu JSONCheckUint64) CheckBool(other bool) bool
CheckBool interprets own value as bool (true = anything > 0, false = 0), We are using JSONCheckUint64 for bool too so we don't create another type.
func (JSONCheckUint64) IsUnspecified ¶
func (jcu JSONCheckUint64) IsUnspecified() bool
IsUnspecified yields true if the field was originally unspecified.
type JSONCheckValueList ¶
type JSONCheckValueList struct { Values []JSONCheckBytes IsStar bool Unspecified bool }
JSONCheckValueList represents a list of value checks, as expressed in JSON. TODO: add star for all values
func JSONCheckValueListStar ¶
func JSONCheckValueListStar() JSONCheckValueList
JSONCheckValueListStar yields the "*" value
func JSONCheckValueListUnspecified ¶
func JSONCheckValueListUnspecified() JSONCheckValueList
JSONCheckValueListUnspecified yields JSONCheckBytesList empty value.
func (JSONCheckValueList) CheckList ¶
func (jcbl JSONCheckValueList) CheckList(other [][]byte) bool
CheckList compares expected value with a list of values.
func (JSONCheckValueList) IsUnspecified ¶
func (jcbl JSONCheckValueList) IsUnspecified() bool
IsUnspecified yields true if the field was originally unspecified.
type JSONUint64 ¶
JSONUint64 stores the parsed uint64 value but also the original parsed string
func JSONUint64Zero ¶
func JSONUint64Zero() JSONUint64
JSONUint64Zero provides an unitialized zero value.
func (*JSONUint64) OriginalEmpty ¶
func (ju *JSONUint64) OriginalEmpty() bool
OriginalEmpty returns true if the object originates from "".
type JSONValueList ¶
type JSONValueList struct {
Values []JSONBytesFromString
}
JSONValueList represents a list of values, as expressed in JSON
func (JSONValueList) IsUnspecified ¶
func (jvl JSONValueList) IsUnspecified() bool
IsUnspecified yields true if the field was originally unspecified.
func (JSONValueList) ToValues ¶
func (jvl JSONValueList) ToValues() [][]byte
ToValues extracts values from a JSONValueList
type LogEntry ¶
type LogEntry struct { Address JSONCheckBytes Endpoint JSONCheckBytes Topics JSONCheckValueList Data JSONCheckBytes }
LogEntry is a json object representing an expected transaction result log entry.
type NewAddressMock ¶
type NewAddressMock struct { CreatorAddress JSONBytesFromString CreatorNonce JSONUint64 NewAddress JSONBytesFromString }
NewAddressMock allows tests to specify what new addresses to generate
type Scenario ¶
type Scenario struct { Name string Comment string CheckGas bool TraceGas bool IsNewTest bool GasSchedule GasSchedule Steps []Step }
Scenario is a json object representing a test scenario with steps.
type SetStateStep ¶
type SetStateStep struct { SetStateIdent string Comment string Accounts []*Account PreviousBlockInfo *BlockInfo CurrentBlockInfo *BlockInfo BlockHashes JSONValueList 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 ¶
type StorageKeyValuePair struct { Key JSONBytesFromString Value JSONBytesFromTree }
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 JSONValueList PostState *CheckAccounts }
Test is a json object representing a test.
type TraceGasStatus ¶
type TraceGasStatus int
const ( FalseValue TraceGasStatus = iota TrueValue TraceGasStatus = iota Undefined TraceGasStatus = iota )
func (TraceGasStatus) ToInt ¶
func (tgs TraceGasStatus) ToInt() int
type Transaction ¶
type Transaction struct { Type TransactionType Nonce JSONUint64 EGLDValue JSONBigInt ESDTValue []*ESDTTxData From JSONBytesFromString To JSONBytesFromString Function string Code JSONBytesFromString Arguments []JSONBytesFromTree GasPrice JSONUint64 GasLimit JSONUint64 }
Transaction is a json object representing a transaction.
type TransactionResult ¶
type TransactionResult struct { Out JSONCheckValueList Status JSONCheckBigInt Message JSONCheckBytes Gas JSONCheckUint64 Refund JSONCheckBigInt Logs LogList }
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 // ScQuery simulates an off-chain call. // It is like a SCCall, but without a sender and with infinite gas. ScQuery // 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 the reward value in storage. ValidatorReward )
func (TransactionType) HasESDT ¶
func (tt TransactionType) HasESDT() bool
HasESDT is a helper function to indicate if transaction has `esdtValue` or `esdtToken` fields.
func (TransactionType) HasFunction ¶
func (tt TransactionType) HasFunction() bool
HasFunction indicates whether tx type allows a `function` field.
func (TransactionType) HasGasLimit ¶
func (tt TransactionType) HasGasLimit() bool
HasGasLimit is a helper function to indicate if transaction has `gasLimit` field.
func (TransactionType) HasGasPrice ¶
func (tt TransactionType) HasGasPrice() bool
HasGasPrice is a helper function to indicate if transaction has `gasPrice` field.
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 `from` field.
func (TransactionType) HasValue ¶
func (tt TransactionType) HasValue() bool
HasValue indicates whether tx type allows a `value` 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 DisplayLogs bool Tx *Transaction ExpectedResult *TransactionResult }
TxStep is a step where a transaction is executed.