-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use starknet::ContractAddress; | ||
|
||
use snforge_std::{ | ||
declare, ContractClassTrait, cheat_caller_address, CheatSpan, spy_events, | ||
EventSpyAssertionsTrait, Event, EventSpyTrait | ||
}; | ||
use push_comm::{PushComm, IPushCommDispatcher, IPushCommDispatcherTrait}; | ||
use super::common::{USER_1, deploy_contract, CHAIN_NAME, CHAIN_ID}; | ||
|
||
#[test] | ||
fn test_verify_channel_alias() { | ||
let contract_address = deploy_contract(); | ||
let push_comm = IPushCommDispatcher { contract_address }; | ||
let channel_address: felt252 = 'some address'; | ||
|
||
let mut spy = spy_events(); | ||
|
||
// user sets the alias | ||
cheat_caller_address(contract_address, USER_1(), CheatSpan::TargetCalls(1)); | ||
push_comm.verify_channel_alias(channel_address); | ||
|
||
// assert on the vent | ||
let events = spy.get_events(); | ||
assert(events.events.len() == 1, 'There should be one event'); | ||
|
||
let (from_addrs, event) = events.events.at(0); | ||
assert(from_addrs == @contract_address, 'Emitted from wrong address'); | ||
assert(event.keys.at(0) == @selector!("ChannelAlias"), 'Wrong event was emitted'); | ||
} |