Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Sep 28, 2023
1 parent 411d6f9 commit 91096d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
1 change: 1 addition & 0 deletions contracts/registry/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub(crate) fn emit_iah_flag_accounts(flag: crate::AccountFlag, accounts: Vec<Acc
let event = match flag {
AccountFlag::Blacklisted => "flag_blacklisted",
AccountFlag::Verified => "flag_verified",
AccountFlag::GovBan => "flag_govban",
};
emit_iah_event(EventPayload {
event,
Expand Down
27 changes: 9 additions & 18 deletions contracts/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,13 @@ impl Contract {

pub(crate) fn _transfer_flag(&mut self, from: &AccountId, recipient: &AccountId) {
if let Some(flag_from) = self.flagged.get(from) {
match self.flagged.get(recipient) {
Some(AccountFlag::Verified) => require!(
flag_from != AccountFlag::Blacklisted,
"can't transfer soul from a blacklisted account to a verified account"
),
Some(AccountFlag::Blacklisted) => require!(
flag_from != AccountFlag::Verified,
"can't transfer soul from a verified account to a blacklisted account"
),
None => {
self.flagged.insert(recipient, &flag_from);
}
if let Some(flag_to) = self.flagged.get(recipient) {
require!(
flag_from == flag_to,
"can't transfer soul when there is a flag conflict"
)
} else {
self.flagged.insert(recipient, &flag_from);
}
}
}
Expand Down Expand Up @@ -2966,9 +2961,7 @@ mod tests {
}

#[test]
#[should_panic(
expected = "can't transfer soul from a blacklisted account to a verified account"
)]
#[should_panic(expected = "can't transfer soul when there is a flag conflict")]
fn flagged_soul_transfer() {
let (mut ctx, mut ctr) = setup(&issuer1(), 2 * MINT_DEPOSIT);

Expand Down Expand Up @@ -3005,9 +2998,7 @@ mod tests {
}

#[test]
#[should_panic(
expected = "can't transfer soul from a verified account to a blacklisted account"
)]
#[should_panic(expected = "can't transfer soul when there is a flag conflict")]
fn flagged_soul_transfer2() {
let (mut ctx, mut ctr) = setup(&issuer1(), 2 * MINT_DEPOSIT);

Expand Down

0 comments on commit 91096d5

Please sign in to comment.