-
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.
* Migrate Upgrades tests to Foundry * Update src/tests/upgrades/test_upgradeable.cairo Co-authored-by: Andrew Fleming <[email protected]> * Update src/tests/upgrades/test_upgradeable.cairo Co-authored-by: Andrew Fleming <[email protected]> --------- Co-authored-by: Eric Nordelo <[email protected]> Co-authored-by: Andrew Fleming <[email protected]>
- Loading branch information
1 parent
8fe4f80
commit 6f7130f
Showing
4 changed files
with
48 additions
and
41 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,16 +1,20 @@ | ||
use openzeppelin::tests::utils::constants::ZERO; | ||
use openzeppelin::tests::utils; | ||
use openzeppelin::tests::utils::events::EventSpyExt; | ||
use openzeppelin::upgrades::UpgradeableComponent::Upgraded; | ||
use openzeppelin::upgrades::UpgradeableComponent; | ||
use snforge_std::{EventSpy, EventSpyAssertionsTrait}; | ||
use starknet::{ContractAddress, ClassHash}; | ||
|
||
pub(crate) fn assert_event_upgraded(contract: ContractAddress, class_hash: ClassHash) { | ||
let event = utils::pop_log::<UpgradeableComponent::Event>(contract).unwrap(); | ||
let expected = UpgradeableComponent::Event::Upgraded(Upgraded { class_hash }); | ||
assert!(event == expected); | ||
} | ||
#[generate_trait] | ||
pub(crate) impl UpgradableSpyHelpersImpl of UpgradableSpyHelpers { | ||
fn assert_event_upgraded(ref self: EventSpy, contract: ContractAddress, class_hash: ClassHash) { | ||
let expected = UpgradeableComponent::Event::Upgraded(Upgraded { class_hash }); | ||
self.assert_emitted_single(contract, expected); | ||
} | ||
|
||
pub(crate) fn assert_only_event_upgraded(contract: ContractAddress, class_hash: ClassHash) { | ||
assert_event_upgraded(contract, class_hash); | ||
utils::assert_no_events_left(ZERO()); | ||
fn assert_only_event_upgraded( | ||
ref self: EventSpy, contract: ContractAddress, class_hash: ClassHash | ||
) { | ||
self.assert_event_upgraded(contract, class_hash); | ||
self.assert_no_events_left_from(contract); | ||
} | ||
} |
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