Skip to content

Commit

Permalink
fix test and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
sparqet committed Jul 26, 2024
1 parent 9b3af8a commit fcfa650
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/test_utils/deposit_setup.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ fn exec_order(
compacted_decimals: array![1, 1],
compacted_min_prices: array![2147483648010000], // 500000, 10000 compacted
compacted_min_prices_indexes: array![0],
compacted_max_prices: array![long_token_price, short_token_price], // 500000, 10000 compacted
compacted_max_prices: array![
long_token_price, short_token_price
], // 500000, 10000 compacted
compacted_max_prices_indexes: array![0],
signatures: array![
array!['signatures1', 'signatures2'].span(), array!['signatures1', 'signatures2'].span()
Expand All @@ -393,10 +395,12 @@ fn exec_order(
};

let keeper_address = contract_address_const::<'keeper'>();
IRoleStoreDispatcher{ contract_address: role_store }.grant_role(keeper_address, role::ORDER_KEEPER);
IRoleStoreDispatcher { contract_address: role_store }
.grant_role(keeper_address, role::ORDER_KEEPER);

stop_prank(order_handler);
start_prank(order_handler, keeper_address);
// TODO add real signatures check on Oracle Account
IOrderHandlerDispatcher{ contract_address: order_handler }.execute_order(key, set_price_params);
IOrderHandlerDispatcher { contract_address: order_handler }
.execute_order(key, set_price_params);
}
14 changes: 10 additions & 4 deletions tests/integration/test_long_integration.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use satoru::exchange::order_handler::{
OrderHandler, IOrderHandlerDispatcher, IOrderHandlerDispatcherTrait
};
use satoru::test_utils::{
tests_lib::{setup, create_market, teardown}, deposit_setup::{deposit_setup}
tests_lib::{setup, create_market, teardown}, deposit_setup::{deposit_setup, exec_order}
};

#[test]
Expand Down Expand Up @@ -412,7 +412,9 @@ fn test_long_increase_decrease_close() {

// Execute the long order.
start_roll(order_handler.contract_address, 1965);
exec_order(order_handler.contract_address, role_store.contract_address, key_long_dec_2, 4000, 1);
exec_order(
order_handler.contract_address, role_store.contract_address, key_long_dec_2, 4000, 1
);
'Long pos close SUCCEEDED'.print();

let first_position_close = data_store.get_position(position_key_1);
Expand Down Expand Up @@ -789,7 +791,9 @@ fn test_takeprofit_long() {

// Execute the swap order.
start_roll(order_handler.contract_address, 1965);
exec_order(order_handler.contract_address, role_store.contract_address, key_long_dec_2, 4000, 1);
exec_order(
order_handler.contract_address, role_store.contract_address, key_long_dec_2, 4000, 1
);
'Long pos close SUCCEEDED'.print();

let first_position_close = data_store.get_position(position_key_1);
Expand Down Expand Up @@ -1166,7 +1170,9 @@ fn test_takeprofit_long_increase_fails() {
let got_order_long_dec = data_store.get_order(key_long_dec_2);
// Execute the swap order.
start_roll(order_handler.contract_address, 1965);
exec_order(order_handler.contract_address, role_store.contract_address, key_long_dec_2, 4000, 1);
exec_order(
order_handler.contract_address, role_store.contract_address, key_long_dec_2, 4000, 1
);
'Long pos close SUCCEEDED'.print();

let first_position_close = data_store.get_position(position_key_1);
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/test_short_integration.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ use satoru::market::{market::{UniqueIdMarketImpl},};
use satoru::exchange::order_handler::{
OrderHandler, IOrderHandlerDispatcher, IOrderHandlerDispatcherTrait
};
use satoru::test_utils::{tests_lib::{setup, create_market, teardown}, deposit_setup::{deposit_setup, exec_order}};
use satoru::test_utils::{
tests_lib::{setup, create_market, teardown}, deposit_setup::{deposit_setup, exec_order}
};
const INITIAL_TOKENS_MINTED: felt252 = 1000;

#[test]
Expand Down Expand Up @@ -294,7 +296,9 @@ fn test_short_increase_decrease_close() {

// Execute the swap order.
start_roll(order_handler.contract_address, 1965);
exec_order(order_handler.contract_address, role_store.contract_address, key_short_dec_2, 3000, 1);
exec_order(
order_handler.contract_address, role_store.contract_address, key_short_dec_2, 3000, 1
);
'Short pos close SUCCEEDED'.print();

let first_position_close = data_store.get_position(position_key_1);
Expand Down

0 comments on commit fcfa650

Please sign in to comment.