testhelpers

package
v0.0.3-rc-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SystemIndex sc.U8 = iota
	TimestampIndex
	SessionIndex
	ConsensusAuthoringIndex
	ConsensusFinalizationIndex
	BalancesIndex
	TxPaymentsIndex
	SudoIndex
	TestableIndex = 255
)
View Source
const ParachainWasm = "../../../build/parachain.wasm"
View Source
const RuntimeWasm = "../../../build/runtime-benchmarks.wasm"
View Source
const RuntimeWasmSpecVersion101 = "../../../testdata/runtimes/gosemble_poa_template_spec_version_101.wasm"

Variables

View Source
var (
	KeySystemHash, _             = common.Twox128Hash([]byte("System"))
	KeyAccountHash, _            = common.Twox128Hash([]byte("Account"))
	KeyAllExtrinsicsLenHash, _   = common.Twox128Hash([]byte("AllExtrinsicsLen"))
	KeyAuraHash, _               = common.Twox128Hash([]byte("Aura"))
	KeyAuthoritiesHash, _        = common.Twox128Hash([]byte("Authorities"))
	KeyAuthorizedUpgradeHash, _  = common.Twox128Hash([]byte("AuthorizedUpgrade"))
	KeyBlockHash, _              = common.Twox128Hash([]byte("BlockHash"))
	KeyCurrentSlotHash, _        = common.Twox128Hash([]byte("CurrentSlot"))
	KeyDigestHash, _             = common.Twox128Hash([]byte("Digest"))
	KeyEventsHash, _             = common.Twox128Hash([]byte("Events"))
	KeyEventCountHash, _         = common.Twox128Hash([]byte("EventCount"))
	KeyExecutionPhaseHash, _     = common.Twox128Hash([]byte("ExecutionPhase"))
	KeyExtrinsicCountHash, _     = common.Twox128Hash([]byte("ExtrinsicCount"))
	KeyExtrinsicIndex            = []byte(":extrinsic_index")
	KeyHeapPages                 = []byte(":heappages")
	KeyExtrinsicDataHash, _      = common.Twox128Hash([]byte("ExtrinsicData"))
	KeyLastRuntimeHash, _        = common.Twox128Hash([]byte("LastRuntimeUpgrade"))
	KeyNumberHash, _             = common.Twox128Hash([]byte("Number"))
	KeyParentHash, _             = common.Twox128Hash([]byte("ParentHash"))
	KeyTimestampHash, _          = common.Twox128Hash([]byte("Timestamp"))
	KeyTimestampNowHash, _       = common.Twox128Hash([]byte("Now"))
	KeyTimestampDidUpdateHash, _ = common.Twox128Hash([]byte("DidUpdate"))
	KeyBlockWeightHash, _        = common.Twox128Hash([]byte("BlockWeight"))
	KeyBalancesHash, _           = common.Twox128Hash([]byte("Balances"))
	KeyTotalIssuanceHash, _      = common.Twox128Hash([]byte("TotalIssuance"))
	KeyTransactionPaymentHash, _ = common.Twox128Hash([]byte("TransactionPayment"))
	KeyNextFeeMultiplierHash, _  = common.Twox128Hash([]byte("NextFeeMultiplier"))
)

keys from all the modules

View Source
var (
	KeyBabeHash, _                     = common.Twox128Hash([]byte("Babe"))
	KeyEpochConfigHash, _              = common.Twox128Hash([]byte("EpochConfig"))
	KeyEpochIndexHash, _               = common.Twox128Hash([]byte("EpochIndex"))
	KeyGenesisSlotHash, _              = common.Twox128Hash([]byte("GenesisSlot"))
	KeyNextRandomnessHash, _           = common.Twox128Hash([]byte("NextRandomness"))
	KeyNextAuthoritiesHash, _          = common.Twox128Hash([]byte("NextAuthorities"))
	KeyNextEpochConfigHash, _          = common.Twox128Hash([]byte("NextEpochConfig"))
	KeyPendingEpochConfigChangeHash, _ = common.Twox128Hash([]byte("PendingEpochConfigChange"))
	KeyRandomnessHash, _               = common.Twox128Hash([]byte("Randomness"))
)

Babe storage keys

View Source
var (
	KeyGrandpaHash, _     = common.Twox128Hash([]byte("Grandpa"))
	KeyGrandpaAuthorities = []byte(":grandpa_authorities")
	KeyStalledHash, _     = common.Twox128Hash([]byte("Stalled"))
)

Grandpa storage keys

View Source
var (
	KeySessionHash, _ = common.Twox128Hash([]byte("Session"))
	KeyNextKeys, _    = common.Twox128Hash([]byte("NextKeys"))
	KeyKeyOwner, _    = common.Twox128Hash([]byte("KeyOwner"))
)

Session storage keys

View Source
var (
	KeySudoHash, _ = common.Twox128Hash([]byte("Sudo"))
	KeyKeyHash, _  = common.Twox128Hash([]byte("Key"))
)

Sudo storage keys

View Source
var (
	ParentHash     = common.MustHexToHash("0x0f6d3477739f8a65886135f58c83ff7c2d4a8300a010dfc8b4c5d65ba37920bb")
	StateRoot      = common.MustHexToHash("0x14cf3fe7f5666e63d0981d80c69b6b8bebbb7c94e3eeacaeca27ae6cfa328631")
	ExtrinsicsRoot = common.MustHexToHash("0x105165e71964828f2b8d1fd89904602cfb9b8930951d87eb249aa2d7c4b51ee7")
	BlockNumber    = uint64(1)
	SealDigest     = gossamertypes.SealDigest{
		ConsensusEngineID: gossamertypes.BabeEngineID,

		Data: []byte{158, 127, 40, 221, 220, 242, 124, 30, 107, 50, 141, 86, 148, 195, 104, 213, 178, 236, 93, 190,
			14, 65, 42, 225, 201, 143, 136, 213, 59, 228, 216, 80, 47, 172, 87, 31, 63, 25, 201, 202, 175, 40, 26,
			103, 51, 25, 36, 30, 12, 80, 149, 166, 131, 173, 52, 49, 98, 4, 8, 138, 54, 164, 189, 134},
	}
)
View Source
var (
	TransactionValidityResultCallErr, _                = primitives.NewTransactionValidityResult(invalidTransactionCallErr.(primitives.TransactionValidityError))
	TransactionValidityResultStaleErr, _               = primitives.NewTransactionValidityResult(invalidTransactionStaleErr.(primitives.TransactionValidityError))
	TransactionValidityResultFutureErr, _              = primitives.NewTransactionValidityResult(invalidTransactionFutureErr.(primitives.TransactionValidityError))
	TransactionValidityResultExhaustsResourcesErr, _   = primitives.NewTransactionValidityResult(invalidTransactionExhaustsResourcesErr.(primitives.TransactionValidityError))
	TransactionValidityResultNoUnsignedValidatorErr, _ = primitives.NewTransactionValidityResult(unknownTransactionNoUnsignedValidator.(primitives.TransactionValidityError))
	TransactionValidityResultMandatoryValidationErr, _ = primitives.NewTransactionValidityResult(invalidTransactionMandatoryValidation.(primitives.TransactionValidityError))

	ApplyExtrinsicResultOutcome, _                    = primitives.NewApplyExtrinsicResult(dispatchOutcome)
	ApplyExtrinsicResultExhaustsResourcesErr, _       = primitives.NewApplyExtrinsicResult(invalidTransactionExhaustsResourcesErr.(primitives.TransactionValidityError))
	ApplyExtrinsicResultBadOriginErr, _               = primitives.NewApplyExtrinsicResult(dispatchOutcomeBadOriginErr)
	ApplyExtrinsicResultBadProofErr, _                = primitives.NewApplyExtrinsicResult(invalidTransactionBadProofErr.(primitives.TransactionValidityError))
	ApplyExtrinsicResultTokenErrorFundsUnavailable, _ = primitives.NewApplyExtrinsicResult(dispatchOutcomeTokenErrorFundsUnavailable)
	ApplyExtrinsicResultExistentialDepositErr, _      = primitives.NewApplyExtrinsicResult(dispatchOutcomeTokenErrorBelowMinimum)
	ApplyExtrinsicResultSessionNoKeysErr, _           = primitives.NewApplyExtrinsicResult(dispatchOutcomeSessionNoKeysErr)
	ApplyExtrinsicResultSudoRequireSudoErr, _         = primitives.NewApplyExtrinsicResult(dispatchOutcomeSudoRequireSudoErr)
)
View Source
var (
	GenesisConfigJson = []byte(
		"{\"system\":{\"code\":\"\"},\"babe\":{\"authorities\":[\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\"],\"epochConfig\":{\"c\":[1,4],\"allowed_slots\":\"PrimarySlots\"}},\"grandpa\":{\"authorities\":[]},\"balances\":{\"balances\":[[\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\",1000000000000000000],[\"5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty\",1000000000000000000],[\"5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y\",1000000000000000000],[\"5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy\",1000000000000000000],[\"5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw\",1000000000000000000],[\"5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL\",1000000000000000000],[\"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY\",1000000000000000000],[\"5HpG9w8EBLe5XCrbczpwq5TSXvedjrBGCwqxK1iQ7qUsSWFc\",1000000000000000000],[\"5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT\",1000000000000000000],[\"5HKPmK9GYtE1PSLsS1qiYU9xQ9Si1NcEhdeCq9sw5bqu4ns8\",1000000000000000000],[ \"5FCfAonRZgTFrTd9HREEyeJjDpT397KMzizE6T3DvebLFE7n\",1000000000000000000],[\"5CRmqmsiNFExV6VbdmPJViVxrWmkaXXvBrSX8oqBT8R9vmWk\",1000000000000000000]]},\"session\": {\"keys\": [[\"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY\",\"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY\",{\"grandpa\":\"5FA9nQDVg267DEd8m1ZypXLBnvN7SFxYwV7ndqSYGiN9TTpu\",\"babe\":\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\"}]]},\"transactionPayment\":{\"multiplier\":\"1\"},\"sudo\":{\"key\":\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\"}}",
	)
)

Functions

func AssertEmittedBalancesEvent

func AssertEmittedBalancesEvent(t assert.TestingT, event sc.U8, buffer *bytes.Buffer)

func AssertEmittedSudoEvent

func AssertEmittedSudoEvent(t assert.TestingT, event sc.U8, buffer *bytes.Buffer)

func AssertEmittedSystemEvent

func AssertEmittedSystemEvent(t assert.TestingT, event sc.U8, buffer *bytes.Buffer)

func AssertEmittedTransactionPaymentEvent

func AssertEmittedTransactionPaymentEvent(t assert.TestingT, event sc.U8, buffer *bytes.Buffer)

func AssertSessionEmptyStorage

func AssertSessionEmptyStorage(t assert.TestingT, storage *runtime.Storage, account []byte, key []byte, keyTypeId [4]byte)

func AssertSessionKeyOwner

func AssertSessionKeyOwner(t assert.TestingT, storage *runtime.Storage, key primitives.SessionKey, expectedOwner []byte)

func AssertSessionNextKeys

func AssertSessionNextKeys(t assert.TestingT, storage *runtime.Storage, account []byte, expectedKey []byte)

func AssertStorageDigestItem

func AssertStorageDigestItem(t *testing.T, storage *runtime.Storage, digestItem sc.U8)

func AssertStorageSystemEventCount

func AssertStorageSystemEventCount(t assert.TestingT, storage *runtime.Storage, expected uint32)

func ExtractConsensusDigests

func ExtractConsensusDigests(t *testing.T, sequence sc.Sequence[types.DigestItem], consensusEngineId []byte) sc.Sequence[types.DigestItem]

func GenesisBuild

func GenesisBuild(t *testing.T, instance *wazero_runtime.Instance, genesisConfig []byte)

func GetBabeSlot

func GetBabeSlot(t *testing.T, instance *wazero_runtime.Instance, time uint64) uint64

func GetQueryInfo

func GetQueryInfo(t *testing.T, instance *wazero_runtime.Instance, extrinsic []byte) primitives.RuntimeDispatchInfo

func InitializeBlock

func InitializeBlock(t *testing.T, instance *wazero_runtime.Instance, parentHash, stateRoot, extrinsicsRoot common.Hash, blockNumber uint64)

func NewBabeDigest

func NewBabeDigest(t *testing.T, slot uint64) gossamertypes.Digest

func NewParachainRuntimeInstance

func NewParachainRuntimeInstance(t *testing.T) (*wazero_runtime.Instance, *runtime.Storage)

func NewParachainRuntimeInstanceWithTrie

func NewParachainRuntimeInstanceWithTrie(t *testing.T, trie *inmemory.InMemoryTrie) (*wazero_runtime.Instance, *runtime.Storage)

func NewRuntimeInstance

func NewRuntimeInstance(t *testing.T) (*wazero_runtime.Instance, *runtime.Storage)

func NewRuntimeInstanceFromCode

func NewRuntimeInstanceFromCode(t *testing.T, parentRuntime *wazero_runtime.Instance, code []byte) (*wazero_runtime.Instance, *runtime.Storage)

func RuntimeMetadata

func RuntimeMetadata(t assert.TestingT, instance *wazero_runtime.Instance) *ctypes.Metadata

func SetSessionKeysStorage

func SetSessionKeysStorage(t assert.TestingT, storage *runtime.Storage, account []byte, key []byte, keyTypeId [4]byte)

func SetStorageAccountInfo

func SetStorageAccountInfo(t *testing.T, storage *runtime.Storage, account []byte, freeBalance *big.Int, nonce uint32) (storageKey []byte, info gossamertypes.AccountInfo)

func SignExtrinsicSecp256k1

func SignExtrinsicSecp256k1(e *ctypes.Extrinsic, o ctypes.SignatureOptions, keyPair *secp256k1.Keypair) error

func TimestampExtrinsicBytes

func TimestampExtrinsicBytes(t assert.TestingT, metadata *ctypes.Metadata, time uint64) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL