pub struct TestRunner<E: NativeVmExtension, D: TestDatabase> {
    scrypto_vm: ScryptoVm<DefaultWasmEngine>,
    native_vm: NativeVm<E>,
    database: D,
    next_private_key: u64,
    next_transaction_nonce: u32,
    trace: bool,
    collected_events: Vec<Vec<(EventTypeIdentifier, Vec<u8>)>>,
    xrd_free_credits_used: bool,
    skip_receipt_check: bool,
}

Fields§

§scrypto_vm: ScryptoVm<DefaultWasmEngine>§native_vm: NativeVm<E>§database: D§next_private_key: u64§next_transaction_nonce: u32§trace: bool§collected_events: Vec<Vec<(EventTypeIdentifier, Vec<u8>)>>§xrd_free_credits_used: bool§skip_receipt_check: bool

Implementations§

source§

impl<E: NativeVmExtension> TestRunner<E, InMemorySubstateDatabase>

source§

impl<E: NativeVmExtension, D: TestDatabase> TestRunner<E, D>

source

pub fn faucet_component(&self) -> GlobalAddress

source

pub fn substate_db(&self) -> &D

source

pub fn substate_db_mut(&mut self) -> &mut D

source

pub fn collected_events(&self) -> &Vec<Vec<(EventTypeIdentifier, Vec<u8>)>>

source

pub fn next_private_key(&mut self) -> u64

source

pub fn next_transaction_nonce(&mut self) -> u32

source

pub fn new_key_pair(&mut self) -> (Secp256k1PublicKey, Secp256k1PrivateKey)

source

pub fn new_ed25519_key_pair(&mut self) -> (Ed25519PublicKey, Ed25519PrivateKey)

source

pub fn new_key_pair_with_auth_address( &mut self ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, NonFungibleGlobalId)

source

pub fn set_metadata( &mut self, address: GlobalAddress, key: &str, value: &str, proof: NonFungibleGlobalId )

source

pub fn get_metadata( &mut self, address: GlobalAddress, key: &str ) -> Option<MetadataValue>

source

pub fn inspect_component_royalty( &mut self, component_address: ComponentAddress ) -> Decimal

source

pub fn inspect_package_royalty( &mut self, package_address: PackageAddress ) -> Option<Decimal>

source

pub fn find_all_nodes(&self) -> IndexSet<NodeId>

source

pub fn find_all_components(&self) -> Vec<ComponentAddress>

source

pub fn find_all_packages(&self) -> Vec<PackageAddress>

source

pub fn find_all_resources(&self) -> Vec<ResourceAddress>

source

pub fn get_package_scrypto_schemas( &self, package_address: &PackageAddress ) -> IndexMap<SchemaHash, VersionedScryptoSchema>

source

pub fn get_package_blueprint_definitions( &self, package_address: &PackageAddress ) -> IndexMap<BlueprintVersionKey, BlueprintDefinition>

source

pub fn sum_descendant_balance_changes( &mut self, commit: &CommitResult, node_id: &NodeId ) -> IndexMap<ResourceAddress, BalanceChange>

source

pub fn get_component_vaults( &mut self, component_address: ComponentAddress, resource_address: ResourceAddress ) -> Vec<NodeId>

source

pub fn get_component_balance( &mut self, account_address: ComponentAddress, resource_address: ResourceAddress ) -> Decimal

source

pub fn inspect_vault_balance(&mut self, vault_id: NodeId) -> Option<Decimal>

source

pub fn inspect_fungible_vault(&mut self, vault_id: NodeId) -> Option<Decimal>

source

pub fn inspect_non_fungible_vault( &mut self, vault_id: NodeId ) -> Option<(Decimal, Box<dyn Iterator<Item = NonFungibleLocalId> + '_>)>

source

pub fn get_component_resources( &mut self, component_address: ComponentAddress ) -> HashMap<ResourceAddress, Decimal>

source

pub fn component_state<T: ScryptoDecode>( &self, component_address: ComponentAddress ) -> T

source

pub fn get_non_fungible_data<T: NonFungibleData>( &self, resource: ResourceAddress, non_fungible_id: NonFungibleLocalId ) -> T

source

pub fn get_kv_store_entry<K: ScryptoEncode, V: ScryptoEncode + ScryptoDecode>( &self, kv_store_id: Own, key: &K ) -> Option<V>

source

pub fn load_account_from_faucet(&mut self, account_address: ComponentAddress)

source

pub fn new_account_advanced( &mut self, owner_role: OwnerRole ) -> ComponentAddress

source

pub fn new_virtual_account( &mut self ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)

source

pub fn new_ed25519_virtual_account( &mut self ) -> (Ed25519PublicKey, Ed25519PrivateKey, ComponentAddress)

source

pub fn get_active_validator_info_by_key( &self, key: &Secp256k1PublicKey ) -> ValidatorSubstate

source

pub fn get_validator_info(&self, address: ComponentAddress) -> ValidatorSubstate

source

pub fn get_active_validator_with_key( &self, key: &Secp256k1PublicKey ) -> ComponentAddress

source

pub fn new_allocated_account( &mut self ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)

source

pub fn new_ed25519_virtual_account_with_access_controller( &mut self, n_out_of_4: u8 ) -> (Ed25519PublicKey, Ed25519PrivateKey, Ed25519PublicKey, Ed25519PrivateKey, Ed25519PublicKey, Ed25519PrivateKey, Ed25519PublicKey, Ed25519PrivateKey, ComponentAddress, ComponentAddress)

source

pub fn new_account( &mut self, is_virtual: bool ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)

source

pub fn new_identity<P: Into<PublicKey> + Clone + HasPublicKeyHash>( &mut self, pk: P, is_virtual: bool ) -> ComponentAddress

source

pub fn new_securified_identity( &mut self, account: ComponentAddress ) -> ComponentAddress

source

pub fn new_validator_with_pub_key( &mut self, pub_key: Secp256k1PublicKey, account: ComponentAddress ) -> ComponentAddress

source

pub fn new_staked_validator_with_pub_key( &mut self, pub_key: Secp256k1PublicKey, account: ComponentAddress ) -> ComponentAddress

source

pub fn publish_native_package( &mut self, native_package_code_id: u64, definition: PackageDefinition ) -> PackageAddress

source

pub fn publish_package_at_address<P: Into<PackagePublishingSource>>( &mut self, source: P, address: PackageAddress )

source

pub fn publish_package<P: Into<PackagePublishingSource>>( &mut self, source: P, metadata: BTreeMap<String, MetadataValue>, owner_role: OwnerRole ) -> PackageAddress

source

pub fn try_publish_package<P: Into<PackagePublishingSource>>( &mut self, source: P ) -> TransactionReceipt

source

pub fn publish_package_simple<P: Into<PackagePublishingSource>>( &mut self, source: P ) -> PackageAddress

source

pub fn publish_package_with_owner<P: Into<PackagePublishingSource>>( &mut self, source: P, owner_badge: NonFungibleGlobalId ) -> PackageAddress

source

pub fn compile<P: AsRef<Path>>( &mut self, package_dir: P ) -> (Vec<u8>, PackageDefinition)

source

pub fn compile_and_publish<P: AsRef<Path>>( &mut self, package_dir: P ) -> PackageAddress

source

pub fn compile_and_publish_at_address<P: AsRef<Path>>( &mut self, package_dir: P, address: PackageAddress )

source

pub fn publish_retain_blueprints<P: Into<PackagePublishingSource>, F: FnMut(&String, &mut BlueprintDefinitionInit) -> bool>( &mut self, source: P, retain: F ) -> PackageAddress

source

pub fn compile_and_publish_with_owner<P: AsRef<Path>>( &mut self, package_dir: P, owner_badge: NonFungibleGlobalId ) -> PackageAddress

source

pub fn execute_unsigned_built_manifest_with_faucet_lock_fee( &mut self, create_manifest: impl FnOnce(ManifestBuilder) -> ManifestBuilder ) -> TransactionReceipt

source

pub fn execute_unsigned_built_manifest( &mut self, create_manifest: impl FnOnce(ManifestBuilder) -> ManifestBuilder ) -> TransactionReceipt

source

pub fn execute_built_manifest_with_faucet_lock_fee( &mut self, create_manifest: impl FnOnce(ManifestBuilder) -> ManifestBuilder, signatures: impl ResolvableTransactionSignatures ) -> TransactionReceipt

source

pub fn execute_built_manifest( &mut self, create_manifest: impl FnOnce(ManifestBuilder) -> ManifestBuilder, signatures: impl ResolvableTransactionSignatures ) -> TransactionReceipt

source

pub fn execute_manifest_with_fee_from_faucet<T>( &mut self, manifest: TransactionManifestV1, amount: Decimal, initial_proofs: T ) -> TransactionReceipt

source

pub fn execute_manifest_with_fee_from_faucet_with_system<'a, T, R: WrappedSystem<Vm<'a, DefaultWasmEngine, E>>>( &'a mut self, manifest: TransactionManifestV1, amount: Decimal, initial_proofs: T, init: R::Init ) -> TransactionReceipt

source

pub fn execute_manifest_ignoring_fee<T>( &mut self, manifest: TransactionManifestV1, initial_proofs: T ) -> TransactionReceipt

source

pub fn execute_raw_transaction( &mut self, network: &NetworkDefinition, raw_transaction: &RawNotarizedTransaction ) -> TransactionReceipt

source

pub fn execute_manifest<T>( &mut self, manifest: TransactionManifestV1, initial_proofs: T ) -> TransactionReceipt

source

pub fn execute_manifest_with_system<'a, T, R: WrappedSystem<Vm<'a, DefaultWasmEngine, E>>>( &'a mut self, manifest: TransactionManifestV1, initial_proofs: T, init: R::Init ) -> TransactionReceipt

source

pub fn execute_manifest_with_costing_params<T>( &mut self, manifest: TransactionManifestV1, initial_proofs: T, costing_parameters: CostingParameters ) -> TransactionReceipt

source

pub fn execute_manifest_with_execution_cost_unit_limit<T>( &mut self, manifest: TransactionManifestV1, initial_proofs: T, execution_cost_unit_limit: u32 ) -> TransactionReceipt

source

pub fn execute_transaction( &mut self, executable: Executable<'_>, costing_parameters: CostingParameters, execution_config: ExecutionConfig ) -> TransactionReceipt

source

pub fn execute_transaction_with_system<'a, T: WrappedSystem<Vm<'a, DefaultWasmEngine, E>>>( &'a mut self, executable: Executable<'_>, costing_parameters: CostingParameters, execution_config: ExecutionConfig, init: T::Init ) -> TransactionReceipt

source

pub fn preview( &mut self, preview_intent: PreviewIntentV1, network: &NetworkDefinition ) -> Result<TransactionReceipt, PreviewError>

source

pub fn preview_manifest( &mut self, manifest: TransactionManifestV1, signer_public_keys: Vec<PublicKey>, tip_percentage: u16, flags: PreviewFlags ) -> TransactionReceipt

source

pub fn call_function( &mut self, package_address: impl ResolvablePackageAddress, blueprint_name: impl Into<String>, function_name: impl Into<String>, arguments: impl ResolvableArguments ) -> TransactionReceipt

Calls a package blueprint function with the given arguments, paying the fee from the faucet.

The arguments should be one of:

  • A tuple, such as (), (x,) or (x, y, z)
    • IMPORTANT: If calling with a single argument, you must include a trailing comma in the tuple declaration. This ensures that the rust compiler knows it’s a singleton tuple, rather than just some brackets around the inner value.
  • A struct which implements ManifestEncode representing the arguments
  • manifest_args!(x, y, z)

Notes:

  • Buckets and signatures are not supported - instead use execute_manifest_ignoring_fee and ManifestBuilder directly.
  • Call .expect_commit_success() on the receipt to get access to receipt details.
source

pub fn construct_new( &mut self, package_address: impl ResolvablePackageAddress, blueprint_name: impl Into<String>, function_name: impl Into<String>, arguments: impl ResolvableArguments ) -> ComponentAddress

Calls a package blueprint function with the given arguments, and assumes it constructs a single component successfully. It returns the address of the first created component.

The arguments should be one of:

  • A tuple, such as (), (x,) or (x, y, z)
    • IMPORTANT: If calling with a single argument, you must include a trailing comma in the tuple declaration. This ensures that the rust compiler knows it’s a singleton tuple, rather than just some brackets around the inner value.
  • A struct which implements ManifestEncode representing the arguments
  • manifest_args!(x, y, z)

Notes:

  • Buckets and signatures are not supported - instead use execute_manifest_ignoring_fee and ManifestBuilder directly.
source

pub fn call_method( &mut self, address: impl ResolvableGlobalAddress, method_name: impl Into<String>, args: impl ResolvableArguments ) -> TransactionReceipt

Calls a component method with the given arguments, paying the fee from the faucet.

The arguments should be one of:

  • A tuple, such as (), (x,) or (x, y, z)
    • IMPORTANT: If calling with a single argument, you must include a trailing comma in the tuple declaration. This ensures that the rust compiler knows it’s a singleton tuple, rather than just some brackets around the inner value.
  • A struct which implements ManifestEncode representing the arguments
  • manifest_args!(x, y, z)

Notes:

  • Buckets and signatures are not supported - instead use execute_manifest_ignoring_fee and ManifestBuilder directly.
  • Call .expect_commit_success() on the receipt to get access to receipt details.
source

fn create_fungible_resource_and_deposit( &mut self, owner_role: OwnerRole, resource_roles: FungibleResourceRoles, to: ComponentAddress ) -> ResourceAddress

source

pub fn create_restricted_token( &mut self, account: ComponentAddress ) -> (ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress)

source

pub fn create_everything_allowed_non_fungible_resource( &mut self, owner_role: OwnerRole ) -> ResourceAddress

source

pub fn create_freezeable_token( &mut self, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_freezeable_non_fungible( &mut self, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_recallable_token( &mut self, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_restricted_burn_token( &mut self, account: ComponentAddress ) -> (ResourceAddress, ResourceAddress)

source

pub fn create_restricted_transfer_token( &mut self, account: ComponentAddress ) -> (ResourceAddress, ResourceAddress)

source

pub fn create_non_fungible_resource( &mut self, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_non_fungible_resource_with_roles( &mut self, resource_roles: NonFungibleResourceRoles, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_non_fungible_resource_advanced( &mut self, resource_roles: NonFungibleResourceRoles, account: ComponentAddress, n: usize ) -> ResourceAddress

source

pub fn create_fungible_resource( &mut self, amount: Decimal, divisibility: u8, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_mintable_burnable_fungible_resource( &mut self, account: ComponentAddress ) -> (ResourceAddress, ResourceAddress)

source

pub fn create_freely_mintable_fungible_resource( &mut self, owner_role: OwnerRole, amount: Option<Decimal>, divisibility: u8, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_freely_mintable_and_burnable_fungible_resource( &mut self, owner_role: OwnerRole, amount: Option<Decimal>, divisibility: u8, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_freely_mintable_and_burnable_non_fungible_resource<T, V>( &mut self, owner_role: OwnerRole, id_type: NonFungibleIdType, initial_supply: Option<T>, account: ComponentAddress ) -> ResourceAddress

source

pub fn create_one_resource_pool( &mut self, resource_address: ResourceAddress, pool_manager_rule: AccessRule ) -> (ComponentAddress, ResourceAddress)

source

pub fn new_component<F>( &mut self, initial_proofs: BTreeSet<NonFungibleGlobalId>, handler: F ) -> ComponentAddress
where F: FnOnce(ManifestBuilder) -> ManifestBuilder,

source

pub fn set_current_epoch(&mut self, epoch: Epoch)

source

pub fn get_current_epoch(&mut self) -> Epoch

source

pub fn execute_system_transaction_with_preallocation( &mut self, instructions: Vec<InstructionV1>, proofs: BTreeSet<NonFungibleGlobalId>, pre_allocated_addresses: Vec<PreAllocatedAddress> ) -> TransactionReceipt

source

pub fn execute_validator_transaction( &mut self, instructions: Vec<InstructionV1> ) -> TransactionReceipt

source

pub fn execute_system_transaction_with_preallocated_addresses( &mut self, instructions: Vec<InstructionV1>, pre_allocated_addresses: Vec<PreAllocatedAddress>, proofs: BTreeSet<NonFungibleGlobalId> ) -> TransactionReceipt

source

pub fn execute_system_transaction( &mut self, instructions: Vec<InstructionV1>, proofs: BTreeSet<NonFungibleGlobalId> ) -> TransactionReceipt

source

pub fn advance_to_round_at_timestamp( &mut self, round: Round, proposer_timestamp_ms: i64 ) -> TransactionReceipt

Executes a “start round number round at timestamp timestamp_ms” system transaction, as if it was proposed by the first validator from the validator set, after round - 1 missed rounds by that validator.

source

pub fn advance_to_round(&mut self, round: Round) -> TransactionReceipt

Performs an [advance_to_round_at_timestamp()] with an unchanged timestamp.

source

pub fn get_current_proposer_timestamp_ms(&mut self) -> i64

Reads out the substate holding the “epoch milli” timestamp reported by the proposer on the most recent round change.

source

pub fn get_consensus_manager_state(&mut self) -> ConsensusManagerSubstate

source

pub fn get_current_time(&mut self, precision: TimePrecision) -> Instant

source

pub fn event_schema( &self, event_type_identifier: &EventTypeIdentifier ) -> (LocalTypeId, VersionedScryptoSchema)

source

pub fn event_name(&self, event_type_identifier: &EventTypeIdentifier) -> String

source

pub fn is_event_name_equal<T: ScryptoDescribe>( &self, event_type_identifier: &EventTypeIdentifier ) -> bool

source

pub fn extract_events_of_type<T: ScryptoEvent>( &self, result: &CommitResult ) -> Vec<T>

source

pub fn check_db<A: ApplicationChecker + Default>( &self ) -> Result<(SystemDatabaseCheckerResults, A::ApplicationCheckerResults), SystemDatabaseCheckError>

source

pub fn check_events<A: ApplicationEventChecker>( &self ) -> Result<A::ApplicationEventCheckerResults, SystemEventCheckerError>

source

pub fn check_database(&self)

source§

impl<E: NativeVmExtension, D: TestDatabase> TestRunner<E, HashTreeUpdatingDatabase<D>>

Auto Trait Implementations§

§

impl<E, D> !RefUnwindSafe for TestRunner<E, D>

§

impl<E, D> Send for TestRunner<E, D>
where D: Send, E: Send,

§

impl<E, D> Sync for TestRunner<E, D>
where D: Sync, E: Sync,

§

impl<E, D> Unpin for TestRunner<E, D>
where D: Unpin, E: Unpin,

§

impl<E, D> !UnwindSafe for TestRunner<E, D>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromBits<T> for T

§

fn from_bits(other: T) -> T

Convert other to Self, preserving bitwise representation
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V