Skip to content

Commit

Permalink
Fix forked mainnet test (#2361)
Browse files Browse the repository at this point in the history
# Description
I think we actually broke the test when we merged some of the verified
quotes logic (that's the problem with flaky test, people tend to just
ignore them when they fail)

Even locally, I'm getting a driver/solver timed out trying to place the
order. This is because the first run of the driver requires fetching all
AMMs and liquidity sources from scratch which can be a time consuming
endeavour. After that the cache is warm and we can respond fast.

# Changes
- [x] Run a dummy quote to warm up the cache in the e2e test before
placing the order.

Alternatively, I thought about making the time limit configurable and
changing it in the e2e tests but we might actually want to get a failing
test if we are unable to process quote requests in < 5s.

## How to test
By running the flaky e2e test, and seeing it now passes reliably.
  • Loading branch information
fleupold authored Feb 5, 2024
1 parent eae4a4b commit d2a6480
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/e2e/tests/e2e/limit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use {
ethcontract::{prelude::U256, H160},
model::{
order::{OrderClass, OrderCreation, OrderKind},
quote::{OrderQuoteRequest, OrderQuoteSide, SellAmount},
signature::EcdsaSigningScheme,
},
secp256k1::SecretKey,
Expand Down Expand Up @@ -543,6 +544,22 @@ async fn forked_mainnet_single_limit_order_test(web3: Web3) {
&onchain.contracts().domain_separator,
SecretKeyRef::from(&SecretKey::from_slice(trader.private_key()).unwrap()),
);

// Warm up co-located driver by quoting the order (otherwise placing an order
// may time out)
let _ = services
.submit_quote(&OrderQuoteRequest {
sell_token: token_usdc.address(),
buy_token: token_usdt.address(),
side: OrderQuoteSide::Sell {
sell_amount: SellAmount::BeforeFee {
value: to_wei_with_exp(1000, 6).try_into().unwrap(),
},
},
..Default::default()
})
.await;

let order_id = services.create_order(&order).await.unwrap();
let limit_order = services.get_order(&order_id).await.unwrap();
assert_eq!(limit_order.metadata.class, OrderClass::Limit);
Expand Down

0 comments on commit d2a6480

Please sign in to comment.