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 CheckStateStep
- type DumpStateStep
- type ExternalStepsStep
- 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
- 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 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 ¶ added in v0.0.3
func JSONBytesFromStringValues(jbs []JSONBytesFromString) [][]byte
JSONBytesFromStringValues extracts values from a slice of JSONBytesFromString into a list
func JSONBytesFromTreeValues ¶ added in v0.0.3
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
Comment string
Nonce JSONUint64
Balance JSONBigInt
Storage []*StorageKeyValuePair
Code JSONBytesFromString
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 JSONBytesFromString
Comment string
Nonce JSONCheckUint64
Balance JSONCheckBigInt
IgnoreStorage bool
CheckStorage []*StorageKeyValuePair
Code JSONCheckBytes
AsyncCallData JSONCheckBytes
}
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 DumpStateStep ¶ added in v0.0.3
type DumpStateStep struct {
Comment string
}
DumpStateStep is a step that simply prints the entire state to console. Useful for debugging.
func (*DumpStateStep) StepTypeName ¶ added in v0.0.3
func (*DumpStateStep) 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 JSONBytesFromString ¶ added in v0.0.3
JSONBytesFromString stores a byte slice
func NewJSONBytesFromString ¶ added in v0.0.3
func NewJSONBytesFromString(value []byte, originalStr string) JSONBytesFromString
NewJSONBytesFromString creates a new JSONBytesFromString instance.
type JSONBytesFromTree ¶ added in v0.0.3
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 ¶ added in v0.0.3
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 JSONCheckBigIntDefault ¶ added in v0.0.3
func JSONCheckBigIntDefault() JSONCheckBigInt
JSONCheckBigIntDefault 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) IsDefault ¶ added in v0.0.3
func (jcbi JSONCheckBigInt) IsDefault() bool
IsDefault yields true if the field was originally unspecified.
type JSONCheckBytes ¶
type JSONCheckBytes struct {
Value []byte
IsStar bool
Original oj.OJsonObject
}
JSONCheckBytes holds a byte slice condition. Values are checked for equality. "*" allows all values.
func JSONCheckBytesDefault ¶ added in v0.0.3
func JSONCheckBytesDefault() JSONCheckBytes
JSONCheckBytesDefault yields JSONCheckBytes default "*" value.
func JSONCheckBytesExplicitStar ¶ added in v0.0.3
func JSONCheckBytesExplicitStar() JSONCheckBytes
JSONCheckBytesExplicitStar yields JSONCheckBytes explicit "*" 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) IsDefault ¶ added in v0.0.3
func (jcbytes JSONCheckBytes) IsDefault() bool
IsDefault yields true if the field was originally unspecified.
func (JSONCheckBytes) OriginalEmpty ¶ added in v0.0.3
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 JSONCheckUint64Default ¶ added in v0.0.3
func JSONCheckUint64Default() JSONCheckUint64
JSONCheckUint64Default 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) IsDefault ¶ added in v0.0.3
func (jcu JSONCheckUint64) IsDefault() bool
IsDefault 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 JSONBytesFromString
Identifier JSONBytesFromString
Topics []JSONBytesFromString
Data JSONBytesFromString
}
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 ¶
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
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
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 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 "DHARITRI_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.