-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update ERC20Votes tests * Run linter * Add test helpers for Ownable tests * Migrate Ownable tests * Migrate OwnableTwoStep tests * Migrate Ownable Dual Dispatcher tests * Support event changes in snforge 0.26 * Resolve review issues * Address review comments
- Loading branch information
Showing
6 changed files
with
166 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
pub(crate) mod common; | ||
|
||
mod test_accesscontrol; | ||
mod test_dual_accesscontrol; | ||
// mod test_accesscontrol; | ||
// mod test_dual_accesscontrol; | ||
mod test_dual_ownable; | ||
mod test_ownable; | ||
mod test_ownable_twostep; |
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 |
---|---|---|
@@ -1,28 +1,32 @@ | ||
use openzeppelin::access::ownable::OwnableComponent::OwnershipTransferred; | ||
use openzeppelin::access::ownable::OwnableComponent; | ||
use openzeppelin::tests::utils::EventSpyExt; | ||
use openzeppelin::tests::utils; | ||
use openzeppelin::utils::serde::SerializedAppend; | ||
use snforge_std::EventSpy; | ||
use starknet::ContractAddress; | ||
|
||
pub(crate) fn assert_only_event_ownership_transferred( | ||
contract: ContractAddress, previous_owner: ContractAddress, new_owner: ContractAddress | ||
) { | ||
assert_event_ownership_transferred(contract, previous_owner, new_owner); | ||
utils::assert_no_events_left(contract); | ||
} | ||
|
||
pub(crate) fn assert_event_ownership_transferred( | ||
contract: ContractAddress, previous_owner: ContractAddress, new_owner: ContractAddress | ||
) { | ||
let event = utils::pop_log::<OwnableComponent::Event>(contract).unwrap(); | ||
let expected = OwnableComponent::Event::OwnershipTransferred( | ||
OwnershipTransferred { previous_owner, new_owner } | ||
); | ||
assert!(event == expected); | ||
#[generate_trait] | ||
pub(crate) impl OwnableSpyHelpersImpl of OwnableSpyHelpers { | ||
fn assert_only_event_ownership_transferred( | ||
ref self: EventSpy, | ||
contract: ContractAddress, | ||
previous_owner: ContractAddress, | ||
new_owner: ContractAddress | ||
) { | ||
self.assert_event_ownership_transferred(contract, previous_owner, new_owner); | ||
self.assert_no_events_left_from(contract); | ||
} | ||
|
||
let mut indexed_keys = array![]; | ||
indexed_keys.append_serde(selector!("OwnershipTransferred")); | ||
indexed_keys.append_serde(previous_owner); | ||
indexed_keys.append_serde(new_owner); | ||
utils::assert_indexed_keys(event, indexed_keys.span()); | ||
fn assert_event_ownership_transferred( | ||
ref self: EventSpy, | ||
contract: ContractAddress, | ||
previous_owner: ContractAddress, | ||
new_owner: ContractAddress | ||
) { | ||
let expected = OwnableComponent::Event::OwnershipTransferred( | ||
OwnershipTransferred { previous_owner, new_owner } | ||
); | ||
self.assert_emitted_single(contract, expected); | ||
} | ||
} |
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
Oops, something went wrong.