Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

openzeppelin_testing

Fully qualified path: openzeppelin_testing

Modules


Re-exports:

panic_data_to_byte_arrayConverts panic data into a string (ByteArray). panic_data is expected to be a valid serialized byte array with an extra felt252 at the beginning, which is the BYTE_ARRAY_MAGIC.
to_base_16_stringConverts a felt252 to a base16 string padded to 66 characters including the 0x prefix.
declare_and_deployCombines the declaration of a class and the deployment of a contract into one function call. This function will skip declaration if the contract is already declared (the result of…
declare_and_deploy_atCombines the declaration of a class and the deployment of a contract at the given address into one function call. This function will skip declaration if the contract is…
declare_classDeclares a contract with a snforge_std::declare call and unwraps the result. This function will skip declaration and just return the ContractClass if the contract is…
deployDeploys an instance of a contract and unwraps the result.
deploy_another_atDeploys a contract using the class hash from another already-deployed contract.
deploy_atDeploys a contract at the given address and unwraps the result.
spy_eventsCreates a new EventSpyQueue instance.

EventSpyQueueA wrapper around the EventSpy structure to allow treating the events as a queue.


ExpectedEventThe ExpectedEvent trait provides a convenient API for constructing expected events in tests. This implementation is generated by the #[generate_trait] macro and offers three methods:…

Modules

Modules

common

Fully qualified path: openzeppelin_testing::common

Free functions

panic_data_to_byte_arrayConverts panic data into a string (ByteArray). panic_data is expected to be a valid serialized byte array with an extra felt252 at the beginning, which is the BYTE_ARRAY_MAGIC.
to_base_16_stringConverts a felt252 to a base16 string padded to 66 characters including the 0x prefix.
to_base_16_string_no_paddingConverts a felt252 to a base16 (hexadecimal) string without padding, but including the 0x prefix. We need this because Starknet Foundry has a way of representing addresses and selectors that…

Traits

Free functions

Free functions

panic_data_to_byte_arrayConverts panic data into a string (ByteArray). panic_data is expected to be a valid serialized byte array with an extra felt252 at the beginning, which is the BYTE_ARRAY_MAGIC.
to_base_16_stringConverts a felt252 to a base16 string padded to 66 characters including the 0x prefix.
to_base_16_string_no_paddingConverts a felt252 to a base16 (hexadecimal) string without padding, but including the 0x prefix. We need this because Starknet Foundry has a way of representing addresses and selectors that…

panic_data_to_byte_array

Converts panic data into a string (ByteArray).

panic_data is expected to be a valid serialized byte array with an extra felt252 at the beginning, which is the BYTE_ARRAY_MAGIC.

Fully qualified path: openzeppelin_testing::common::panic_data_to_byte_array

pub fn panic_data_to_byte_array(panic_data: Array<felt252>) -> ByteArray

to_base_16_string

Converts a felt252 to a base16 string padded to 66 characters including the 0x prefix.

Fully qualified path: openzeppelin_testing::common::to_base_16_string

pub fn to_base_16_string(value: felt252) -> ByteArray

to_base_16_string_no_padding

Converts a felt252 to a base16 (hexadecimal) string without padding, but including the 0x prefix. We need this because Starknet Foundry has a way of representing addresses and selectors that does not include 0’s after 0x.

Fully qualified path: openzeppelin_testing::common::to_base_16_string_no_padding

pub fn to_base_16_string_no_padding(value: felt252) -> ByteArray

Traits

Traits

IntoBase16StringTrait

Fully qualified path: openzeppelin_testing::common::IntoBase16StringTrait

pub trait IntoBase16StringTrait<T, +Into<T, felt252>>

Trait functions

into_base_16_string

Fully qualified path: openzeppelin_testing::common::IntoBase16StringTrait::into_base_16_string

fn into_base_16_string(self: T) -> ByteArray

into_base_16_string_no_padding

Fully qualified path: openzeppelin_testing::common::IntoBase16StringTrait::into_base_16_string_no_padding

fn into_base_16_string_no_padding(self: T) -> ByteArray

constants

Fully qualified path: openzeppelin_testing::constants

Modules

Constants

Free functions

Type aliases

Traits

Impls

Modules

Modules

stark

Fully qualified path: openzeppelin_testing::constants::stark

Free functions

Free functions

Free functions

KEY_PAIR

Fully qualified path: openzeppelin_testing::constants::stark::KEY_PAIR

pub fn KEY_PAIR() -> KeyPair<felt252, felt252>

KEY_PAIR_2

Fully qualified path: openzeppelin_testing::constants::stark::KEY_PAIR_2

pub fn KEY_PAIR_2() -> KeyPair<felt252, felt252>

secp256k1

Fully qualified path: openzeppelin_testing::constants::secp256k1

Free functions

Free functions

Free functions

KEY_PAIR

Fully qualified path: openzeppelin_testing::constants::secp256k1::KEY_PAIR

pub fn KEY_PAIR() -> KeyPair<u256, Secp256k1Point>

KEY_PAIR_2

Fully qualified path: openzeppelin_testing::constants::secp256k1::KEY_PAIR_2

pub fn KEY_PAIR_2() -> KeyPair<u256, Secp256k1Point>

secp256r1

Fully qualified path: openzeppelin_testing::constants::secp256r1

Free functions

Free functions

Free functions

KEY_PAIR

Fully qualified path: openzeppelin_testing::constants::secp256r1::KEY_PAIR

pub fn KEY_PAIR() -> KeyPair<u256, Secp256r1Point>

KEY_PAIR_2

Fully qualified path: openzeppelin_testing::constants::secp256r1::KEY_PAIR_2

pub fn KEY_PAIR_2() -> KeyPair<u256, Secp256r1Point>

Constants

Constants

QUERY_OFFSET

Fully qualified path: openzeppelin_testing::constants::QUERY_OFFSET

pub const QUERY_OFFSET: felt252 = 340282366920938463463374607431768211456;

QUERY_VERSION

Fully qualified path: openzeppelin_testing::constants::QUERY_VERSION

pub const QUERY_VERSION: felt252 = 340282366920938463463374607431768211457;

DECIMALS

Fully qualified path: openzeppelin_testing::constants::DECIMALS

pub const DECIMALS: u8 = 18;

SUPPLY

Fully qualified path: openzeppelin_testing::constants::SUPPLY

pub const SUPPLY: u256 = 2000;

VALUE

Fully qualified path: openzeppelin_testing::constants::VALUE

pub const VALUE: u256 = 300;

FELT_VALUE

Fully qualified path: openzeppelin_testing::constants::FELT_VALUE

pub const FELT_VALUE: felt252 = 331843979267830117586245;

ROLE

Fully qualified path: openzeppelin_testing::constants::ROLE

pub const ROLE: felt252 = 1380928581;

TIMESTAMP

Fully qualified path: openzeppelin_testing::constants::TIMESTAMP

pub const TIMESTAMP: u64 = 1704067200;

BLOCK_NUMBER

Fully qualified path: openzeppelin_testing::constants::BLOCK_NUMBER

pub const BLOCK_NUMBER: u64 = 1234567;

OTHER_ROLE

Fully qualified path: openzeppelin_testing::constants::OTHER_ROLE

pub const OTHER_ROLE: felt252 = 374621686308007054363717;

CHAIN_ID

Fully qualified path: openzeppelin_testing::constants::CHAIN_ID

pub const CHAIN_ID: felt252 = 4848196781967624516;

TOKEN_ID

Fully qualified path: openzeppelin_testing::constants::TOKEN_ID

pub const TOKEN_ID: u256 = 21;

TOKEN_ID_2

Fully qualified path: openzeppelin_testing::constants::TOKEN_ID_2

pub const TOKEN_ID_2: u256 = 121;

TOKEN_VALUE

Fully qualified path: openzeppelin_testing::constants::TOKEN_VALUE

pub const TOKEN_VALUE: u256 = 42;

TOKEN_VALUE_2

Fully qualified path: openzeppelin_testing::constants::TOKEN_VALUE_2

pub const TOKEN_VALUE_2: u256 = 142;

PUBKEY

Fully qualified path: openzeppelin_testing::constants::PUBKEY

pub const PUBKEY: felt252 = 88327114671449;

NEW_PUBKEY

Fully qualified path: openzeppelin_testing::constants::NEW_PUBKEY

pub const NEW_PUBKEY: felt252 =
    1098377157898629946571614844583422311425675589668982787103879603004212846503;

DAPP_NAME

Fully qualified path: openzeppelin_testing::constants::DAPP_NAME

pub const DAPP_NAME: felt252 = 1259084946993116695877;

DAPP_VERSION

Fully qualified path: openzeppelin_testing::constants::DAPP_VERSION

pub const DAPP_VERSION: felt252 = 21123940118054325539509456718;

SALT

Fully qualified path: openzeppelin_testing::constants::SALT

pub const SALT: felt252 = 1396788308;

SUCCESS

Fully qualified path: openzeppelin_testing::constants::SUCCESS

pub const SUCCESS: felt252 = 23456170446771027;

FAILURE

Fully qualified path: openzeppelin_testing::constants::FAILURE

pub const FAILURE: felt252 = 19775031438824005;

MIN_TRANSACTION_VERSION

Fully qualified path: openzeppelin_testing::constants::MIN_TRANSACTION_VERSION

pub const MIN_TRANSACTION_VERSION: felt252 = 1;

TRANSACTION_HASH

Fully qualified path: openzeppelin_testing::constants::TRANSACTION_HASH

pub const TRANSACTION_HASH: felt252 = 112082244550519856607465155747721073480;

ADMIN

Fully qualified path: openzeppelin_testing::constants::ADMIN

pub const ADMIN: ContractAddress = 'ADMIN'.as_address(); // = 280318789966

AUTHORIZED

Fully qualified path: openzeppelin_testing::constants::AUTHORIZED

pub const AUTHORIZED: ContractAddress = 'AUTHORIZED'.as_address(); // = 308527867824104596456772

ZERO

Fully qualified path: openzeppelin_testing::constants::ZERO

pub const ZERO: ContractAddress = 0.as_address(); // = 0

CALLER

Fully qualified path: openzeppelin_testing::constants::CALLER

pub const CALLER: ContractAddress = 'CALLER'.as_address(); // = 73947732002130

OWNER

Fully qualified path: openzeppelin_testing::constants::OWNER

pub const OWNER: ContractAddress = 'OWNER'.as_address(); // = 340767163730

NEW_OWNER

Fully qualified path: openzeppelin_testing::constants::NEW_OWNER

pub const NEW_OWNER: ContractAddress = 'NEW_OWNER'.as_address(); // = 1443842604855307683154

OTHER

Fully qualified path: openzeppelin_testing::constants::OTHER

pub const OTHER: ContractAddress = 'OTHER'.as_address(); // = 340716438866

OTHER_ADMIN

Fully qualified path: openzeppelin_testing::constants::OTHER_ADMIN

pub const OTHER_ADMIN: ContractAddress = 'OTHER_ADMIN'.as_address(); // = 95903151694849732718184782

SPENDER

Fully qualified path: openzeppelin_testing::constants::SPENDER

pub const SPENDER: ContractAddress = 'SPENDER'.as_address(); // = 23450681663046994

RECIPIENT

Fully qualified path: openzeppelin_testing::constants::RECIPIENT

pub const RECIPIENT: ContractAddress = 'RECIPIENT'.as_address(); // = 1517623927465415364180

OPERATOR

Fully qualified path: openzeppelin_testing::constants::OPERATOR

pub const OPERATOR: ContractAddress = 'OPERATOR'.as_address(); // = 5715144146718838610

DELEGATOR

Fully qualified path: openzeppelin_testing::constants::DELEGATOR

pub const DELEGATOR: ContractAddress = 'DELEGATOR'.as_address(); // = 1259372039271437586258

DELEGATEE

Fully qualified path: openzeppelin_testing::constants::DELEGATEE

pub const DELEGATEE: ContractAddress = 'DELEGATEE'.as_address(); // = 1259372039271437583685

TIMELOCK

Fully qualified path: openzeppelin_testing::constants::TIMELOCK

pub const TIMELOCK: ContractAddress = 'TIMELOCK'.as_address(); // = 6073470532514169675

VOTES_TOKEN

Fully qualified path: openzeppelin_testing::constants::VOTES_TOKEN

pub const VOTES_TOKEN: ContractAddress = 'VOTES_TOKEN'
    .as_address(); // = 104342241960948229995185486

ALICE

Fully qualified path: openzeppelin_testing::constants::ALICE

pub const ALICE: ContractAddress = 'ALICE'.as_address(); // = 280452744005

BOB

Fully qualified path: openzeppelin_testing::constants::BOB

pub const BOB: ContractAddress = 'BOB'.as_address(); // = 4345666

CHARLIE

Fully qualified path: openzeppelin_testing::constants::CHARLIE

pub const CHARLIE: ContractAddress = 'CHARLIE'.as_address(); // = 18938268830419269

CLASS_HASH_ZERO

Fully qualified path: openzeppelin_testing::constants::CLASS_HASH_ZERO

pub const CLASS_HASH_ZERO: ClassHash = 0.try_into().unwrap(); // = 0

Free functions

Free functions

NAME

Fully qualified path: openzeppelin_testing::constants::NAME

pub fn NAME() -> ByteArray

SYMBOL

Fully qualified path: openzeppelin_testing::constants::SYMBOL

pub fn SYMBOL() -> ByteArray

BASE_URI

Fully qualified path: openzeppelin_testing::constants::BASE_URI

pub fn BASE_URI() -> ByteArray

BASE_URI_2

Fully qualified path: openzeppelin_testing::constants::BASE_URI_2

pub fn BASE_URI_2() -> ByteArray

DATA

Fully qualified path: openzeppelin_testing::constants::DATA

pub fn DATA(success: bool) -> Span<felt252>

EMPTY_DATA

Fully qualified path: openzeppelin_testing::constants::EMPTY_DATA

pub fn EMPTY_DATA() -> Span<felt252>

Type aliases

Type aliases

EthPublicKey

Fully qualified path: openzeppelin_testing::constants::EthPublicKey

pub type EthPublicKey = Secp256k1Point;

Traits

Traits

AsAddressTrait

Fully qualified path: openzeppelin_testing::constants::AsAddressTrait

pub trait AsAddressTrait

Trait functions

as_address

Converts a felt252 to a ContractAddress as a constant function.

Requirements:

  • value must be a valid contract address.

Fully qualified path: openzeppelin_testing::constants::AsAddressTrait::as_address

fn as_address(self: felt252) -> ContractAddress

Impls

Impls

AsAddressImpl

Fully qualified path: openzeppelin_testing::constants::AsAddressImpl

pub impl AsAddressImpl of AsAddressTrait;

Impl functions

as_address

Converts a felt252 to a ContractAddress as a constant function.

Requirements:

  • value must be a valid contract address.

Fully qualified path: openzeppelin_testing::constants::AsAddressImpl::as_address

fn as_address(self: felt252) -> ContractAddress

deployment

Fully qualified path: openzeppelin_testing::deployment

Free functions

declare_classDeclares a contract with a snforge_std::declare call and unwraps the result. This function will skip declaration and just return the ContractClass if the contract is…
deployDeploys an instance of a contract and unwraps the result.
deploy_atDeploys a contract at the given address and unwraps the result.
deploy_another_atDeploys a contract using the class hash from another already-deployed contract.
declare_and_deployCombines the declaration of a class and the deployment of a contract into one function call. This function will skip declaration if the contract is already declared (the result of…
declare_and_deploy_atCombines the declaration of a class and the deployment of a contract at the given address into one function call. This function will skip declaration if the contract is…

Free functions

Free functions

declare_classDeclares a contract with a snforge_std::declare call and unwraps the result. This function will skip declaration and just return the ContractClass if the contract is…
deployDeploys an instance of a contract and unwraps the result.
deploy_atDeploys a contract at the given address and unwraps the result.
deploy_another_atDeploys a contract using the class hash from another already-deployed contract.
declare_and_deployCombines the declaration of a class and the deployment of a contract into one function call. This function will skip declaration if the contract is already declared (the result of…
declare_and_deploy_atCombines the declaration of a class and the deployment of a contract at the given address into one function call. This function will skip declaration if the contract is…

declare_class

Declares a contract with a snforge_std::declare call and unwraps the result. This function will skip declaration and just return the ContractClass if the contract is already declared (the result of snforge_std::declare call is of type DeclareResult::AlreadyDeclared)

Fully qualified path: openzeppelin_testing::deployment::declare_class

pub fn declare_class(contract_name: ByteArray) -> ContractClass

deploy

Deploys an instance of a contract and unwraps the result.

Fully qualified path: openzeppelin_testing::deployment::deploy

pub fn deploy(contract_class: ContractClass, calldata: Array<felt252>) -> ContractAddress

deploy_at

Deploys a contract at the given address and unwraps the result.

Fully qualified path: openzeppelin_testing::deployment::deploy_at

pub fn deploy_at(
    contract_class: ContractClass, target_address: ContractAddress, calldata: Array<felt252>,
)

deploy_another_at

Deploys a contract using the class hash from another already-deployed contract.

Fully qualified path: openzeppelin_testing::deployment::deploy_another_at

pub fn deploy_another_at(
    existing: ContractAddress, target_address: ContractAddress, calldata: Array<felt252>,
)

declare_and_deploy

Combines the declaration of a class and the deployment of a contract into one function call. This function will skip declaration if the contract is already declared (the result of snforge_std::declare call is of type DeclareResult::AlreadyDeclared)

Fully qualified path: openzeppelin_testing::deployment::declare_and_deploy

pub fn declare_and_deploy(contract_name: ByteArray, calldata: Array<felt252>) -> ContractAddress

declare_and_deploy_at

Combines the declaration of a class and the deployment of a contract at the given address into one function call. This function will skip declaration if the contract is already declared (the result of snforge_std::declare call is of type DeclareResult::AlreadyDeclared)

Fully qualified path: openzeppelin_testing::deployment::declare_and_deploy_at

pub fn declare_and_deploy_at(
    contract_name: ByteArray, target_address: ContractAddress, calldata: Array<felt252>,
)

events

Fully qualified path: openzeppelin_testing::events

Free functions

spy_eventsCreates a new EventSpyQueue instance.

Structs

EventSpyQueueA wrapper around the EventSpy structure to allow treating the events as a queue.

Traits

Impls

EventSpyQueueImpl
ExpectedEventThe ExpectedEvent trait provides a convenient API for constructing expected events in tests. This implementation is generated by the #[generate_trait] macro and offers three methods:…
EventSpyQueueDebugImpl

Free functions

Free functions

spy_eventsCreates a new EventSpyQueue instance.

spy_events

Creates a new EventSpyQueue instance.

Fully qualified path: openzeppelin_testing::events::spy_events

pub fn spy_events() -> EventSpyQueue

Structs

Structs

EventSpyQueueA wrapper around the EventSpy structure to allow treating the events as a queue.

EventSpyQueue

A wrapper around the EventSpy structure to allow treating the events as a queue.

Fully qualified path: openzeppelin_testing::events::EventSpyQueue

[derive(Drop, Serde)]
pub struct EventSpyQueue { /* private fields */ }

Traits

Traits

EventSpyExt

Fully qualified path: openzeppelin_testing::events::EventSpyExt

pub trait EventSpyExt

Trait functions

get_events

Fully qualified path: openzeppelin_testing::events::EventSpyExt::get_events

fn get_events(ref self: EventSpyQueue) -> Events

assert_only_event

Ensures that from_address has emitted only the expected_event and no additional events.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::assert_only_event

fn assert_only_event<T, +starknet::Event<T>, +Drop<T>>(
    ref self: EventSpyQueue, from_address: ContractAddress, expected_event: T,
)

assert_emitted_single

Ensures that from_address has emitted the expected_event. This assertion increments the event offset which essentially consumes the event in the first position of the offset. This means that events must be asserted in the order that they’re emitted.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::assert_emitted_single

fn assert_emitted_single<T, +starknet::Event<T>, +Drop<T>>(
    ref self: EventSpyQueue, from_address: ContractAddress, expected_event: T,
)

drop_event

Removes a single event from the queue. If the queue is empty, the function will panic.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::drop_event

fn drop_event(ref self: EventSpyQueue)

drop_n_events

Removes number_to_drop events from the queue. If the queue is empty, the function will panic.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::drop_n_events

fn drop_n_events(ref self: EventSpyQueue, number_to_drop: u32)

drop_all_events

Removes all events remaining on the queue. If the queue is empty already, the function will do nothing.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::drop_all_events

fn drop_all_events(ref self: EventSpyQueue)

assert_no_events_left

Ensures that there are no events remaining on the queue.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::assert_no_events_left

fn assert_no_events_left(ref self: EventSpyQueue)

assert_no_events_left_from

Ensures that there are no events emitted from the given address remaining on the queue.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::assert_no_events_left_from

fn assert_no_events_left_from(ref self: EventSpyQueue, from_address: ContractAddress)

count_events_from

Counts the number of remaining events emitted from the given address.

Fully qualified path: openzeppelin_testing::events::EventSpyExt::count_events_from

fn count_events_from(ref self: EventSpyQueue, from_address: ContractAddress) -> u32

ExpectedEventTrait

Fully qualified path: openzeppelin_testing::events::ExpectedEventTrait

pub trait ExpectedEventTrait

Trait functions

new

Creates a new Event with empty keys and data arrays.

Fully qualified path: openzeppelin_testing::events::ExpectedEventTrait::new

fn new() -> Event

key

Serializes the given value and appends it to the keys array.

Fully qualified path: openzeppelin_testing::events::ExpectedEventTrait::key

fn key<T, +Serde<T>, +Drop<T>>(self: Event, value: T) -> Event

data

Serializes the given value and appends it to the data array.

Fully qualified path: openzeppelin_testing::events::ExpectedEventTrait::data

fn data<T, +Serde<T>, +Drop<T>>(self: Event, value: T) -> Event

EventSpyQueueDebug

Fully qualified path: openzeppelin_testing::events::EventSpyQueueDebug

pub trait EventSpyQueueDebug

Trait functions

Prints out all events remaining on the queue.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueDebug::print_all_events

fn print_all_events(ref self: EventSpyQueue)

Prints out events on the queue emitted from the given address.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueDebug::print_events_from

fn print_events_from(ref self: EventSpyQueue, from_address: ContractAddress)

Impls

Impls

EventSpyQueueImpl
ExpectedEventThe ExpectedEvent trait provides a convenient API for constructing expected events in tests. This implementation is generated by the #[generate_trait] macro and offers three methods:…
EventSpyQueueDebugImpl

EventSpyQueueImpl

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl

pub impl EventSpyQueueImpl of EventSpyExt;

Impl functions

get_events

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::get_events

fn get_events(ref self: EventSpyQueue) -> Events

assert_only_event

Ensures that from_address has emitted only the expected_event and no additional events.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::assert_only_event

fn assert_only_event(ref self: EventSpyQueue, from_address: ContractAddress, expected_event: T)

assert_emitted_single

Ensures that from_address has emitted the expected_event. This assertion increments the event offset which essentially consumes the event in the first position of the offset. This means that events must be asserted in the order that they’re emitted.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::assert_emitted_single

fn assert_emitted_single(ref self: EventSpyQueue, from_address: ContractAddress, expected_event: T)

drop_event

Removes a single event from the queue. If the queue is empty, the function will panic.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::drop_event

fn drop_event(ref self: EventSpyQueue)

drop_n_events

Removes number_to_drop events from the queue. If the queue is empty, the function will panic.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::drop_n_events

fn drop_n_events(ref self: EventSpyQueue, number_to_drop: u32)

drop_all_events

Removes all events remaining on the queue. If the queue is empty already, the function will do nothing.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::drop_all_events

fn drop_all_events(ref self: EventSpyQueue)

assert_no_events_left

Ensures that there are no events remaining on the queue.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::assert_no_events_left

fn assert_no_events_left(ref self: EventSpyQueue)

assert_no_events_left_from

Ensures that there are no events emitted from the given address remaining on the queue.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::assert_no_events_left_from

fn assert_no_events_left_from(ref self: EventSpyQueue, from_address: ContractAddress)

count_events_from

Counts the number of remaining events emitted from the given address.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueImpl::count_events_from

fn count_events_from(ref self: EventSpyQueue, from_address: ContractAddress) -> u32

ExpectedEvent

The ExpectedEvent trait provides a convenient API for constructing expected events in tests.

This implementation is generated by the #[generate_trait] macro and offers three methods:

  • new(): creates a fresh Event with empty keys and data arrays.
  • key(value): serializes the given value and appends it to the keys array.
  • data(value): serializes the given value and appends it to the data array.

By using these methods, you can construct events in a fluent style without manually managing the keys and data arrays. For example, instead of:

let mut keys = array![];
keys.append_serde(selector!("Transfer")); // event selector
keys.append_serde(from);                  // key #1
keys.append_serde(to);                    // key #2

let mut data = array![];
data.append_serde(value);                 // non-key data
let expected = Event { keys, data };

spy.assert_emitted(
    @array![(contract_address, expected)],
);

you can now write:

let expected = ExpectedEvent::new()
    .key(selector!("Transfer"))
    .key(from)
    .key(to)
    .data(value);
spy.assert_emitted(
    @array![(contract_address, expected)]
);

NOTE: key and data accept any serializable value as input.

Fully qualified path: openzeppelin_testing::events::ExpectedEvent

pub impl ExpectedEvent of ExpectedEventTrait;

Impl functions

new

Creates a new Event with empty keys and data arrays.

Fully qualified path: openzeppelin_testing::events::ExpectedEvent::new

fn new() -> Event

key

Serializes the given value and appends it to the keys array.

Fully qualified path: openzeppelin_testing::events::ExpectedEvent::key

fn key(self: Event, value: T) -> Event

data

Serializes the given value and appends it to the data array.

Fully qualified path: openzeppelin_testing::events::ExpectedEvent::data

fn data(self: Event, value: T) -> Event

EventSpyQueueDebugImpl

Fully qualified path: openzeppelin_testing::events::EventSpyQueueDebugImpl

pub impl EventSpyQueueDebugImpl of EventSpyQueueDebug;

Impl functions

Prints out all events remaining on the queue.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueDebugImpl::print_all_events

fn print_all_events(ref self: EventSpyQueue)

Prints out events on the queue emitted from the given address.

Fully qualified path: openzeppelin_testing::events::EventSpyQueueDebugImpl::print_events_from

fn print_events_from(ref self: EventSpyQueue, from_address: ContractAddress)

signing

Fully qualified path: openzeppelin_testing::signing

Free functions

get_stark_keys_fromBuilds a Stark Key Pair from a private key represented by a felt252 value.
get_secp256k1_keys_fromBuilds a Secp256k1 Key Pair from a private key represented by a u256 value.
get_secp256r1_keys_fromBuilds a Secp256r1 Key Pair from a private key represented by a u256 value.

Type aliases

Traits

SerializedSigningA helper trait that facilitates converting a signature into a serialized format.

Impls

Free functions

Free functions

get_stark_keys_fromBuilds a Stark Key Pair from a private key represented by a felt252 value.
get_secp256k1_keys_fromBuilds a Secp256k1 Key Pair from a private key represented by a u256 value.
get_secp256r1_keys_fromBuilds a Secp256r1 Key Pair from a private key represented by a u256 value.

get_stark_keys_from

Builds a Stark Key Pair from a private key represented by a felt252 value.

Fully qualified path: openzeppelin_testing::signing::get_stark_keys_from

pub fn get_stark_keys_from(private_key: felt252) -> KeyPair<felt252, felt252>

get_secp256k1_keys_from

Builds a Secp256k1 Key Pair from a private key represented by a u256 value.

Fully qualified path: openzeppelin_testing::signing::get_secp256k1_keys_from

pub fn get_secp256k1_keys_from(private_key: u256) -> KeyPair<u256, Secp256k1Point>

get_secp256r1_keys_from

Builds a Secp256r1 Key Pair from a private key represented by a u256 value.

Fully qualified path: openzeppelin_testing::signing::get_secp256r1_keys_from

pub fn get_secp256r1_keys_from(private_key: u256) -> KeyPair<u256, Secp256r1Point>

Type aliases

Type aliases

StarkKeyPair

Fully qualified path: openzeppelin_testing::signing::StarkKeyPair

pub type StarkKeyPair = KeyPair<felt252, felt252>;

Secp256k1KeyPair

Fully qualified path: openzeppelin_testing::signing::Secp256k1KeyPair

pub type Secp256k1KeyPair = KeyPair<u256, Secp256k1Point>;

Secp256r1KeyPair

Fully qualified path: openzeppelin_testing::signing::Secp256r1KeyPair

pub type Secp256r1KeyPair = KeyPair<u256, Secp256r1Point>;

Traits

Traits

SerializedSigningA helper trait that facilitates converting a signature into a serialized format.

SerializedSigning

A helper trait that facilitates converting a signature into a serialized format.

Fully qualified path: openzeppelin_testing::signing::SerializedSigning

pub trait SerializedSigning<KP, M>

Trait functions

serialized_sign

Fully qualified path: openzeppelin_testing::signing::SerializedSigning::serialized_sign

fn serialized_sign(self: KP, msg: M) -> Array<felt252>

Impls

Impls

StarkSerializedSigning

Fully qualified path: openzeppelin_testing::signing::StarkSerializedSigning

pub impl StarkSerializedSigning of SerializedSigning<KeyPair<felt252, felt252>, felt252>;

Impl functions

serialized_sign

Fully qualified path: openzeppelin_testing::signing::StarkSerializedSigning::serialized_sign

fn serialized_sign(self: KeyPair<felt252, felt252>, msg: felt252) -> Array<felt252>

Secp256k1SerializedSigning

Fully qualified path: openzeppelin_testing::signing::Secp256k1SerializedSigning

pub impl Secp256k1SerializedSigning of SerializedSigning<KeyPair<u256, Secp256k1Point>, u256>;

Impl functions

serialized_sign

Fully qualified path: openzeppelin_testing::signing::Secp256k1SerializedSigning::serialized_sign

fn serialized_sign(self: KeyPair<u256, Secp256k1Point>, msg: u256) -> Array<felt252>

Secp256r1SerializedSigning

Fully qualified path: openzeppelin_testing::signing::Secp256r1SerializedSigning

pub impl Secp256r1SerializedSigning of SerializedSigning<KeyPair<u256, Secp256r1Point>, u256>;

Impl functions

serialized_sign

Fully qualified path: openzeppelin_testing::signing::Secp256r1SerializedSigning::serialized_sign

fn serialized_sign(self: KeyPair<u256, Secp256r1Point>, msg: u256) -> Array<felt252>