Skip to content

Commit

Permalink
feat: working on app tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Nov 10, 2023
1 parent f44bdaf commit 43e1da1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/dilazionato/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,17 @@ mod test {

use pretty_assertions::assert_eq;

#[test]
fn test_should_get_tx() {
assert!(SellContract::transaction(Nat::from(1)).is_err());
let id = TxHistory::register_token_mint(&mock_token(1, 1));
assert!(SellContract::transaction(Nat::from(id)).is_ok());
}

#[test]
fn test_should_get_total_transactions() {
assert_eq!(SellContract::total_transactions(), Nat::from(0));
let _ = TxHistory::register_token_mint(&mock_token(1, 1));
assert_eq!(SellContract::total_transactions(), Nat::from(1));
}
}
6 changes: 4 additions & 2 deletions src/dilazionato/src/app/storage/tx_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl TxHistory {
}

/// Register a token mint
pub fn register_token_mint(token: &Token) {
pub fn register_token_mint(token: &Token) -> Nat {
let event = TxEvent {
caller: crate::utils::caller(),
details: vec![
Expand All @@ -44,8 +44,10 @@ impl TxHistory {
};
let id = Self::next_id();
with_tx_history_mut(|tx_history| {
tx_history.insert(id.into(), event.into());
tx_history.insert(id.clone().into(), event.into());
});

id
}

pub fn register_token_burn(token: &Token) -> Nat {
Expand Down

0 comments on commit 43e1da1

Please sign in to comment.