Skip to content

Commit

Permalink
Additional protocol tests and use of error checking functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Jan 3, 2024
1 parent 1fb6a3f commit d9acc9a
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions unit-tests/tests/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Protocol related behavior tests.

mod utils;
use ociswap_adapter::OciswapPoolInterfaceScryptoTestStub;
use utils::*;

use olympus::{LiquidityPosition, LockupPeriod, Percent};
Expand All @@ -21,7 +22,7 @@ fn cant_add_a_pool_with_no_corresponding_adapter() -> Result<(), RuntimeError> {
let rtn = olympus.add_allowed_pool(FAUCET, env);

// Assert
assert!(is_wasm_panic(&rtn));
assert_is_add_allowed_pool_no_adapter_found_for_pool(&rtn);

Ok(())
}
Expand Down Expand Up @@ -53,7 +54,44 @@ fn cant_open_a_liquidity_position_when_opening_is_disabled(
);

// Assert
assert!(is_wasm_panic(&rtn));
assert_is_open_liquidity_position_opening_disabled_error(&rtn);

Ok(())
}

#[test]
fn cant_open_a_liquidity_position_to_a_registered_pool_with_no_adapter(
) -> Result<(), RuntimeError> {
// Arrange
let Environment {
environment: ref mut env,
mut resources,
mut protocol,
ociswap,
} = Environment::new()?;
protocol.olympus.remove_pool_adapter(
OciswapPoolInterfaceScryptoTestStub::blueprint_id(ociswap.package),
env,
)?;

protocol
.oracle
.set_price(resources.bitcoin.0, XRD, dec!(1), env)?;

// Act
let bitcoin_contribution_amount = dec!(0.1);
let bitcoin_bucket = resources
.bitcoin
.mint_fungible(bitcoin_contribution_amount, env)?;
let rtn = protocol.olympus.open_liquidity_position(
ociswap.bitcoin_pool.try_into().unwrap(),
FungibleBucket(bitcoin_bucket),
LockupPeriod::from_months(6),
env,
);

// Assert
assert_is_open_liquidity_position_no_adapter_error(&rtn);

Ok(())
}
Expand Down

0 comments on commit d9acc9a

Please sign in to comment.