Skip to content

Commit

Permalink
Tests for renouncing ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Sep 12, 2023
1 parent 4778813 commit c232173
Showing 1 changed file with 68 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::Addr;
use cw_tokenfactory_issuer::ContractError;
use cosmwasm_std::{Addr, Uint128};
use cw_tokenfactory_issuer::{msg::ExecuteMsg, ContractError};
use osmosis_test_tube::Account;

use crate::test_env::{TestEnv, TokenfactoryIssuer};
Expand Down Expand Up @@ -52,3 +52,69 @@ fn change_owner_by_non_owner_should_fail() {
))
);
}

#[test]
fn renounce_ownership() {
let env = TestEnv::default();
let owner = &env.test_accs[0];
let non_owner = &env.test_accs[1];
let hook = &env.test_accs[1];

assert_eq!(
Some(Addr::unchecked(owner.address())),
env.cw_tokenfactory_issuer.query_owner().unwrap().owner,
);

// Renounce ownership
env.cw_tokenfactory_issuer
.execute(
&ExecuteMsg::UpdateOwnership(cw_ownable::Action::RenounceOwnership),
&[],
owner,
)
.unwrap();

assert_eq!(
env.cw_tokenfactory_issuer.query_owner().unwrap().owner,
None,
);

// Cannot perform actions that require ownership
assert_eq!(
env.cw_tokenfactory_issuer
.set_minter(&non_owner.address(), 10000, owner)
.unwrap_err(),
TokenfactoryIssuer::execute_error(ContractError::Ownership(
cw_ownable::OwnershipError::NoOwner
))
);
assert_eq!(
env.cw_tokenfactory_issuer
.set_burner(&non_owner.address(), 10000, owner)
.unwrap_err(),
TokenfactoryIssuer::execute_error(ContractError::Ownership(
cw_ownable::OwnershipError::NoOwner
))
);
assert_eq!(
env.cw_tokenfactory_issuer
.force_transfer(
non_owner,
Uint128::new(10000),
owner.address(),
non_owner.address(),
)
.unwrap_err(),
TokenfactoryIssuer::execute_error(ContractError::Ownership(
cw_ownable::OwnershipError::NoOwner
))
);
assert_eq!(
env.cw_tokenfactory_issuer
.set_before_send_hook(hook.address(), owner)
.unwrap(),
TokenfactoryIssuer::execute_error(ContractError::Ownership(
cw_ownable::OwnershipError::NoOwner
))
);
}

0 comments on commit c232173

Please sign in to comment.