Documentation ¶
Index ¶
- Constants
- func CreateMultiTransferData(to []byte, dcdtData []*DCDTTxData, endpointName string, arguments [][]byte) []byte
- func JSONBytesFromTreeValues(jbs []JSONBytesFromTree) [][]byte
- type Account
- type BlockInfo
- type CheckAccount
- type CheckAccounts
- type CheckDCDTData
- type CheckDCDTInstance
- type CheckStateStep
- type CheckStorageKeyValuePair
- type DCDTData
- type DCDTInstance
- type DCDTTxData
- type DumpStateStep
- 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 TraceGasStatus
- type Transaction
- type TransactionResult
- type TransactionType
- func (tt TransactionType) HasDCDT() 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 StepNameScUpgrade = "scUpgrade"
StepNameScUpgrade 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 CreateMultiTransferData ¶
func CreateMultiTransferData(to []byte, dcdtData []*DCDTTxData, endpointName string, arguments [][]byte) []byte
CreateMultiTransferData builds data for a multiTransferDCDT
func JSONBytesFromTreeValues ¶
func JSONBytesFromTreeValues(jbs []JSONBytesFromTree) [][]byte
JSONBytesFromTreeValues extracts values from a slice of JSONBytesFromTree into a list
Types ¶
type Account ¶
type Account struct { Address JSONBytesFromString Shard JSONUint64 IsSmartContract bool Comment string Nonce JSONUint64 Balance JSONBigInt Username JSONBytesFromString Storage []*StorageKeyValuePair Code JSONBytesFromString CodeMetadata JSONBytesFromString Owner JSONBytesFromString AsyncCallData string DCDTData []*DCDTData Update bool DeveloperReward JSONBigInt }
Account is a json object representing an account.
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 CodeMetadata JSONCheckBytes Owner JSONCheckBytes AsyncCallData JSONCheckBytes CheckDCDTData []*CheckDCDTData IgnoreDCDT bool MoreDCDTTokensAllowed 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 CheckDCDTData ¶
type CheckDCDTData struct { TokenIdentifier JSONBytesFromString Instances []*CheckDCDTInstance LastNonce JSONCheckUint64 Roles []string Frozen JSONCheckUint64 }
CheckDCDTData checks the DCDT tokens held by an account
type CheckDCDTInstance ¶
type CheckDCDTInstance struct { Nonce JSONUint64 Balance JSONCheckBigInt Creator JSONCheckBytes Royalties JSONCheckUint64 Hash JSONCheckBytes Uris JSONCheckValueList Attributes JSONCheckBytes }
CheckDCDTInstance checks an instance of an NFT/SFT, with its own nonce
func NewCheckDCDTInstance ¶
func NewCheckDCDTInstance() *CheckDCDTInstance
NewCheckDCDTInstance 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 DCDTData ¶
type DCDTData struct { TokenIdentifier JSONBytesFromString Instances []*DCDTInstance LastNonce JSONUint64 Roles []string Frozen JSONUint64 }
DCDTData models an account holding an DCDT token
type DCDTInstance ¶
type DCDTInstance struct { Nonce JSONUint64 Balance JSONBigInt Creator JSONBytesFromString Royalties JSONUint64 Hash JSONBytesFromString Uris JSONValueList Attributes JSONBytesFromTree }
DCDTInstance models an instance of an NFT/SFT, with its own nonce
type DCDTTxData ¶
type DCDTTxData struct { TokenIdentifier JSONBytesFromString Nonce JSONUint64 Value JSONBigInt }
DCDTTxData models the transfer of tokens in a tx
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 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 JSONCheckValueList }
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 TraceGasStatus ¶
type TraceGasStatus int
TraceGasStatus defines the trace gas status
const ( FalseValue TraceGasStatus = iota TrueValue TraceGasStatus = iota Undefined TraceGasStatus = iota )
constants defining all TraceGasStatus possible values
func (TraceGasStatus) ToInt ¶
func (tgs TraceGasStatus) ToInt() int
ToInt returns the int representation of the current TraceGasStatus
type Transaction ¶
type Transaction struct { Type TransactionType Nonce JSONUint64 REWAValue JSONBigInt DCDTValue []*DCDTTxData From JSONBytesFromString To JSONBytesFromString Function string Code JSONBytesFromString CodeMetadata 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 MOA 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 // ScUpgrade describes a transaction that upgrades an existing contract ScUpgrade )
func (TransactionType) HasDCDT ¶
func (tt TransactionType) HasDCDT() bool
HasDCDT is a helper function to indicate if transaction has `dcdtValue` or `dcdtToken` 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.