Documentation
¶
Index ¶
- Variables
- 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) ...
- func NewTestInterpreter(tb testing.TB) *interpreter.Interpreter
- func NewTransactionLocationGenerator() func() common.TransactionLocation
- func NewUnmeteredInMemoryStorage() interpreter.Storage
- func TestStorageKey(owner, key string) string
- type TestInterpreterRuntime
- 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 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) ComputationUsed() (uint64, 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) GetInterpreterSharedState() *interpreter.SharedState
- func (i *TestRuntimeInterface) GetOrLoadProgram(location runtime.Location, load func() (*interpreter.Program, error)) (program *interpreter.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) InteractionUsed() (uint64, error)
- func (i *TestRuntimeInterface) InvalidateUpdatedPrograms()
- func (i *TestRuntimeInterface) MemoryUsed() (uint64, error)
- func (i *TestRuntimeInterface) MeterComputation(compKind common.ComputationKind, intensity uint) error
- func (i *TestRuntimeInterface) MeterMemory(usage common.MemoryUsage) 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, location runtime.Location, duration time.Duration, ...)
- 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) SetInterpreterSharedState(state *interpreter.SharedState)
- 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(inter *interpreter.Interpreter, locationRange interpreter.LocationRange, ...) (bool, error)
- func (i *TestRuntimeInterface) ValidateAccountCapabilitiesPublish(inter *interpreter.Interpreter, locationRange interpreter.LocationRange, ...) (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, AttachmentsEnabled: true, }
Functions ¶
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) func( identifiers []runtime.Identifier, location runtime.Location, ) ( []runtime.ResolvedLocation, error, )
func NewTestInterpreter ¶
func NewTestInterpreter(tb testing.TB) *interpreter.Interpreter
func NewTransactionLocationGenerator ¶
func NewTransactionLocationGenerator() func() common.TransactionLocation
func NewUnmeteredInMemoryStorage ¶
func NewUnmeteredInMemoryStorage() interpreter.Storage
func TestStorageKey ¶
Types ¶
type TestInterpreterRuntime ¶
func NewTestInterpreterRuntime ¶
func NewTestInterpreterRuntime() TestInterpreterRuntime
func NewTestInterpreterRuntimeWithAttachments ¶
func NewTestInterpreterRuntimeWithAttachments() TestInterpreterRuntime
func NewTestInterpreterRuntimeWithConfig ¶
func NewTestInterpreterRuntimeWithConfig(config runtime.Config) TestInterpreterRuntime
func (TestInterpreterRuntime) ExecuteScript ¶
func (TestInterpreterRuntime) ExecuteTransaction ¶
type TestLedger ¶
type TestLedger struct {
StoredValues map[string][]byte
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 func(owner, key, value []byte), onWrite func(owner, key, value []byte), ) 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 TestRuntimeInterface ¶
type TestRuntimeInterface struct {
Storage TestLedger
OnResolveLocation func(
identifiers []runtime.Identifier,
location runtime.Location,
) (
[]runtime.ResolvedLocation,
error,
)
OnGetCode func(_ runtime.Location) ([]byte, error)
OnGetAndSetProgram func(
location runtime.Location,
load func() (*interpreter.Program, error),
) (*interpreter.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)
OnMeterComputation func(compKind common.ComputationKind, intensity uint) 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]*interpreter.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,
location runtime.Location,
duration time.Duration,
attrs []attribute.KeyValue,
)
OnMeterMemory func(usage common.MemoryUsage) error
OnComputationUsed func() (uint64, error)
OnMemoryUsed func() (uint64, error)
OnInteractionUsed func() (uint64, error)
OnGenerateAccountID func(address common.Address) (uint64, error)
OnRecoverProgram func(program *ast.Program, location common.Location) ([]byte, error)
OnValidateAccountCapabilitiesGet func(
inter *interpreter.Interpreter,
locationRange interpreter.LocationRange,
address interpreter.AddressValue,
path interpreter.PathValue,
wantedBorrowType *sema.ReferenceType,
capabilityBorrowType *sema.ReferenceType,
) (bool, error)
OnValidateAccountCapabilitiesPublish func(
inter *interpreter.Interpreter,
locationRange interpreter.LocationRange,
address interpreter.AddressValue,
path interpreter.PathValue,
capabilityBorrowType *interpreter.ReferenceStaticType,
) (bool, 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) ComputationUsed ¶
func (i *TestRuntimeInterface) ComputationUsed() (uint64, error)
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) GetInterpreterSharedState ¶
func (i *TestRuntimeInterface) GetInterpreterSharedState() *interpreter.SharedState
func (*TestRuntimeInterface) GetOrLoadProgram ¶
func (i *TestRuntimeInterface) GetOrLoadProgram( location runtime.Location, load func() (*interpreter.Program, error), ) ( program *interpreter.Program, err error, )
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) InteractionUsed ¶
func (i *TestRuntimeInterface) InteractionUsed() (uint64, error)
func (*TestRuntimeInterface) InvalidateUpdatedPrograms ¶
func (i *TestRuntimeInterface) InvalidateUpdatedPrograms()
func (*TestRuntimeInterface) MemoryUsed ¶
func (i *TestRuntimeInterface) MemoryUsed() (uint64, error)
func (*TestRuntimeInterface) MeterComputation ¶
func (i *TestRuntimeInterface) MeterComputation(compKind common.ComputationKind, intensity uint) error
func (*TestRuntimeInterface) MeterMemory ¶
func (i *TestRuntimeInterface) MeterMemory(usage common.MemoryUsage) 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) SetInterpreterSharedState ¶
func (i *TestRuntimeInterface) SetInterpreterSharedState(state *interpreter.SharedState)
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( inter *interpreter.Interpreter, locationRange interpreter.LocationRange, address interpreter.AddressValue, path interpreter.PathValue, wantedBorrowType *sema.ReferenceType, capabilityBorrowType *sema.ReferenceType, ) (bool, error)
func (*TestRuntimeInterface) ValidateAccountCapabilitiesPublish ¶
func (i *TestRuntimeInterface) ValidateAccountCapabilitiesPublish( inter *interpreter.Interpreter, locationRange interpreter.LocationRange, 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.