dojo_snf_test
Fully qualified path: dojo_snf_test
Modules
Modules
Modules
cheatcodes
Fully qualified path: dojo_snf_test::cheatcodes
Free functions
| set_account_address | Set the global account address used for tests…. |
| set_caller_address | Set the global caller address used for tests…. |
| get_default_caller_address | Get the default caller address used for tests. |
| set_block_number | — |
Free functions
Free functions
| set_account_address | Set the global account address used for tests…. |
| set_caller_address | Set the global caller address used for tests…. |
| get_default_caller_address | Get the default caller address used for tests. |
| set_block_number | — |
set_account_address
Set the global account address used for tests.
Arguments
account- the account address.
Fully qualified path: dojo_snf_test::cheatcodes::set_account_address
pub fn set_account_address(account: ContractAddress)
set_caller_address
Set the global caller address used for tests.
Arguments
account- the caller address.
Fully qualified path: dojo_snf_test::cheatcodes::set_caller_address
pub fn set_caller_address(contract: ContractAddress)
get_default_caller_address
Get the default caller address used for tests.
Fully qualified path: dojo_snf_test::cheatcodes::get_default_caller_address
pub fn get_default_caller_address() -> ContractAddress
set_block_number
Fully qualified path: dojo_snf_test::cheatcodes::set_block_number
pub fn set_block_number(block_number: u64)
declare_deploy
Fully qualified path: dojo_snf_test::declare_deploy
Free functions
| declare | Declare a contract…. |
| deploy | Deploy a contract…. |
| declare_and_deploy | Declare and deploy and contract…. |
| declare_contract | Declare a Dojo contract…. |
| declare_library | Declare a Dojo library…. |
| declare_event_contract | Declare a Dojo Event contract…. |
| declare_model_contract | Declare a Dojo Model contract…. |
Free functions
Free functions
| declare | Declare a contract…. |
| deploy | Deploy a contract…. |
| declare_and_deploy | Declare and deploy and contract…. |
| declare_contract | Declare a Dojo contract…. |
| declare_library | Declare a Dojo library…. |
| declare_event_contract | Declare a Dojo Event contract…. |
| declare_model_contract | Declare a Dojo Model contract…. |
declare
Declare a contract.
Arguments
name- the contract name.
Returns
The declared contract class and classHash.
Fully qualified path: dojo_snf_test::declare_deploy::declare
pub fn declare(name: ByteArray) -> (ContractClass, ClassHash)
deploy
Deploy a contract.
Arguments
contract_class- the contract class.calldata- serialized calldata to pass to constructor.
Returns
The deployed contract address.
Fully qualified path: dojo_snf_test::declare_deploy::deploy
pub fn deploy(contract_class: ContractClass, calldata: @Array<felt252>) -> ContractAddress
declare_and_deploy
Declare and deploy and contract.
Arguments
name- the contract name.
Returns
The deployed contract address.
Fully qualified path: dojo_snf_test::declare_deploy::declare_and_deploy
pub fn declare_and_deploy(name: ByteArray) -> ContractAddress
declare_contract
Declare a Dojo contract.
Arguments
name- the contract name.
Returns
The declared contract classhash.
Fully qualified path: dojo_snf_test::declare_deploy::declare_contract
pub fn declare_contract(name: ByteArray) -> ClassHash
declare_library
Declare a Dojo library.
Arguments
name- the library contract name.
Returns
The declared library classhash.
Fully qualified path: dojo_snf_test::declare_deploy::declare_library
pub fn declare_library(name: ByteArray) -> ClassHash
declare_event_contract
Declare a Dojo Event contract.
Arguments
name- the contract name.
Returns
The declared contract classhash.
Fully qualified path: dojo_snf_test::declare_deploy::declare_event_contract
pub fn declare_event_contract(name: ByteArray) -> ClassHash
declare_model_contract
Declare a Dojo Model contract.
Arguments
name- the contract name.
Returns
The declared contract classhash.
Fully qualified path: dojo_snf_test::declare_deploy::declare_model_contract
pub fn declare_model_contract(name: ByteArray) -> ClassHash
world
Fully qualified path: dojo_snf_test::world
Free functions
| deploy_contract | Deploy classhash with calldata for constructor… |
| deploy_with_world_address | Deploy classhash and passes in world address to constructor… |
| spawn_test_world | Spawns a test world registering provided resources into namespaces. This function only deploys the world and registers the resources, it does not initialize the contracts or any permissions…. |
Structs
| ContractDef | Definition of a contract to register in the world. You can use this struct for a dojo contract, but also for an external contract. The only difference is the init_calldata… |
| NamespaceDef | — |
Enums
| TestResource | In snfoundry test runner, all the classes must be declared. If a contract belong to an other crate, it must be added to the build-external-contract ,… |
| ContractDescriptor | — |
Type aliases
Traits
Impls
Free functions
Free functions
| deploy_contract | Deploy classhash with calldata for constructor… |
| deploy_with_world_address | Deploy classhash and passes in world address to constructor… |
| spawn_test_world | Spawns a test world registering provided resources into namespaces. This function only deploys the world and registers the resources, it does not initialize the contracts or any permissions…. |
deploy_contract
Deploy classhash with calldata for constructor
Arguments
class_hash- Class to deploycalldata- calldata for constructor
Returns
- address of contract deployed
Fully qualified path: dojo_snf_test::world::deploy_contract
pub fn deploy_contract(class_hash: felt252, calldata: Span<felt252>) -> ContractAddress
deploy_with_world_address
Deploy classhash and passes in world address to constructor
Arguments
class_hash- Class to deployworld- World dispatcher to pass as world address
Returns
- address of contract deployed
Fully qualified path: dojo_snf_test::world::deploy_with_world_address
pub fn deploy_with_world_address(class_hash: felt252, world: IWorldDispatcher) -> ContractAddress
spawn_test_world
Spawns a test world registering provided resources into namespaces.
This function only deploys the world and registers the resources, it does not initialize the
contracts or any permissions.
The first namespace is used as the default namespace when WorldStorage is returned.
Arguments
namespaces_defs- Definitions of namespaces to register.
Returns
- World dispatcher
Fully qualified path: dojo_snf_test::world::spawn_test_world
pub fn spawn_test_world(namespaces_defs: Span<NamespaceDef>) -> WorldStorage
Structs
Structs
| ContractDef | Definition of a contract to register in the world. You can use this struct for a dojo contract, but also for an external contract. The only difference is the init_calldata… |
| NamespaceDef | — |
ContractDef
Definition of a contract to register in the world.
You can use this struct for a dojo contract, but also for an external contract.
The only difference is the init_calldata, which is only used for dojo contracts.
If the contract is an external contract (hence an address), then init_calldata is ignored.
Fully qualified path: dojo_snf_test::world::ContractDef
#[derive(Drop, Copy, Debug)]
pub struct ContractDef {
pub contract: ContractDescriptor,
pub writer_of: Span<felt252>,
pub owner_of: Span<felt252>,
pub init_calldata: Span<felt252>,
}
Members
contract
The contract to grant permission to.
Fully qualified path: dojo_snf_test::world::ContractDef::contract
pub contract: ContractDescriptor
writer_of
Selectors of the resources that the contract is granted writer access to.
Fully qualified path: dojo_snf_test::world::ContractDef::writer_of
pub writer_of: Span<felt252>
owner_of
Selector of the resource that the contract is the owner of.
Fully qualified path: dojo_snf_test::world::ContractDef::owner_of
pub owner_of: Span<felt252>
init_calldata
Calldata for dojo_init.
Fully qualified path: dojo_snf_test::world::ContractDef::init_calldata
pub init_calldata: Span<felt252>
NamespaceDef
Fully qualified path: dojo_snf_test::world::NamespaceDef
[derive(Drop, Debug)]
pub struct NamespaceDef {
pub namespace: ByteArray,
pub resources: Span<TestResource>,
}
Members
namespace
Fully qualified path: dojo_snf_test::world::NamespaceDef::namespace
pub namespace: ByteArray
resources
Fully qualified path: dojo_snf_test::world::NamespaceDef::resources
pub resources: Span<TestResource>
Enums
Enums
| TestResource | In snfoundry test runner, all the classes must be declared. If a contract belong to an other crate, it must be added to the build-external-contract ,… |
| ContractDescriptor | — |
TestResource
In snfoundry test runner, all the classes must be declared.
If a contract belong to an other crate, it must be added to the build-external-contract,
even for testing, since Scarb does not do that automatically anymore.
The TestResource enum uses a ByteArray to represent the resource name.
Fully qualified path: dojo_snf_test::world::TestResource
pub enum TestResource {
Event: ByteArray,
Model: ByteArray,
Contract: ByteArray,
Library: (ByteArray, ByteArray),
}
Variants
Event
Fully qualified path: dojo_snf_test::world::TestResource::Event
Event: ByteArray
Model
Fully qualified path: dojo_snf_test::world::TestResource::Model
Model: ByteArray
Contract
Fully qualified path: dojo_snf_test::world::TestResource::Contract
Contract: ByteArray
Library
(name, version)
Fully qualified path: dojo_snf_test::world::TestResource::Library
Library: (ByteArray, ByteArray)
ContractDescriptor
Fully qualified path: dojo_snf_test::world::ContractDescriptor
pub enum ContractDescriptor {
Address: ContractAddress,
Named: (@ByteArray, @ByteArray),
}
Variants
Address
Address of the contract.
Fully qualified path: dojo_snf_test::world::ContractDescriptor::Address
Address: ContractAddress
Named
Namespace and name of the contract.
Fully qualified path: dojo_snf_test::world::ContractDescriptor::Named
Named: (@ByteArray, @ByteArray)
Type aliases
Type aliases
TestClassHash
Fully qualified path: dojo_snf_test::world::TestClassHash
pub type TestClassHash = felt252;
Traits
Traits
ContractDefTrait
Fully qualified path: dojo_snf_test::world::ContractDefTrait
pub trait ContractDefTrait
Trait functions
new
Fully qualified path: dojo_snf_test::world::ContractDefTrait::new
fn new(namespace: @ByteArray, name: @ByteArray) -> ContractDef
new_address
Fully qualified path: dojo_snf_test::world::ContractDefTrait::new_address
fn new_address(address: ContractAddress) -> ContractDef
with_init_calldata
Fully qualified path: dojo_snf_test::world::ContractDefTrait::with_init_calldata
fn with_init_calldata(self: ContractDef, init_calldata: Span<felt252>) -> ContractDef
with_writer_of
Fully qualified path: dojo_snf_test::world::ContractDefTrait::with_writer_of
fn with_writer_of(self: ContractDef, writer_of: Span<felt252>) -> ContractDef
with_owner_of
Fully qualified path: dojo_snf_test::world::ContractDefTrait::with_owner_of
fn with_owner_of(self: ContractDef, owner_of: Span<felt252>) -> ContractDef
WorldStorageTestTrait
Fully qualified path: dojo_snf_test::world::WorldStorageTestTrait
pub trait WorldStorageTestTrait
Trait functions
sync_perms_and_inits
Fully qualified path: dojo_snf_test::world::WorldStorageTestTrait::sync_perms_and_inits
fn sync_perms_and_inits(self: @WorldStorage, contracts: Span<ContractDef>)
Impls
Impls
ContractDefImpl
Fully qualified path: dojo_snf_test::world::ContractDefImpl
pub impl ContractDefImpl of ContractDefTrait;
Impl functions
new
Fully qualified path: dojo_snf_test::world::ContractDefImpl::new
fn new(namespace: @ByteArray, name: @ByteArray) -> ContractDef
new_address
Fully qualified path: dojo_snf_test::world::ContractDefImpl::new_address
fn new_address(address: ContractAddress) -> ContractDef
with_init_calldata
Fully qualified path: dojo_snf_test::world::ContractDefImpl::with_init_calldata
fn with_init_calldata(mut self: ContractDef, init_calldata: Span<felt252>) -> ContractDef
with_writer_of
Fully qualified path: dojo_snf_test::world::ContractDefImpl::with_writer_of
fn with_writer_of(mut self: ContractDef, writer_of: Span<felt252>) -> ContractDef
with_owner_of
Fully qualified path: dojo_snf_test::world::ContractDefImpl::with_owner_of
fn with_owner_of(mut self: ContractDef, owner_of: Span<felt252>) -> ContractDef
WorldStorageInternalTestImpl
Fully qualified path: dojo_snf_test::world::WorldStorageInternalTestImpl
pub impl WorldStorageInternalTestImpl of WorldStorageTestTrait;
Impl functions
sync_perms_and_inits
Fully qualified path: dojo_snf_test::world::WorldStorageInternalTestImpl::sync_perms_and_inits
fn sync_perms_and_inits(self: @WorldStorage, contracts: Span<ContractDef>)