Documentation ¶
Index ¶
- Constants
- func JSONBytesFromStringValues(jbs []JSONBytesFromString) [][]byte
- func JSONBytesFromTreeValues(jbs []JSONBytesFromTree) [][]byte
- func ResultAsString(result [][]byte) string
- func ResultEqual(expected JSONBytesFromString, actual []byte) bool
- type Account
- type Block
- type BlockHeader
- type BlockInfo
- type CheckAccount
- type CheckAccounts
- type CheckDCDTData
- type CheckDCDTInstance
- type CheckStateStep
- 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 JSONUint64
- type LogEntry
- type NewAddressMock
- type Scenario
- type SetStateStep
- type Step
- type StorageKeyValuePair
- type Test
- type Transaction
- type TransactionResult
- type TransactionType
- func (tt TransactionType) HasDCDT() bool
- func (tt TransactionType) HasFunction() bool
- func (tt TransactionType) HasGas() 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 JSONBytesFromStringValues ¶
func JSONBytesFromStringValues(jbs []JSONBytesFromString) [][]byte
JSONBytesFromStringValues extracts values from a slice of JSONBytesFromString into a list
func JSONBytesFromTreeValues ¶
func JSONBytesFromTreeValues(jbs []JSONBytesFromTree) [][]byte
JSONBytesFromTreeValues extracts values from a slice of JSONBytesFromTree into a list
func ResultAsString ¶
ResultAsString helps create nicer error messages.
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 DCDTData []*DCDTData }
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 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 IgnoreStorage bool CheckStorage []*StorageKeyValuePair Code JSONCheckBytes Owner JSONCheckBytes AsyncCallData JSONCheckBytes IgnoreDCDT bool CheckDCDTData []*CheckDCDTData }
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 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 JSONCheckUint64 Balance JSONCheckBigInt Uri JSONCheckBytes }
CheckDCDTInstance checks an instance of an NFT/SFT, with its own nonce
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 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 Uri JSONBytesFromTree }
DCDTInstance models an instance of an NFT/SFT, with its own nonce
type DCDTTxData ¶
type DCDTTxData struct { TokenIdentifier JSONBytesFromString Nonce JSONUint64 Value JSONBigInt }
DCDTTransfer 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 ¶
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 // GasScheduleV1 was previously used on mainnet. GasScheduleV1 // GasScheduleV2 was previously used on mainnet. GasScheduleV2 // GasScheduleV3 is currently used on mainnet. GasScheduleV3 )
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 NewJSONBytesFromString ¶
func NewJSONBytesFromString(value []byte, originalStr string) JSONBytesFromString
NewJSONBytesFromString creates a new JSONBytesFromString instance.
type JSONBytesFromTree ¶
type JSONBytesFromTree struct { Value []byte Original oj.OJsonObject }
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 JSONCheckBytesExplicitStar ¶
func JSONCheckBytesExplicitStar() JSONCheckBytes
JSONCheckBytesExplicitStar yields JSONCheckBytes explicit "*" value.
func JSONCheckBytesReconstructed ¶
func JSONCheckBytesReconstructed(value []byte) JSONCheckBytes
JSONCheckBytesReconstructed creates a JSONCheckBytes without an original JSON source.
func JSONCheckBytesUnspecified ¶
func JSONCheckBytesUnspecified() JSONCheckBytes
JSONCheckBytesUnspecified yields JSONCheckBytes default "*" value.
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 JSONUint64 ¶
JSONUint64 stores the parsed uint64 value but also the original parsed string
type LogEntry ¶
type LogEntry struct { Address JSONCheckBytes Identifier JSONCheckBytes Topics []JSONCheckBytes 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 GasSchedule GasSchedule Steps []Step }
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 []JSONBytesFromString 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 []JSONBytesFromString PostState *CheckAccounts }
Test is a json object representing a test.
type Transaction ¶
type Transaction struct { Type TransactionType Nonce JSONUint64 Value JSONBigInt DCDTValue *DCDTTxData 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 []JSONCheckBytes Status JSONCheckBigInt Message JSONCheckBytes Gas JSONCheckUint64 Refund JSONCheckBigInt LogsStar bool LogsUnspecified 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 // 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 )
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) HasGas ¶
func (tt TransactionType) HasGas() bool
HasGas is a helper function to indicate if transaction has `dcdtValue` or `dcdtToken` fields.
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) 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 Tx *Transaction ExpectedResult *TransactionResult }
TxStep is a step where a transaction is executed.