scrypto_test/sdk/resource/common.rs
1use crate::prelude::*;
2
3/// The creation strategy used in the [`BucketFactory`] and [`ProofFactory`] structs allowing them
4/// to either create them by disabling auth and minting or by mocking the bucket or proof.
5///
6/// [`BucketFactory`]: crate::prelude::BucketFactory
7/// [`ProofFactory`]: crate::prelude::ProofFactory
8#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
9pub enum CreationStrategy {
10 /// Disables the auth module and mints the specified amount of resources and then creates a
11 /// [`Bucket`] or [`Proof`] out of them.
12 ///
13 /// [`Bucket`]: crate::prelude::Bucket
14 /// [`Proof`]: crate::prelude::Proof
15 DisableAuthAndMint,
16
17 /// Mocks the creation of [`Bucket`]s and [`Proof`]s by creating nodes with their respective
18 /// substates. This approach does not increase the total supply of the resource but can be
19 /// somewhat fragile in some tests.
20 ///
21 /// [`Bucket`]: crate::prelude::Bucket
22 /// [`Proof`]: crate::prelude::Proof
23 Mock,
24}
25pub use CreationStrategy::*;
26
27#[derive(Clone, Debug)]
28pub enum FactoryResourceSpecifier {
29 Amount(ResourceAddress, Decimal),
30 Ids(ResourceAddress, IndexMap<NonFungibleLocalId, ScryptoValue>),
31}
32
33impl FactoryResourceSpecifier {
34 pub fn resource_address(&self) -> &ResourceAddress {
35 match self {
36 Self::Amount(address, ..) | Self::Ids(address, ..) => address,
37 }
38 }
39}