Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
order-book tests
Signed-off-by: Mikhail Tagirov <[email protected]>
  • Loading branch information
wer1st committed Dec 11, 2023
commit eeba63133519a52c839b2b86f80c6420e6c1cfb9
100 changes: 50 additions & 50 deletions pallets/order-book/src/tests/data_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ fn should_work_as_cache() {

let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -168,8 +168,8 @@ fn should_work_as_storage() {

let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -253,8 +253,8 @@ fn should_get_all_limit_orders(data: &mut (impl DataLayer<Runtime> + StoragePush
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_buy_id1 = 1;
Expand Down Expand Up @@ -313,7 +313,7 @@ fn should_get_all_limit_orders(data: &mut (impl DataLayer<Runtime> + StoragePush

let order_sell3 = LimitOrder::<Runtime>::new(
order_sell_id3,
owner.clone(),
owner,
PriceVariant::Sell,
price2,
amount,
Expand Down Expand Up @@ -363,8 +363,8 @@ fn should_insert_limit_order(data: &mut (impl DataLayer<Runtime> + StoragePush))
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_buy_id = 1;
Expand Down Expand Up @@ -516,8 +516,8 @@ fn should_not_insert_limit_order(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let owner = accounts::alice::<Runtime>();
Expand All @@ -526,7 +526,7 @@ fn should_not_insert_limit_order(data: &mut impl DataLayer<Runtime>) {

let mut order = LimitOrder::<Runtime>::new(
0,
owner.clone(),
owner,
PriceVariant::Sell,
price,
amount,
Expand Down Expand Up @@ -569,8 +569,8 @@ fn should_delete_limit_order(data: &mut (impl DataLayer<Runtime> + StoragePush))
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_buy_id1 = 1;
Expand Down Expand Up @@ -1060,8 +1060,8 @@ fn should_not_delete_unknown_limit_order(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -1089,8 +1089,8 @@ fn should_update_limit_order(data: &mut (impl DataLayer<Runtime> + StoragePush))
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -1230,8 +1230,8 @@ fn should_update_limit_order_with_zero_amount(data: &mut (impl DataLayer<Runtime
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -1355,8 +1355,8 @@ fn should_not_update_unknown_limit_order(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -1385,8 +1385,8 @@ fn should_not_update_equal_limit_order(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -1431,8 +1431,8 @@ fn should_not_update_limit_order_with_bigger_amount(data: &mut impl DataLayer<Ru
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let order_id = 1;
Expand Down Expand Up @@ -1475,8 +1475,8 @@ fn get_limit_orders_by_price(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

let buy_price = balance!(10).into();
Expand Down Expand Up @@ -1509,16 +1509,16 @@ fn get_user_limit_orders(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

create_and_fill_order_book::<Runtime>(order_book_id);

let empty_order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: PSWAP.into(),
quote: XOR.into(),
base: PSWAP,
quote: XOR,
};

create_empty_order_book::<Runtime>(empty_order_book_id);
Expand Down Expand Up @@ -1552,24 +1552,24 @@ fn get_all_user_limit_orders(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id1 = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};

create_and_fill_order_book::<Runtime>(order_book_id1);

let order_book_id2 = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: PSWAP.into(),
quote: XOR.into(),
base: PSWAP,
quote: XOR,
};

create_and_fill_order_book::<Runtime>(order_book_id2);

let empty_order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: ETH.into(),
quote: XOR.into(),
base: ETH,
quote: XOR,
};

create_empty_order_book::<Runtime>(empty_order_book_id);
Expand All @@ -1595,8 +1595,8 @@ fn best_bid_should_work_multiple_prices(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};
let mut order_book = create_and_fill_order_book::<Runtime>(order_book_id);

Expand Down Expand Up @@ -1633,7 +1633,7 @@ fn best_bid_should_work_multiple_prices(data: &mut impl DataLayer<Runtime>) {
let new_best_price = BalanceUnit::divisible(balance!(10.7));
let order2 = LimitOrder::<Runtime>::new(
order_book.next_order_id(),
owner.clone(),
owner,
PriceVariant::Buy,
new_best_price,
order_amount,
Expand Down Expand Up @@ -1669,8 +1669,8 @@ fn best_ask_should_work_multiple_prices(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};
let mut order_book = create_and_fill_order_book::<Runtime>(order_book_id);

Expand Down Expand Up @@ -1707,7 +1707,7 @@ fn best_ask_should_work_multiple_prices(data: &mut impl DataLayer<Runtime>) {
let new_best_price = BalanceUnit::divisible(balance!(10.3));
let order2 = LimitOrder::<Runtime>::new(
order_book.next_order_id(),
owner.clone(),
owner,
PriceVariant::Sell,
new_best_price,
order_amount,
Expand Down Expand Up @@ -1799,8 +1799,8 @@ fn is_bid_price_full_works(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};
let order_book = create_empty_order_book::<Runtime>(order_book_id);
let price = order_book.tick_size;
Expand All @@ -1818,8 +1818,8 @@ fn is_ask_price_full_works(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};
let order_book = create_empty_order_book::<Runtime>(order_book_id);
let price = order_book.tick_size;
Expand Down Expand Up @@ -1861,8 +1861,8 @@ fn is_user_limit_orders_full_works(data: &mut impl DataLayer<Runtime>) {
ext().execute_with(|| {
let order_book_id = OrderBookId::<AssetIdOf<Runtime>, DEXId> {
dex_id: DEX.into(),
base: VAL.into(),
quote: XOR.into(),
base: VAL,
quote: XOR,
};
let mut order_book = create_empty_order_book::<Runtime>(order_book_id);
let user = accounts::alice::<Runtime>();
Expand Down
Loading