Skip to content

Commit

Permalink
Merge pull request #30 from keep-starknet-strange/feat/test_is_pauseable
Browse files Browse the repository at this point in the history
adds test for is pauseable
  • Loading branch information
ZackAttax authored Feb 5, 2025
2 parents 5a84d07 + d3066d0 commit 0d6d927
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use openzeppelin_access::ownable::interface::{
};
use openzeppelin_upgrades::upgradeable::UpgradeableComponent;
use openzeppelin_security::pausable::PausableComponent;
use openzeppelin_security::pausable::PausableComponent::{PausableImpl, InternalImpl};
use openzeppelin_security::interface::{IPausableDispatcher, IPausableDispatcherTrait};
use openzeppelin_token::erc1155::ERC1155Component;
use openzeppelin_token::erc1155::interface::{IERC1155Dispatcher, IERC1155DispatcherTrait};
use tokenized_bond::utils::constants::{
Expand All @@ -24,6 +26,19 @@ use utils::{
upgrade_class_hash,
};

#[test]
fn test_is_paused() {
let mut tokenized_bond = ITokenizedBondDispatcher { contract_address: setup() };
let pauseable = IPausableDispatcher { contract_address: tokenized_bond.contract_address };

assert(!pauseable.is_paused(), 'Contract should not be paused');

start_cheat_caller_address(tokenized_bond.contract_address, OWNER());
tokenized_bond.pause();

assert(pauseable.is_paused(), 'Contract should be paused');
}

#[test]
fn test_pause_unpause_functionality() {
let mut spy = spy_events();
Expand Down Expand Up @@ -57,6 +72,16 @@ fn test_pause_not_owner() {
tokenized_bond.pause();
}

#[test]
#[should_panic(expected: 'Pausable: paused')]
fn test_pause_already_paused() {
let mut tokenized_bond = ITokenizedBondDispatcher { contract_address: setup() };

start_cheat_caller_address(tokenized_bond.contract_address, OWNER());
tokenized_bond.pause();
tokenized_bond.pause();
}

#[test]
#[should_panic(expected: 'Caller is not the owner')]
fn test_unpause_not_owner() {
Expand All @@ -65,6 +90,15 @@ fn test_unpause_not_owner() {
tokenized_bond.pause();
}

#[test]
#[should_panic(expected: 'Pausable: not paused')]
fn test_unpause_not_paused() {
let mut tokenized_bond = ITokenizedBondDispatcher { contract_address: setup() };

start_cheat_caller_address(tokenized_bond.contract_address, OWNER());
tokenized_bond.unpause();
}

#[test]
fn test_add_minter() {
let mut spy = spy_events();
Expand Down

0 comments on commit 0d6d927

Please sign in to comment.