Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading