LedgerSimulator

Struct LedgerSimulator 

Source
pub struct LedgerSimulator<E: NativeVmExtension, D: TestDatabase> { /* private fields */ }

Implementations§

Source§

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

Source§

impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<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 transaction_validator(&self) -> &TransactionValidator

Source

pub fn update_transaction_validator_after_manual_protocol_update(&mut self)

This should only be needed if you manually apply protocol updates to the underlying database after the LedgerSimulator has been built.

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, ) -> Result<Decimal, SystemReaderError>

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_radix_blueprint_schema_inits( &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 get_fungible_resource_total_supply( &self, resource: ResourceAddress, ) -> Decimal

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_preallocated_account( &mut self, ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)

Source

pub fn new_ed25519_preallocated_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_preallocated_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_preallocated: 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, )

Publishes a package at a specified address.

This is for testing only. On real networks, this operation is not allowed to users.

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_with_option<P: AsRef<Path>>( &mut self, package_dir: P, compile_profile: CompileProfile, ) -> (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_manifest( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, ) -> TransactionReceipt

Source

pub fn execute_manifest_with_execution_config( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, execution_config: ExecutionConfig, ) -> TransactionReceipt

Source

pub fn execute_manifest_with_costing_params( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, costing_parameters: CostingParameters, ) -> TransactionReceipt

Source

pub fn execute_manifest_with_injected_error( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, error_after_count: u64, ) -> TransactionReceipt

Source

pub fn construct_unsigned_notarized_transaction_v1( &mut self, manifest: TransactionManifestV1, ) -> NotarizedTransactionV1

Source

pub fn default_notary(&self) -> Ed25519PrivateKey

Source

pub fn v2_transaction_builder(&mut self) -> TransactionV2Builder

Includes default headers

Source

pub fn v2_partial_transaction_builder(&mut self) -> PartialTransactionV2Builder

Includes default headers

Source

pub fn execute_notarized_transaction( &mut self, transaction_source: impl ResolveAsRawNotarizedTransaction, ) -> TransactionReceipt

Source

pub fn execute_system_transaction( &mut self, manifest: SystemTransactionManifestV1, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, ) -> TransactionReceipt

The system manifest can be created with ManifestBuilder::new_system_v1(). Preallocated addresses can be created with manifest_builder.preallocate_address()

Source

pub fn execute_test_transaction( &mut self, test_transaction: TestTransaction, ) -> TransactionReceipt

Source

pub fn execute_transaction_no_commit( &mut self, executable_source: impl IntoExecutable, execution_config: ExecutionConfig, ) -> TransactionReceipt

Source

pub fn execute_transaction( &mut self, executable_source: impl IntoExecutable, execution_config: ExecutionConfig, ) -> 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 preview_v2( &mut self, preview_transaction: PreviewTransactionV2, flags: PreviewFlags, ) -> TransactionReceipt

Source

pub fn call_function( &mut self, package_address: impl Resolve<ManifestPackageAddress>, 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 Resolve<ManifestPackageAddress>, 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 Resolve<ManifestGlobalAddress>, 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

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

Source

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

Source

pub fn get_current_epoch(&mut self) -> Epoch

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> LedgerSimulator<E, StateTreeUpdatingDatabase<D>>

Auto Trait Implementations§

§

impl<E, D> Freeze for LedgerSimulator<E, D>
where D: Freeze, E: Freeze,

§

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

§

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

§

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

§

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

§

impl<E, D> !UnwindSafe for LedgerSimulator<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
Source§

impl<U> As for U

Source§

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
Source§

impl<T, U> ContextualTryInto<U> for T
where U: ContextualTryFrom<T>,

Source§

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

Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

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

Source§

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

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.

Source§

impl<T> FromBits<T> for T

Source§

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<X, Y> LabelledResolve<Y> for X
where Y: LabelledResolveFrom<X>,

Source§

fn labelled_resolve( self, resolver: &impl LabelResolver<<Y as LabelledResolvable>::ResolverOutput>, ) -> Y

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<X, Y> Resolve<Y> for X
where Y: ResolveFrom<X>,

Source§

fn resolve(self) -> Y

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.