Skip to content

Commit

Permalink
percentage test
Browse files Browse the repository at this point in the history
  • Loading branch information
dorin-iancu committed Jan 16, 2024
1 parent 1563288 commit 8f0ec73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions contracts/fair-launch/tests/fair_launch_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@

mod tests_common;

use fair_launch::initial_launch::InitialLaunchModule;
use tests_common::*;

#[test]
fn init_test() {
let _ = FairLaunchSetup::new(fair_launch::contract_obj);
}

#[test]
fn percentage_test() {
let mut fr_setup = FairLaunchSetup::new(fair_launch::contract_obj);
fr_setup.b_mock.set_block_nonce(10);
fr_setup
.b_mock
.execute_query(&fr_setup.fl_wrapper, |sc| {
let percentage =
sc.get_fee_percentage(BUY_FEE_PERCENTAGE_START, BUY_FEE_PERCENTAGE_END);
let expected_percentage = BUY_FEE_PERCENTAGE_START - 808; // (BUY_FEE_PERCENTAGE_END - BUY_FEE_PERCENTAGE_START) * 10 blocks / (100 blocks - 1) ~= 808
assert_eq!(percentage, expected_percentage);
})
.assert_ok();
}
8 changes: 5 additions & 3 deletions contracts/fair-launch/tests/tests_common.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(deprecated)]

use fair_launch::{common::Percentage, FairLaunch};
use multiversx_sc::types::Address;
use fair_launch::{common::Percentage, token_info::TokenInfoModule, FairLaunch};
use multiversx_sc::{storage::mappers::StorageTokenWrapper, types::Address};
use multiversx_sc_scenario::{
managed_biguint, rust_biguint,
managed_biguint, managed_token_id, rust_biguint,
testing_framework::{BlockchainStateWrapper, ContractObjWrapper},
DebugApi,
};
Expand Down Expand Up @@ -56,6 +56,8 @@ where
SELL_FEE_PERCENTAGE_START,
SELL_FEE_PERCENTAGE_END,
);
sc.non_fungible_token()
.set_token_id(managed_token_id!(TOKEN_ID));
})
.assert_ok();

Expand Down

0 comments on commit 8f0ec73

Please sign in to comment.