Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

dojo_cairo_test

Fully qualified path: dojo_cairo_test

Modules

world

Modules

Modules

world

world

Fully qualified path: dojo_cairo_test::world

Free functions

spawn_test_worldSpawns 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

ContractDefDefinition 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

TestResourceIn Cairo test runner, all the classes are expected to be declared already. If a contract belong to an other crate, it must be added to the build-external-contract ,…
ContractDescriptor

Traits

Impls

Free functions

Free functions

spawn_test_worldSpawns 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….

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_cairo_test::world::spawn_test_world

pub fn spawn_test_world(
    world_class_hash: ClassHash, namespaces_defs: Span<NamespaceDef>,
) -> WorldStorage

Structs

Structs

ContractDefDefinition 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_cairo_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_cairo_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_cairo_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_cairo_test::world::ContractDef::owner_of

pub owner_of: Span<felt252>

init_calldata

Calldata for dojo_init.

Fully qualified path: dojo_cairo_test::world::ContractDef::init_calldata

pub init_calldata: Span<felt252>

NamespaceDef

Fully qualified path: dojo_cairo_test::world::NamespaceDef

[derive(Drop, Debug)]
pub struct NamespaceDef {
    pub namespace: ByteArray,
    pub resources: Span<TestResource>,
}

Members

namespace

Fully qualified path: dojo_cairo_test::world::NamespaceDef::namespace

pub namespace: ByteArray

resources

Fully qualified path: dojo_cairo_test::world::NamespaceDef::resources

pub resources: Span<TestResource>

Enums

Enums

TestResourceIn Cairo test runner, all the classes are expected to be declared already. If a contract belong to an other crate, it must be added to the build-external-contract ,…
ContractDescriptor

TestResource

In Cairo test runner, all the classes are expected to be declared already. If a contract belong to an other crate, it must be added to the build-external-contract, event for testing, since Scarb does not do that automatically anymore.

Fully qualified path: dojo_cairo_test::world::TestResource

pub enum TestResource {
    Event: ClassHash,
    Model: ClassHash,
    Contract: ClassHash,
    Library: (ClassHash, @ByteArray, @ByteArray),
}

Variants

Event

Fully qualified path: dojo_cairo_test::world::TestResource::Event

Event: ClassHash

Model

Fully qualified path: dojo_cairo_test::world::TestResource::Model

Model: ClassHash

Contract

Fully qualified path: dojo_cairo_test::world::TestResource::Contract

Contract: ClassHash

Library

(class_hash, name, version)

Fully qualified path: dojo_cairo_test::world::TestResource::Library

Library: (ClassHash, @ByteArray, @ByteArray)

ContractDescriptor

Fully qualified path: dojo_cairo_test::world::ContractDescriptor

pub enum ContractDescriptor {
    Address: ContractAddress,
    Named: (@ByteArray, @ByteArray),
}

Variants

Address

Address of the contract.

Fully qualified path: dojo_cairo_test::world::ContractDescriptor::Address

Address: ContractAddress

Named

Namespace and name of the contract.

Fully qualified path: dojo_cairo_test::world::ContractDescriptor::Named

Named: (@ByteArray, @ByteArray)

Traits

Traits

ContractDefTrait

Fully qualified path: dojo_cairo_test::world::ContractDefTrait

pub trait ContractDefTrait

Trait functions

new

Fully qualified path: dojo_cairo_test::world::ContractDefTrait::new

fn new(namespace: @ByteArray, name: @ByteArray) -> ContractDef

new_address

Fully qualified path: dojo_cairo_test::world::ContractDefTrait::new_address

fn new_address(address: ContractAddress) -> ContractDef

with_init_calldata

Fully qualified path: dojo_cairo_test::world::ContractDefTrait::with_init_calldata

fn with_init_calldata(self: ContractDef, init_calldata: Span<felt252>) -> ContractDef

with_writer_of

Fully qualified path: dojo_cairo_test::world::ContractDefTrait::with_writer_of

fn with_writer_of(self: ContractDef, writer_of: Span<felt252>) -> ContractDef

with_owner_of

Fully qualified path: dojo_cairo_test::world::ContractDefTrait::with_owner_of

fn with_owner_of(self: ContractDef, owner_of: Span<felt252>) -> ContractDef

WorldStorageTestTrait

Fully qualified path: dojo_cairo_test::world::WorldStorageTestTrait

pub trait WorldStorageTestTrait

Trait functions

sync_perms_and_inits

Fully qualified path: dojo_cairo_test::world::WorldStorageTestTrait::sync_perms_and_inits

fn sync_perms_and_inits(self: @WorldStorage, contracts: Span<ContractDef>)

Impls

Impls

ContractDefImpl

Fully qualified path: dojo_cairo_test::world::ContractDefImpl

pub impl ContractDefImpl of ContractDefTrait;

Impl functions

new

Fully qualified path: dojo_cairo_test::world::ContractDefImpl::new

fn new(namespace: @ByteArray, name: @ByteArray) -> ContractDef

new_address

Fully qualified path: dojo_cairo_test::world::ContractDefImpl::new_address

fn new_address(address: ContractAddress) -> ContractDef

with_init_calldata

Fully qualified path: dojo_cairo_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_cairo_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_cairo_test::world::ContractDefImpl::with_owner_of

fn with_owner_of(mut self: ContractDef, owner_of: Span<felt252>) -> ContractDef

WorldStorageInternalTestImpl

Fully qualified path: dojo_cairo_test::world::WorldStorageInternalTestImpl

pub impl WorldStorageInternalTestImpl of WorldStorageTestTrait;

Impl functions

sync_perms_and_inits

Fully qualified path: dojo_cairo_test::world::WorldStorageInternalTestImpl::sync_perms_and_inits

fn sync_perms_and_inits(self: @WorldStorage, contracts: Span<ContractDef>)