pub struct LedgerSimulator<E: NativeVmExtension, D: TestDatabase> { /* private fields */ }
Implementations§
Source§impl<E: NativeVmExtension> LedgerSimulator<E, InMemorySubstateDatabase>
impl<E: NativeVmExtension> LedgerSimulator<E, InMemorySubstateDatabase>
pub fn create_snapshot(&self) -> LedgerSimulatorSnapshot
pub fn restore_snapshot(&mut self, snapshot: LedgerSimulatorSnapshot)
Source§impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, D>
impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, D>
pub fn faucet_component(&self) -> GlobalAddress
pub fn substate_db(&self) -> &D
pub fn substate_db_mut(&mut self) -> &mut D
pub fn transaction_validator(&self) -> &TransactionValidator
Sourcepub fn update_transaction_validator_after_manual_protocol_update(&mut self)
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.
pub fn collected_events(&self) -> &Vec<Vec<(EventTypeIdentifier, Vec<u8>)>>
pub fn next_private_key(&mut self) -> u64
pub fn next_transaction_nonce(&mut self) -> u32
pub fn new_key_pair(&mut self) -> (Secp256k1PublicKey, Secp256k1PrivateKey)
pub fn new_ed25519_key_pair(&mut self) -> (Ed25519PublicKey, Ed25519PrivateKey)
pub fn new_key_pair_with_auth_address( &mut self, ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, NonFungibleGlobalId)
pub fn set_metadata( &mut self, address: GlobalAddress, key: &str, value: &str, proof: NonFungibleGlobalId, )
pub fn get_metadata( &mut self, address: GlobalAddress, key: &str, ) -> Option<MetadataValue>
pub fn inspect_component_royalty( &mut self, component_address: ComponentAddress, ) -> Result<Decimal, SystemReaderError>
pub fn inspect_package_royalty( &mut self, package_address: PackageAddress, ) -> Option<Decimal>
pub fn find_all_nodes(&self) -> IndexSet<NodeId>
pub fn find_all_components(&self) -> Vec<ComponentAddress>
pub fn find_all_packages(&self) -> Vec<PackageAddress>
pub fn find_all_resources(&self) -> Vec<ResourceAddress>
pub fn get_package_radix_blueprint_schema_inits( &self, package_address: &PackageAddress, ) -> IndexMap<SchemaHash, VersionedScryptoSchema>
pub fn get_package_blueprint_definitions( &self, package_address: &PackageAddress, ) -> IndexMap<BlueprintVersionKey, BlueprintDefinition>
pub fn sum_descendant_balance_changes( &mut self, commit: &CommitResult, node_id: &NodeId, ) -> IndexMap<ResourceAddress, BalanceChange>
pub fn get_component_vaults( &mut self, component_address: ComponentAddress, resource_address: ResourceAddress, ) -> Vec<NodeId>
pub fn get_component_balance( &mut self, account_address: ComponentAddress, resource_address: ResourceAddress, ) -> Decimal
pub fn inspect_vault_balance(&mut self, vault_id: NodeId) -> Option<Decimal>
pub fn inspect_fungible_vault(&mut self, vault_id: NodeId) -> Option<Decimal>
pub fn inspect_non_fungible_vault( &mut self, vault_id: NodeId, ) -> Option<(Decimal, Box<dyn Iterator<Item = NonFungibleLocalId> + '_>)>
pub fn get_component_resources( &mut self, component_address: ComponentAddress, ) -> HashMap<ResourceAddress, Decimal>
pub fn component_state<T: ScryptoDecode>( &self, component_address: ComponentAddress, ) -> T
pub fn get_non_fungible_data<T: NonFungibleData>( &self, resource: ResourceAddress, non_fungible_id: NonFungibleLocalId, ) -> T
pub fn get_kv_store_entry<K: ScryptoEncode, V: ScryptoEncode + ScryptoDecode>( &self, kv_store_id: Own, key: &K, ) -> Option<V>
pub fn get_fungible_resource_total_supply( &self, resource: ResourceAddress, ) -> Decimal
pub fn load_account_from_faucet(&mut self, account_address: ComponentAddress)
pub fn new_account_advanced( &mut self, owner_role: OwnerRole, ) -> ComponentAddress
pub fn new_preallocated_account( &mut self, ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)
pub fn new_ed25519_preallocated_account( &mut self, ) -> (Ed25519PublicKey, Ed25519PrivateKey, ComponentAddress)
pub fn get_active_validator_info_by_key( &self, key: &Secp256k1PublicKey, ) -> ValidatorSubstate
pub fn get_validator_info(&self, address: ComponentAddress) -> ValidatorSubstate
pub fn get_active_validator_with_key( &self, key: &Secp256k1PublicKey, ) -> ComponentAddress
pub fn new_allocated_account( &mut self, ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)
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)
pub fn new_account( &mut self, is_preallocated: bool, ) -> (Secp256k1PublicKey, Secp256k1PrivateKey, ComponentAddress)
pub fn new_identity<P: Into<PublicKey> + Clone + HasPublicKeyHash>( &mut self, pk: P, is_virtual: bool, ) -> ComponentAddress
pub fn new_securified_identity( &mut self, account: ComponentAddress, ) -> ComponentAddress
pub fn new_validator_with_pub_key( &mut self, pub_key: Secp256k1PublicKey, account: ComponentAddress, ) -> ComponentAddress
pub fn new_staked_validator_with_pub_key( &mut self, pub_key: Secp256k1PublicKey, account: ComponentAddress, ) -> ComponentAddress
pub fn publish_native_package( &mut self, native_package_code_id: u64, definition: PackageDefinition, ) -> PackageAddress
Sourcepub fn publish_package_at_address<P: Into<PackagePublishingSource>>(
&mut self,
source: P,
address: PackageAddress,
)
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.
pub fn publish_package<P: Into<PackagePublishingSource>>( &mut self, source: P, metadata: BTreeMap<String, MetadataValue>, owner_role: OwnerRole, ) -> PackageAddress
pub fn try_publish_package<P: Into<PackagePublishingSource>>( &mut self, source: P, ) -> TransactionReceipt
pub fn publish_package_simple<P: Into<PackagePublishingSource>>( &mut self, source: P, ) -> PackageAddress
pub fn publish_package_with_owner<P: Into<PackagePublishingSource>>( &mut self, source: P, owner_badge: NonFungibleGlobalId, ) -> PackageAddress
pub fn compile<P: AsRef<Path>>( &mut self, package_dir: P, ) -> (Vec<u8>, PackageDefinition)
pub fn compile_with_option<P: AsRef<Path>>( &mut self, package_dir: P, compile_profile: CompileProfile, ) -> (Vec<u8>, PackageDefinition)
pub fn compile_and_publish<P: AsRef<Path>>( &mut self, package_dir: P, ) -> PackageAddress
pub fn compile_and_publish_at_address<P: AsRef<Path>>( &mut self, package_dir: P, address: PackageAddress, )
pub fn publish_retain_blueprints<P: Into<PackagePublishingSource>, F: FnMut(&String, &mut BlueprintDefinitionInit) -> bool>( &mut self, source: P, retain: F, ) -> PackageAddress
pub fn compile_and_publish_with_owner<P: AsRef<Path>>( &mut self, package_dir: P, owner_badge: NonFungibleGlobalId, ) -> PackageAddress
pub fn execute_manifest( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, ) -> TransactionReceipt
pub fn execute_manifest_with_execution_config( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, execution_config: ExecutionConfig, ) -> TransactionReceipt
pub fn execute_manifest_with_costing_params( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, costing_parameters: CostingParameters, ) -> TransactionReceipt
pub fn execute_manifest_with_injected_error( &mut self, manifest: impl BuildableManifest, initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>, error_after_count: u64, ) -> TransactionReceipt
pub fn construct_unsigned_notarized_transaction_v1( &mut self, manifest: TransactionManifestV1, ) -> NotarizedTransactionV1
pub fn default_notary(&self) -> Ed25519PrivateKey
Sourcepub fn v2_transaction_builder(&mut self) -> TransactionV2Builder
pub fn v2_transaction_builder(&mut self) -> TransactionV2Builder
Includes default headers
Sourcepub fn v2_partial_transaction_builder(&mut self) -> PartialTransactionV2Builder
pub fn v2_partial_transaction_builder(&mut self) -> PartialTransactionV2Builder
Includes default headers
pub fn execute_notarized_transaction( &mut self, transaction_source: impl ResolveAsRawNotarizedTransaction, ) -> TransactionReceipt
Sourcepub fn execute_system_transaction(
&mut self,
manifest: SystemTransactionManifestV1,
initial_proofs: impl IntoIterator<Item = NonFungibleGlobalId>,
) -> TransactionReceipt
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()
pub fn execute_test_transaction( &mut self, test_transaction: TestTransaction, ) -> TransactionReceipt
pub fn execute_transaction_no_commit( &mut self, executable_source: impl IntoExecutable, execution_config: ExecutionConfig, ) -> TransactionReceipt
pub fn execute_transaction( &mut self, executable_source: impl IntoExecutable, execution_config: ExecutionConfig, ) -> TransactionReceipt
pub fn preview( &mut self, preview_intent: PreviewIntentV1, network: &NetworkDefinition, ) -> Result<TransactionReceipt, PreviewError>
pub fn preview_manifest( &mut self, manifest: TransactionManifestV1, signer_public_keys: Vec<PublicKey>, tip_percentage: u16, flags: PreviewFlags, ) -> TransactionReceipt
pub fn preview_v2( &mut self, preview_transaction: PreviewTransactionV2, flags: PreviewFlags, ) -> TransactionReceipt
Sourcepub fn call_function(
&mut self,
package_address: impl Resolve<ManifestPackageAddress>,
blueprint_name: impl Into<String>,
function_name: impl Into<String>,
arguments: impl ResolvableArguments,
) -> TransactionReceipt
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
andManifestBuilder
directly. - Call
.expect_commit_success()
on the receipt to get access to receipt details.
Sourcepub fn construct_new(
&mut self,
package_address: impl Resolve<ManifestPackageAddress>,
blueprint_name: impl Into<String>,
function_name: impl Into<String>,
arguments: impl ResolvableArguments,
) -> ComponentAddress
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
andManifestBuilder
directly.
Sourcepub fn call_method(
&mut self,
address: impl Resolve<ManifestGlobalAddress>,
method_name: impl Into<String>,
args: impl ResolvableArguments,
) -> TransactionReceipt
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
andManifestBuilder
directly. - Call
.expect_commit_success()
on the receipt to get access to receipt details.
pub fn create_restricted_token( &mut self, account: ComponentAddress, ) -> (ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress, ResourceAddress)
pub fn create_everything_allowed_non_fungible_resource( &mut self, owner_role: OwnerRole, ) -> ResourceAddress
pub fn create_freezeable_token( &mut self, account: ComponentAddress, ) -> ResourceAddress
pub fn create_freezeable_non_fungible( &mut self, account: ComponentAddress, ) -> ResourceAddress
pub fn create_recallable_token( &mut self, account: ComponentAddress, ) -> ResourceAddress
pub fn create_restricted_burn_token( &mut self, account: ComponentAddress, ) -> (ResourceAddress, ResourceAddress)
pub fn create_restricted_transfer_token( &mut self, account: ComponentAddress, ) -> (ResourceAddress, ResourceAddress)
pub fn create_non_fungible_resource( &mut self, account: ComponentAddress, ) -> ResourceAddress
pub fn create_non_fungible_resource_with_roles( &mut self, resource_roles: NonFungibleResourceRoles, account: ComponentAddress, ) -> ResourceAddress
pub fn create_non_fungible_resource_advanced( &mut self, resource_roles: NonFungibleResourceRoles, account: ComponentAddress, n: usize, ) -> ResourceAddress
pub fn create_fungible_resource( &mut self, amount: Decimal, divisibility: u8, account: ComponentAddress, ) -> ResourceAddress
pub fn create_mintable_burnable_fungible_resource( &mut self, account: ComponentAddress, ) -> (ResourceAddress, ResourceAddress)
pub fn create_freely_mintable_fungible_resource( &mut self, owner_role: OwnerRole, amount: Option<Decimal>, divisibility: u8, account: ComponentAddress, ) -> ResourceAddress
pub fn create_freely_mintable_and_burnable_fungible_resource( &mut self, owner_role: OwnerRole, amount: Option<Decimal>, divisibility: u8, account: ComponentAddress, ) -> ResourceAddress
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
pub fn create_one_resource_pool( &mut self, resource_address: ResourceAddress, pool_manager_rule: AccessRule, ) -> (ComponentAddress, ResourceAddress)
pub fn new_component<F>( &mut self, initial_proofs: BTreeSet<NonFungibleGlobalId>, handler: F, ) -> ComponentAddress
pub fn set_current_epoch(&mut self, epoch: Epoch)
pub fn get_current_epoch(&mut self) -> Epoch
Sourcepub fn advance_to_round_at_timestamp(
&mut self,
round: Round,
proposer_timestamp_ms: i64,
) -> TransactionReceipt
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.
Sourcepub fn advance_to_round(&mut self, round: Round) -> TransactionReceipt
pub fn advance_to_round(&mut self, round: Round) -> TransactionReceipt
Performs an [advance_to_round_at_timestamp()
] with an unchanged timestamp.
Sourcepub fn get_current_proposer_timestamp_ms(&mut self) -> i64
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.
pub fn get_consensus_manager_state(&mut self) -> ConsensusManagerSubstate
pub fn get_current_time(&mut self, precision: TimePrecision) -> Instant
pub fn event_schema( &self, event_type_identifier: &EventTypeIdentifier, ) -> (LocalTypeId, VersionedScryptoSchema)
pub fn event_name(&self, event_type_identifier: &EventTypeIdentifier) -> String
pub fn is_event_name_equal<T: ScryptoDescribe>( &self, event_type_identifier: &EventTypeIdentifier, ) -> bool
pub fn extract_events_of_type<T: ScryptoEvent>( &self, result: &CommitResult, ) -> Vec<T>
pub fn check_db<A: ApplicationChecker + Default>( &self, ) -> Result<(SystemDatabaseCheckerResults, A::ApplicationCheckerResults), SystemDatabaseCheckError>
pub fn check_events<A: ApplicationEventChecker>( &self, ) -> Result<A::ApplicationEventCheckerResults, SystemEventCheckerError>
pub fn check_database(&self)
Source§impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, StateTreeUpdatingDatabase<D>>
impl<E: NativeVmExtension, D: TestDatabase> LedgerSimulator<E, StateTreeUpdatingDatabase<D>>
pub fn get_state_hash(&self) -> Hash
pub fn assert_state_tree_matches_substate_store(&mut self)
Auto Trait Implementations§
impl<E, D> Freeze for LedgerSimulator<E, D>
impl<E, D> !RefUnwindSafe for LedgerSimulator<E, D>
impl<E, D> Send for LedgerSimulator<E, D>
impl<E, D> Sync for LedgerSimulator<E, D>
impl<E, D> Unpin for LedgerSimulator<E, D>
impl<E, D> !UnwindSafe for LedgerSimulator<E, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
type Error = <U as ContextualTryFrom<T>>::Error
type Context = <U as ContextualTryFrom<T>>::Context
fn contextual_try_into( self, context: &<U as ContextualTryFrom<T>>::Context, ) -> Result<U, <U as ContextualTryFrom<T>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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