Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
jayz22 committed Feb 23, 2023
1 parent 06b5a94 commit 751ff58
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions soroban-env-host/src/test/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl TokenTest {
);
}

fn create_default_trustline(&self, user: &TestSigner) -> LedgerKey {
fn create_default_trustline(&self, user: &TestSigner) -> Rc<LedgerKey> {
self.create_trustline(
&user.account_id(),
&keypair_to_account_id(&self.issuer_key),
Expand Down Expand Up @@ -162,15 +162,19 @@ impl TokenTest {
);
}

fn update_account_flags(&self, key: &LedgerKey, new_flags: u32) {
fn update_account_flags(&self, key: Rc<LedgerKey>, new_flags: u32) {
self.host
.with_mut_storage(|s| match s.get(key, self.host.as_budget()).unwrap().data {
LedgerEntryData::Account(mut account) => {
account.flags = new_flags;
let update = Host::ledger_entry_from_data(LedgerEntryData::Account(account));
s.put(&key, &update, self.host.as_budget())
.with_mut_storage(|s| {
let entry = s.get(Rc::clone(&key), self.host.as_budget()).unwrap();
match entry.data.clone() {
LedgerEntryData::Account(mut account) => {
account.flags = new_flags;
let update =
Host::ledger_entry_from_data(LedgerEntryData::Account(account));
s.put(key, update, self.host.as_budget())
}
_ => unreachable!(),
}
_ => unreachable!(),
})
.unwrap();
}
Expand Down Expand Up @@ -231,16 +235,19 @@ impl TokenTest {
key
}

fn update_trustline_flags(&self, key: &LedgerKey, new_flags: u32) {
fn update_trustline_flags(&self, key: Rc<LedgerKey>, new_flags: u32) {
self.host
.with_mut_storage(|s| match s.get(key, self.host.as_budget()).unwrap().data {
LedgerEntryData::Trustline(mut trustline) => {
trustline.flags = new_flags;
let update =
Host::ledger_entry_from_data(LedgerEntryData::Trustline(trustline));
s.put(&key, &update, self.host.as_budget())
.with_mut_storage(|s| {
let entry = s.get(key.clone(), self.host.as_budget()).unwrap();
match entry.data.clone() {
LedgerEntryData::Trustline(mut trustline) => {
trustline.flags = new_flags;
let update =
Host::ledger_entry_from_data(LedgerEntryData::Trustline(trustline));
s.put(key, update, self.host.as_budget())
}
_ => unreachable!(),
}
_ => unreachable!(),
})
.unwrap();
}
Expand Down Expand Up @@ -893,7 +900,7 @@ fn test_clawback_on_account() {
);

// disable clawback on the trustline
test.update_trustline_flags(&tl_key, 0);
test.update_trustline_flags(Rc::clone(&tl_key), 0);
assert_eq!(
to_contract_err(
token
Expand All @@ -905,7 +912,7 @@ fn test_clawback_on_account() {
);

// enable clawback on the trustline
test.update_trustline_flags(&tl_key, TrustLineFlags::TrustlineClawbackEnabledFlag as u32);
test.update_trustline_flags(tl_key, TrustLineFlags::TrustlineClawbackEnabledFlag as u32);

// Clawback everything else
token
Expand Down Expand Up @@ -934,7 +941,7 @@ fn test_clawback_on_contract() {
.unwrap();

//disable clawback before minting to user_2
test.update_account_flags(&issuer_ledger_key, 0);
test.update_account_flags(Rc::clone(&issuer_ledger_key), 0);
token
.mint(&admin, user_2_addr.clone(), 100_000_000)
.unwrap();
Expand All @@ -959,7 +966,7 @@ fn test_clawback_on_contract() {
);

// enable clawback on the issuer again. Nothing should change for existing balances
test.update_account_flags(&issuer_ledger_key, AccountFlags::ClawbackEnabledFlag as u32);
test.update_account_flags(issuer_ledger_key, AccountFlags::ClawbackEnabledFlag as u32);

token
.clawback(&admin, user_1_addr.clone(), 40_000_000)
Expand Down

0 comments on commit 751ff58

Please sign in to comment.