generated from veeso-dev/rust-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
151 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use candid::{Encode, Nat}; | ||
use integration_tests::actor::{admin, bob}; | ||
use integration_tests::TestEnv; | ||
|
||
#[test] | ||
#[serial_test::serial] | ||
fn test_should_inspect_is_admin() { | ||
let env = TestEnv::init(); | ||
|
||
assert!(env | ||
.update::<Nat>( | ||
env.ekoke_liquidity_pool_id, | ||
admin(), | ||
"admin_cycles", | ||
Encode!().unwrap(), | ||
) | ||
.is_ok()); | ||
} | ||
|
||
#[test] | ||
#[serial_test::serial] | ||
fn test_should_fail_inspect_admin() { | ||
let env = TestEnv::init(); | ||
// not an admin | ||
assert!(env | ||
.update::<Nat>( | ||
env.ekoke_liquidity_pool_id, | ||
bob(), | ||
"admin_cycles", | ||
Encode!().unwrap(), | ||
) | ||
.is_err()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod deferred; | ||
mod ekoke_erc20_swap; | ||
mod ekoke_liquidity_pool; | ||
mod ekoke_reward_pool; | ||
mod marketplace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
integration-tests/tests/use_case/withdraw_liquidity_pool_icp.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use candid::Nat; | ||
use integration_tests::actor::bob_account; | ||
use integration_tests::client::{EkokeLiquidityPoolClient, IcrcLedgerClient}; | ||
use integration_tests::TestEnv; | ||
|
||
#[test] | ||
#[serial_test::serial] | ||
fn test_as_seller_i_should_withdraw_contract_deposit_after_being_paid() { | ||
let env = TestEnv::init(); | ||
let icp_ledger_client = IcrcLedgerClient::new(env.icp_ledger_id, &env); | ||
let ekoke_liquidity_pool_client = EkokeLiquidityPoolClient::from(&env); | ||
|
||
// withdraw icp to bob | ||
let current_bob_balance = icp_ledger_client.icrc1_balance_of(bob_account()); | ||
let current_pool_balance = | ||
icp_ledger_client.icrc1_balance_of(env.ekoke_liquidity_pool_id.into()); | ||
|
||
let icp_fee = icp_ledger_client.icrc1_fee(); | ||
|
||
let withdraw_amount = Nat::from(1_000_000_000u64); | ||
|
||
let expected_bob_balance = current_bob_balance + withdraw_amount.clone(); | ||
let expected_pool_balance = current_pool_balance - withdraw_amount.clone() - icp_fee; | ||
|
||
assert!(ekoke_liquidity_pool_client | ||
.admin_withdraw_icp(bob_account(), withdraw_amount) | ||
.is_ok()); | ||
|
||
let new_bob_balance = icp_ledger_client.icrc1_balance_of(bob_account()); | ||
let new_pool_balance = icp_ledger_client.icrc1_balance_of(env.ekoke_liquidity_pool_id.into()); | ||
|
||
assert_eq!(new_bob_balance, expected_bob_balance); | ||
assert_eq!(new_pool_balance, expected_pool_balance); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters