Skip to content

Commit

Permalink
Replaced function in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrug committed Feb 18, 2025
1 parent 6930802 commit baeeed7
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions crates/database/src/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,19 +834,6 @@ mod tests {
.await
}

async fn single_full_order_without_quote(
ex: &mut PgConnection,
uid: &OrderUid,
) -> Result<Option<FullOrder>, sqlx::Error> {
#[rustfmt::skip]
const QUERY: &str = const_format::concatcp!(
"SELECT ", SELECT,
" FROM ", FROM,
" WHERE o.uid = $1 ",
);
sqlx::query_as(QUERY).bind(uid).fetch_optional(ex).await
}

#[tokio::test]
#[ignore]
async fn postgres_order_roundtrip() {
Expand All @@ -861,10 +848,11 @@ mod tests {
let order_ = read_order(&mut db, &order.uid).await.unwrap().unwrap();
assert_eq!(order, order_);

let full_order = single_full_order_without_quote(&mut db, &order.uid)
let full_order = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;

assert_eq!(order.uid, full_order.uid);
assert_eq!(order.owner, full_order.owner);
Expand Down Expand Up @@ -923,10 +911,11 @@ mod tests {
.await
.unwrap();
insert_order(&mut db, &order).await.unwrap();
let order_ = single_full_order_without_quote(&mut db, &order.uid)
let order_ = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(Some(sender), order_.onchain_user);
}

Expand Down Expand Up @@ -958,10 +947,11 @@ mod tests {
)
.await
.unwrap();
let order_ = single_full_order_without_quote(&mut db, &order.uid)
let order_ = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(
Some((Some(Default::default()), user_valid_to)),
order_.ethflow_data
Expand Down Expand Up @@ -994,10 +984,11 @@ mod tests {
insert_or_overwrite_interaction(&mut db, &post_interaction_1, &order.uid)
.await
.unwrap();
let order_ = single_full_order_without_quote(&mut db, &order.uid)
let order_ = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(
vec![ByteArray::default(), ByteArray([1; 20])],
order_
Expand Down Expand Up @@ -1084,10 +1075,11 @@ mod tests {
insert_or_overwrite_interaction(&mut db, &pre_interaction_1, &order.uid)
.await
.unwrap();
let order_ = single_full_order_without_quote(&mut db, &order.uid)
let order_ = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(
vec![ByteArray::default(), ByteArray([1; 20])],
order_
Expand Down Expand Up @@ -1458,10 +1450,11 @@ mod tests {
.unwrap();
}

let order = single_full_order_without_quote(&mut db, &order.uid)
let order = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;

let expected_sell_amount_including_fees: BigInt = sell_amount_including_fee * 16;
assert!(expected_sell_amount_including_fees > u256_max);
Expand Down Expand Up @@ -1558,18 +1551,20 @@ mod tests {
..Default::default()
};
insert_order(&mut db, &order).await.unwrap();
let result = single_full_order_without_quote(&mut db, &order.uid)
let result = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert!(!result.invalidated);
insert_onchain_invalidation(&mut db, &EventIndex::default(), &order.uid)
.await
.unwrap();
let result = single_full_order_without_quote(&mut db, &order.uid)
let result = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert!(result.invalidated);
}

Expand Down Expand Up @@ -1907,10 +1902,11 @@ mod tests {
.unwrap();

let fee: BigDecimal = 0.into();
let order = single_full_order_without_quote(&mut db, &order_uid)
let order = single_full_order_with_quote(&mut db, &order_uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(order.executed_fee, fee);

let fee: BigDecimal = 1.into();
Expand All @@ -1928,10 +1924,11 @@ mod tests {
.await
.unwrap();

let order = single_full_order_without_quote(&mut db, &order_uid)
let order = single_full_order_with_quote(&mut db, &order_uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(order.executed_fee, fee);
}

Expand All @@ -1946,19 +1943,21 @@ mod tests {
..Default::default()
};
insert_order(&mut db, &order).await.unwrap();
let full_order = single_full_order_without_quote(&mut db, &order.uid)
let full_order = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert!(full_order.full_app_data.is_none());
let full_app_data = vec![0u8, 1, 2];
crate::app_data::insert(&mut db, &order.app_data, &full_app_data)
.await
.unwrap();
let full_order = single_full_order_without_quote(&mut db, &order.uid)
let full_order = single_full_order_with_quote(&mut db, &order.uid)
.await
.unwrap()
.unwrap();
.unwrap()
.full_order;
assert_eq!(full_order.full_app_data, Some(full_app_data));
}

Expand Down

0 comments on commit baeeed7

Please sign in to comment.