Skip to content

Commit

Permalink
[Tests]: Additional exchange specific tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Feb 14, 2024
1 parent 05a1066 commit 92ba312
Showing 1 changed file with 77 additions and 2 deletions.
79 changes: 77 additions & 2 deletions tests/tests/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,8 @@ fn cant_add_allowed_pool_of_a_blueprint_that_is_not_registered(
Ok(())
}

// TODO: Maybe we also need a caviarnine version of this.
#[test]
fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resource(
fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resource_ociswap_v1(
) -> Result<(), RuntimeError> {
// Arrange
let Environment {
Expand Down Expand Up @@ -584,6 +583,82 @@ fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resou
Ok(())
}

#[test]
fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resource_ociswap_v2(
) -> Result<(), RuntimeError> {
// Arrange
let Environment {
environment: ref mut env,
mut protocol,
ociswap_v2,
..
} = ScryptoTestEnv::new()?;

let fungible1 = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(100, env)?;
let fungible2 = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(100, env)?;
let (pool, ..) = OciswapV2PoolInterfaceScryptoTestStub::instantiate(
fungible2.resource_address(env)?,
fungible1.resource_address(env)?,
pdec!(1),
dec!(0.03),
dec!(0.03),
FAUCET,
vec![],
FAUCET,
ociswap_v2.package,
env,
)?;

// Act
let rtn = protocol
.ignition
.add_allowed_pool(pool.try_into().unwrap(), env);

// Assert
assert_is_ignition_neither_pool_resource_is_protocol_resource_error(&rtn);

Ok(())
}

#[test]
fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resource_caviarnine_v1(
) -> Result<(), RuntimeError> {
// Arrange
let Environment {
environment: ref mut env,
mut protocol,
caviarnine_v1,
..
} = ScryptoTestEnv::new()?;

let fungible1 = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(100, env)?;
let fungible2 = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(100, env)?;
let pool = CaviarnineV1PoolInterfaceScryptoTestStub::new(
rule!(allow_all),
rule!(allow_all),
fungible1.resource_address(env)?,
fungible2.resource_address(env)?,
50,
None,
caviarnine_v1.package,
env,
)?;

// Act
let rtn = protocol
.ignition
.add_allowed_pool(pool.try_into().unwrap(), env);

// Assert
assert_is_ignition_neither_pool_resource_is_protocol_resource_error(&rtn);

Ok(())
}

#[test]
fn cant_remove_an_allowed_pool_for_a_blueprint_with_no_registered_adapter(
) -> Result<(), RuntimeError> {
Expand Down

0 comments on commit 92ba312

Please sign in to comment.