Documentation
¶
Index ¶
- Variables
- func CheckAtreeStorageHealth(tb testing.TB, storage atree.SlabStorage, expectedRootSlabIDs []atree.SlabID)
- func DeploymentTransaction(name string, contract []byte) []byte
- func MultipleIdentifierLocationResolver(identifiers []ast.Identifier, location common.Location) (result []sema.ResolvedLocation, err error)
- func NewLocationGenerator[T ~[32]byte]() func() T
- func NewScriptLocationGenerator() func() common.ScriptLocation
- func NewSingleIdentifierLocationResolver(t testing.TB) sema.LocationHandlerFunc
- func NewTransactionLocationGenerator() func() common.TransactionLocation
- func RemovalTransaction(name string) []byte
- func TestStorageKey(owner, key string) string
- func UpdateTransaction(name string, contract []byte) []byte
- type LedgerOnRead
- type LedgerOnWrite
- type OwnerKeyValue
- type TestLedger
- func (s TestLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)
- func (s TestLedger) Dump()
- func (s TestLedger) ForEach(f func(owner, key, value []byte) error) error
- func (s TestLedger) GetValue(owner, key []byte) (value []byte, err error)
- func (s TestLedger) SetValue(owner, key, value []byte) (err error)
- func (s TestLedger) ValueExists(owner, key []byte) (exists bool, err error)
- type TestRuntime
- type TestRuntimeInterface
- func (i *TestRuntimeInterface) AccountKeysCount(address runtime.Address) (uint32, error)
- func (i *TestRuntimeInterface) AddAccountKey(address runtime.Address, publicKey *stdlib.PublicKey, ...) (*stdlib.AccountKey, error)
- func (i *TestRuntimeInterface) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error
- func (i *TestRuntimeInterface) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)
- func (i *TestRuntimeInterface) BLSAggregatePublicKeys(keys []*stdlib.PublicKey) (*stdlib.PublicKey, error)
- func (i *TestRuntimeInterface) BLSAggregateSignatures(sigs [][]byte) ([]byte, error)
- func (i *TestRuntimeInterface) BLSVerifyPOP(key *stdlib.PublicKey, s []byte) (bool, error)
- func (i *TestRuntimeInterface) CreateAccount(payer runtime.Address) (address runtime.Address, err error)
- func (i *TestRuntimeInterface) DecodeArgument(b []byte, t cadence.Type) (cadence.Value, error)
- func (i *TestRuntimeInterface) EmitEvent(event cadence.Event) error
- func (i *TestRuntimeInterface) GenerateAccountID(address common.Address) (uint64, error)
- func (i *TestRuntimeInterface) GenerateUUID() (uint64, error)
- func (i *TestRuntimeInterface) GetAccountAvailableBalance(address runtime.Address) (uint64, error)
- func (i *TestRuntimeInterface) GetAccountBalance(address runtime.Address) (uint64, error)
- func (i *TestRuntimeInterface) GetAccountContractCode(location common.AddressLocation) (code []byte, err error)
- func (i *TestRuntimeInterface) GetAccountContractNames(address runtime.Address) ([]string, error)
- func (i *TestRuntimeInterface) GetAccountKey(address runtime.Address, index uint32) (*stdlib.AccountKey, error)
- func (i *TestRuntimeInterface) GetBlockAtHeight(height uint64) (block stdlib.Block, exists bool, err error)
- func (i *TestRuntimeInterface) GetCode(location runtime.Location) ([]byte, error)
- func (i *TestRuntimeInterface) GetCurrentBlockHeight() (uint64, error)
- func (i *TestRuntimeInterface) GetOrLoadProgram(location runtime.Location, load func() (*runtime.Program, error)) (program *runtime.Program, err error)
- func (i *TestRuntimeInterface) GetSigningAccounts() ([]runtime.Address, error)
- func (i *TestRuntimeInterface) GetStorageCapacity(address runtime.Address) (uint64, error)
- func (i *TestRuntimeInterface) GetStorageUsed(address runtime.Address) (uint64, error)
- func (i *TestRuntimeInterface) GetValue(owner, key []byte) (value []byte, err error)
- func (i *TestRuntimeInterface) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
- func (i *TestRuntimeInterface) ImplementationDebugLog(message string) error
- func (i *TestRuntimeInterface) InvalidateUpdatedPrograms()
- func (i *TestRuntimeInterface) MinimumRequiredVersion() (string, error)
- func (i *TestRuntimeInterface) ProgramChecked(location runtime.Location, duration time.Duration)
- func (i *TestRuntimeInterface) ProgramInterpreted(location runtime.Location, duration time.Duration)
- func (i *TestRuntimeInterface) ProgramLog(message string) error
- func (i *TestRuntimeInterface) ProgramParsed(location runtime.Location, duration time.Duration)
- func (i *TestRuntimeInterface) ReadRandom(buffer []byte) error
- func (i *TestRuntimeInterface) RecordTrace(operation string, duration time.Duration, attrs []attribute.KeyValue)
- func (i *TestRuntimeInterface) RecoverProgram(program *ast.Program, location common.Location) ([]byte, error)
- func (i *TestRuntimeInterface) RemoveAccountContractCode(location common.AddressLocation) (err error)
- func (i *TestRuntimeInterface) ResolveLocation(identifiers []runtime.Identifier, location runtime.Location) ([]runtime.ResolvedLocation, error)
- func (i *TestRuntimeInterface) ResourceOwnerChanged(interpreter *interpreter.Interpreter, resource *interpreter.CompositeValue, ...)
- func (i *TestRuntimeInterface) RevokeAccountKey(address runtime.Address, index uint32) (*stdlib.AccountKey, error)
- func (i *TestRuntimeInterface) RevokeEncodedAccountKey(address runtime.Address, index int) ([]byte, error)
- func (i *TestRuntimeInterface) SetCadenceValue(owner common.Address, key string, value cadence.Value) (err error)
- func (i *TestRuntimeInterface) SetValue(owner, key, value []byte) (err error)
- func (i *TestRuntimeInterface) UpdateAccountContractCode(location common.AddressLocation, code []byte) (err error)
- func (i *TestRuntimeInterface) ValidateAccountCapabilitiesGet(context interpreter.AccountCapabilityGetValidationContext, ...) (bool, error)
- func (i *TestRuntimeInterface) ValidateAccountCapabilitiesPublish(context interpreter.AccountCapabilityPublishValidationContext, ...) (bool, error)
- func (i *TestRuntimeInterface) ValidatePublicKey(key *stdlib.PublicKey) error
- func (i *TestRuntimeInterface) ValueExists(owner, key []byte) (exists bool, err error)
- func (i *TestRuntimeInterface) VerifySignature(signature []byte, tag string, signedData []byte, publicKey []byte, ...) (bool, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTestInterpreterConfig = runtime.Config{ AtreeValidationEnabled: true, }
View Source
var LedgerOnWriteCounter = func(counter *int) LedgerOnWrite { return func(_, _, _ []byte) { (*counter)++ } }
View Source
var LedgerOnWriteEntries = func(entries *[]OwnerKeyValue) LedgerOnWrite { return func(owner, key, value []byte) { *entries = append( *entries, OwnerKeyValue{Owner: owner, Key: key, Value: value}) } }
Functions ¶
func CheckAtreeStorageHealth ¶ added in v1.3.0
func DeploymentTransaction ¶
func MultipleIdentifierLocationResolver ¶
func MultipleIdentifierLocationResolver( identifiers []ast.Identifier, location common.Location, ) ( result []sema.ResolvedLocation, err error, )
func NewLocationGenerator ¶
func NewLocationGenerator[T ~[32]byte]() func() T
func NewScriptLocationGenerator ¶
func NewScriptLocationGenerator() func() common.ScriptLocation
func NewSingleIdentifierLocationResolver ¶
func NewSingleIdentifierLocationResolver(t testing.TB) sema.LocationHandlerFunc
func NewTransactionLocationGenerator ¶
func NewTransactionLocationGenerator() func() common.TransactionLocation
func RemovalTransaction ¶
func TestStorageKey ¶
func UpdateTransaction ¶
Types ¶
type LedgerOnRead ¶ added in v1.3.0
type LedgerOnRead func(owner, key, value []byte)
type LedgerOnWrite ¶ added in v1.3.0
type LedgerOnWrite func(owner, key, value []byte)
type OwnerKeyValue ¶ added in v1.3.0
type OwnerKeyValue struct {
Owner, Key, Value []byte
}
type TestLedger ¶
type TestLedger struct {
StoredValues map[string][]byte
StorageIndices map[string]uint64
OnValueExists func(owner, key []byte) (exists bool, err error)
OnGetValue func(owner, key []byte) (value []byte, err error)
OnSetValue func(owner, key, value []byte) (err error)
OnAllocateSlabIndex func(owner []byte) (atree.SlabIndex, error)
}
func NewTestLedger ¶
func NewTestLedger( onRead LedgerOnRead, onWrite LedgerOnWrite, ) TestLedger
func NewTestLedgerWithData ¶
func (TestLedger) AllocateSlabIndex ¶
func (s TestLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)
func (TestLedger) Dump ¶
func (s TestLedger) Dump()
func (TestLedger) ForEach ¶
func (s TestLedger) ForEach(f func(owner, key, value []byte) error) error
func (TestLedger) GetValue ¶
func (s TestLedger) GetValue(owner, key []byte) (value []byte, err error)
func (TestLedger) SetValue ¶
func (s TestLedger) SetValue(owner, key, value []byte) (err error)
func (TestLedger) ValueExists ¶
func (s TestLedger) ValueExists(owner, key []byte) (exists bool, err error)
type TestRuntime ¶ added in v1.7.0
func NewTestRuntime ¶ added in v1.7.0
func NewTestRuntime() TestRuntime
func NewTestRuntimeWithConfig ¶ added in v1.7.0
func NewTestRuntimeWithConfig(config runtime.Config) TestRuntime
func (TestRuntime) ExecuteScript ¶ added in v1.7.0
func (TestRuntime) ExecuteTransaction ¶ added in v1.7.0
type TestRuntimeInterface ¶
type TestRuntimeInterface struct {
Storage TestLedger
OnResolveLocation sema.LocationHandlerFunc
OnGetCode func(_ runtime.Location) ([]byte, error)
OnGetOrLoadProgram func(
location runtime.Location,
load func() (*runtime.Program, error),
) (*runtime.Program, error)
OnCreateAccount func(payer runtime.Address) (address runtime.Address, err error)
OnAddEncodedAccountKey func(address runtime.Address, publicKey []byte) error
OnRemoveEncodedAccountKey func(address runtime.Address, index int) (publicKey []byte, err error)
OnAddAccountKey func(
address runtime.Address,
publicKey *stdlib.PublicKey,
hashAlgo runtime.HashAlgorithm,
weight int,
) (*stdlib.AccountKey, error)
OnGetAccountKey func(address runtime.Address, index uint32) (*stdlib.AccountKey, error)
OnRemoveAccountKey func(address runtime.Address, index uint32) (*stdlib.AccountKey, error)
OnAccountKeysCount func(address runtime.Address) (uint32, error)
OnUpdateAccountContractCode func(location common.AddressLocation, code []byte) error
OnGetAccountContractCode func(location common.AddressLocation) (code []byte, err error)
OnRemoveAccountContractCode func(location common.AddressLocation) (err error)
OnGetSigningAccounts func() ([]runtime.Address, error)
OnProgramLog func(string)
OnEmitEvent func(cadence.Event) error
OnResourceOwnerChanged func(
interpreter *interpreter.Interpreter,
resource *interpreter.CompositeValue,
oldAddress common.Address,
newAddress common.Address,
)
OnGenerateUUID func() (uint64, error)
OnDecodeArgument func(b []byte, t cadence.Type) (cadence.Value, error)
OnProgramParsed func(location runtime.Location, duration time.Duration)
OnProgramChecked func(location runtime.Location, duration time.Duration)
OnProgramInterpreted func(location runtime.Location, duration time.Duration)
OnReadRandom func([]byte) error
OnVerifySignature func(
signature []byte,
tag string,
signedData []byte,
publicKey []byte,
signatureAlgorithm runtime.SignatureAlgorithm,
hashAlgorithm runtime.HashAlgorithm,
) (bool, error)
OnHash func(
data []byte,
tag string,
hashAlgorithm runtime.HashAlgorithm,
) ([]byte, error)
OnSetCadenceValue func(owner runtime.Address, key string, value cadence.Value) (err error)
OnGetAccountBalance func(_ runtime.Address) (uint64, error)
OnGetAccountAvailableBalance func(_ runtime.Address) (uint64, error)
OnGetStorageUsed func(_ runtime.Address) (uint64, error)
OnGetStorageCapacity func(_ runtime.Address) (uint64, error)
Programs map[runtime.Location]*runtime.Program
OnImplementationDebugLog func(message string) error
OnValidatePublicKey func(publicKey *stdlib.PublicKey) error
OnBLSVerifyPOP func(pk *stdlib.PublicKey, s []byte) (bool, error)
OnBLSAggregateSignatures func(sigs [][]byte) ([]byte, error)
OnBLSAggregatePublicKeys func(keys []*stdlib.PublicKey) (*stdlib.PublicKey, error)
OnGetAccountContractNames func(address runtime.Address) ([]string, error)
OnRecordTrace func(
operation string,
duration time.Duration,
attrs []attribute.KeyValue,
)
OnGenerateAccountID func(address common.Address) (uint64, error)
OnRecoverProgram func(program *ast.Program, location common.Location) ([]byte, error)
OnValidateAccountCapabilitiesGet func(
context interpreter.AccountCapabilityGetValidationContext,
address interpreter.AddressValue,
path interpreter.PathValue,
wantedBorrowType *sema.ReferenceType,
capabilityBorrowType *sema.ReferenceType,
) (bool, error)
OnValidateAccountCapabilitiesPublish func(
context interpreter.AccountCapabilityPublishValidationContext,
address interpreter.AddressValue,
path interpreter.PathValue,
capabilityBorrowType *interpreter.ReferenceStaticType,
) (bool, error)
OnMinimumRequiredVersion func() (string, error)
// contains filtered or unexported fields
}
func (*TestRuntimeInterface) AccountKeysCount ¶
func (i *TestRuntimeInterface) AccountKeysCount(address runtime.Address) (uint32, error)
func (*TestRuntimeInterface) AddAccountKey ¶
func (i *TestRuntimeInterface) AddAccountKey( address runtime.Address, publicKey *stdlib.PublicKey, hashAlgo runtime.HashAlgorithm, weight int, ) (*stdlib.AccountKey, error)
func (*TestRuntimeInterface) AddEncodedAccountKey ¶
func (i *TestRuntimeInterface) AddEncodedAccountKey(address runtime.Address, publicKey []byte) error
func (*TestRuntimeInterface) AllocateSlabIndex ¶
func (i *TestRuntimeInterface) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error)
func (*TestRuntimeInterface) BLSAggregatePublicKeys ¶
func (*TestRuntimeInterface) BLSAggregateSignatures ¶
func (i *TestRuntimeInterface) BLSAggregateSignatures(sigs [][]byte) ([]byte, error)
func (*TestRuntimeInterface) BLSVerifyPOP ¶
func (*TestRuntimeInterface) CreateAccount ¶
func (*TestRuntimeInterface) DecodeArgument ¶
func (*TestRuntimeInterface) EmitEvent ¶
func (i *TestRuntimeInterface) EmitEvent(event cadence.Event) error
func (*TestRuntimeInterface) GenerateAccountID ¶
func (i *TestRuntimeInterface) GenerateAccountID(address common.Address) (uint64, error)
func (*TestRuntimeInterface) GenerateUUID ¶
func (i *TestRuntimeInterface) GenerateUUID() (uint64, error)
func (*TestRuntimeInterface) GetAccountAvailableBalance ¶
func (i *TestRuntimeInterface) GetAccountAvailableBalance(address runtime.Address) (uint64, error)
func (*TestRuntimeInterface) GetAccountBalance ¶
func (i *TestRuntimeInterface) GetAccountBalance(address runtime.Address) (uint64, error)
func (*TestRuntimeInterface) GetAccountContractCode ¶
func (i *TestRuntimeInterface) GetAccountContractCode(location common.AddressLocation) (code []byte, err error)
func (*TestRuntimeInterface) GetAccountContractNames ¶
func (i *TestRuntimeInterface) GetAccountContractNames(address runtime.Address) ([]string, error)
func (*TestRuntimeInterface) GetAccountKey ¶
func (i *TestRuntimeInterface) GetAccountKey(address runtime.Address, index uint32) (*stdlib.AccountKey, error)
func (*TestRuntimeInterface) GetBlockAtHeight ¶
func (*TestRuntimeInterface) GetCode ¶
func (i *TestRuntimeInterface) GetCode(location runtime.Location) ([]byte, error)
func (*TestRuntimeInterface) GetCurrentBlockHeight ¶
func (i *TestRuntimeInterface) GetCurrentBlockHeight() (uint64, error)
func (*TestRuntimeInterface) GetOrLoadProgram ¶
func (*TestRuntimeInterface) GetSigningAccounts ¶
func (i *TestRuntimeInterface) GetSigningAccounts() ([]runtime.Address, error)
func (*TestRuntimeInterface) GetStorageCapacity ¶
func (i *TestRuntimeInterface) GetStorageCapacity(address runtime.Address) (uint64, error)
func (*TestRuntimeInterface) GetStorageUsed ¶
func (i *TestRuntimeInterface) GetStorageUsed(address runtime.Address) (uint64, error)
func (*TestRuntimeInterface) GetValue ¶
func (i *TestRuntimeInterface) GetValue(owner, key []byte) (value []byte, err error)
func (*TestRuntimeInterface) Hash ¶
func (i *TestRuntimeInterface) Hash(data []byte, tag string, hashAlgorithm runtime.HashAlgorithm) ([]byte, error)
func (*TestRuntimeInterface) ImplementationDebugLog ¶
func (i *TestRuntimeInterface) ImplementationDebugLog(message string) error
func (*TestRuntimeInterface) InvalidateUpdatedPrograms ¶
func (i *TestRuntimeInterface) InvalidateUpdatedPrograms()
func (*TestRuntimeInterface) MinimumRequiredVersion ¶
func (i *TestRuntimeInterface) MinimumRequiredVersion() (string, error)
func (*TestRuntimeInterface) ProgramChecked ¶
func (i *TestRuntimeInterface) ProgramChecked(location runtime.Location, duration time.Duration)
func (*TestRuntimeInterface) ProgramInterpreted ¶
func (i *TestRuntimeInterface) ProgramInterpreted(location runtime.Location, duration time.Duration)
func (*TestRuntimeInterface) ProgramLog ¶
func (i *TestRuntimeInterface) ProgramLog(message string) error
func (*TestRuntimeInterface) ProgramParsed ¶
func (i *TestRuntimeInterface) ProgramParsed(location runtime.Location, duration time.Duration)
func (*TestRuntimeInterface) ReadRandom ¶
func (i *TestRuntimeInterface) ReadRandom(buffer []byte) error
func (*TestRuntimeInterface) RecordTrace ¶
func (*TestRuntimeInterface) RecoverProgram ¶
func (*TestRuntimeInterface) RemoveAccountContractCode ¶
func (i *TestRuntimeInterface) RemoveAccountContractCode(location common.AddressLocation) (err error)
func (*TestRuntimeInterface) ResolveLocation ¶
func (i *TestRuntimeInterface) ResolveLocation( identifiers []runtime.Identifier, location runtime.Location, ) ([]runtime.ResolvedLocation, error)
func (*TestRuntimeInterface) ResourceOwnerChanged ¶
func (i *TestRuntimeInterface) ResourceOwnerChanged( interpreter *interpreter.Interpreter, resource *interpreter.CompositeValue, oldOwner common.Address, newOwner common.Address, )
func (*TestRuntimeInterface) RevokeAccountKey ¶
func (i *TestRuntimeInterface) RevokeAccountKey(address runtime.Address, index uint32) (*stdlib.AccountKey, error)
func (*TestRuntimeInterface) RevokeEncodedAccountKey ¶
func (*TestRuntimeInterface) SetCadenceValue ¶
func (*TestRuntimeInterface) SetValue ¶
func (i *TestRuntimeInterface) SetValue(owner, key, value []byte) (err error)
func (*TestRuntimeInterface) UpdateAccountContractCode ¶
func (i *TestRuntimeInterface) UpdateAccountContractCode(location common.AddressLocation, code []byte) (err error)
func (*TestRuntimeInterface) ValidateAccountCapabilitiesGet ¶
func (i *TestRuntimeInterface) ValidateAccountCapabilitiesGet( context interpreter.AccountCapabilityGetValidationContext, address interpreter.AddressValue, path interpreter.PathValue, wantedBorrowType *sema.ReferenceType, capabilityBorrowType *sema.ReferenceType, ) (bool, error)
func (*TestRuntimeInterface) ValidateAccountCapabilitiesPublish ¶
func (i *TestRuntimeInterface) ValidateAccountCapabilitiesPublish( context interpreter.AccountCapabilityPublishValidationContext, address interpreter.AddressValue, path interpreter.PathValue, capabilityBorrowType *interpreter.ReferenceStaticType, ) (bool, error)
func (*TestRuntimeInterface) ValidatePublicKey ¶
func (i *TestRuntimeInterface) ValidatePublicKey(key *stdlib.PublicKey) error
func (*TestRuntimeInterface) ValueExists ¶
func (i *TestRuntimeInterface) ValueExists(owner, key []byte) (exists bool, err error)
func (*TestRuntimeInterface) VerifySignature ¶
func (i *TestRuntimeInterface) VerifySignature( signature []byte, tag string, signedData []byte, publicKey []byte, signatureAlgorithm runtime.SignatureAlgorithm, hashAlgorithm runtime.HashAlgorithm, ) (bool, error)
Click to show internal directories.
Click to hide internal directories.