Skip to content

Commit

Permalink
drop all events
Browse files Browse the repository at this point in the history
  • Loading branch information
neotheprogramist committed Apr 24, 2024
1 parent 4fca34b commit c5881b0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/dojo-core/src/world_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -619,32 +619,36 @@ fn test_set_facts_registry() {
assert(facts_registry == contract_address_const::<0x875914875149357>(), 'invalid program hash');
}

fn drop_all_events(address: ContractAddress) {
loop {
match starknet::testing::pop_log_raw(address) {
option::Option::Some(_) => {},
option::Option::None => { break; },
};
}
}

#[test]
#[available_gas(6000000)]
fn test_program_hash_event_emit() {
let world = deploy_world();
drop_all_events(world.contract_address);
let config = IConfigDispatcher { contract_address: world.contract_address };

config.set_program_hash(program_hash: 98758347158781475198374598718743);

// pop value from the logs for the assertion to pass
let _: Option<ProgramHashUpdate> = starknet::testing::pop_log(world.contract_address);

assert_eq!(starknet::testing::pop_log(world.contract_address),
Option::Some(ProgramHashUpdate { program_hash: 98758347158781475198374598718743 }));
}
#[test]
#[available_gas(6000000)]
fn test_facts_registry_event_emit() {
let world = deploy_world();
drop_all_events(world.contract_address);
let config = IConfigDispatcher { contract_address: world.contract_address };

config.set_facts_registry(contract_address_const::<0x12>());

// pop value from the logs for the assertion to pass
let _: Option<FactsRegistryUpdate> = starknet::testing::pop_log(world.contract_address);

assert_eq!(starknet::testing::pop_log(world.contract_address),
Option::Some(FactsRegistryUpdate{ address: contract_address_const::<0x12>()}));
}

0 comments on commit c5881b0

Please sign in to comment.