From 723515a6bad7a3a8b1ca8d54d3fb20fe19a80a10 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 14 Mar 2024 19:23:08 +0000 Subject: [PATCH] Better tests values --- .../driver/src/tests/cases/protocol_fees.rs | 60 +++++++++---------- crates/driver/src/tests/setup/mod.rs | 10 +++- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/crates/driver/src/tests/cases/protocol_fees.rs b/crates/driver/src/tests/cases/protocol_fees.rs index 9b9b0a9866..dd6b662a7a 100644 --- a/crates/driver/src/tests/cases/protocol_fees.rs +++ b/crates/driver/src/tests/cases/protocol_fees.rs @@ -173,19 +173,19 @@ async fn surplus_protocol_fee_partial_buy_order_not_capped() { fee_policy, order: Order { sell_amount: 50.ether().into_wei(), - buy_amount: 40.ether().into_wei(), + buy_amount: 50.ether().into_wei(), side: order::Side::Buy, }, execution: Execution { - // 6 ETH surplus in sell token (after network fee), half of which is kept by the + // 10 ETH surplus in sell token (after network fee), half of which is kept by the // protocol solver: Amounts { - sell: 29.ether().into_wei(), - buy: 28.ether().into_wei(), + sell: 10.ether().into_wei(), + buy: 20.ether().into_wei(), }, driver: Amounts { - sell: 32.ether().into_wei(), - buy: 28.ether().into_wei(), + sell: 15.ether().into_wei(), + buy: 20.ether().into_wei(), }, }, }; @@ -205,18 +205,18 @@ async fn surplus_protocol_fee_partial_sell_order_not_capped() { fee_policy, order: Order { sell_amount: 50.ether().into_wei(), - buy_amount: 40.ether().into_wei(), + buy_amount: 50.ether().into_wei(), side: order::Side::Sell, }, execution: Execution { - // 6 ETH surplus, half of which gets captured by the protocol + // 10 ETH surplus, half of which gets captured by the protocol solver: Amounts { - sell: 25.ether().into_wei(), - buy: 26.ether().into_wei(), + sell: 20.ether().into_wei(), + buy: 30.ether().into_wei(), }, driver: Amounts { - sell: 25.ether().into_wei(), - buy: 23.ether().into_wei(), + sell: 20.ether().into_wei(), + buy: 25.ether().into_wei(), }, }, }; @@ -295,18 +295,18 @@ async fn surplus_protocol_fee_partial_buy_order_capped() { fee_policy, order: Order { sell_amount: 50.ether().into_wei(), - buy_amount: 40.ether().into_wei(), + buy_amount: 50.ether().into_wei(), side: order::Side::Buy, }, execution: Execution { // Fee is capped at 20% of solver proposed sell volume solver: Amounts { - sell: 25.ether().into_wei(), - buy: 28.ether().into_wei(), + sell: 10.ether().into_wei(), + buy: 20.ether().into_wei(), }, driver: Amounts { - sell: 30.ether().into_wei(), - buy: 28.ether().into_wei(), + sell: 12.ether().into_wei(), + buy: 20.ether().into_wei(), }, }, }; @@ -325,18 +325,18 @@ async fn surplus_protocol_fee_partial_sell_order_capped() { fee_policy, order: Order { sell_amount: 50.ether().into_wei(), - buy_amount: 40.ether().into_wei(), + buy_amount: 50.ether().into_wei(), side: order::Side::Sell, }, execution: Execution { // Fee is capped at 10% of solver proposed buy volume solver: Amounts { - sell: 25.ether().into_wei(), - buy: 26.ether().into_wei(), + sell: 20.ether().into_wei(), + buy: 30.ether().into_wei(), }, driver: Amounts { - sell: 25.ether().into_wei(), - buy: "23.4".ether().into_wei(), + sell: 20.ether().into_wei(), + buy: 27.ether().into_wei(), }, }, }; @@ -403,18 +403,18 @@ async fn volume_protocol_fee_partial_buy_order() { fee_policy, order: Order { sell_amount: 50.ether().into_wei(), - buy_amount: 40.ether().into_wei(), + buy_amount: 50.ether().into_wei(), side: order::Side::Buy, }, execution: Execution { // Half of the solver proposed sell volume is kept by the protocol solver: Amounts { - sell: 20.ether().into_wei(), - buy: 28.ether().into_wei(), + sell: 10.ether().into_wei(), + buy: 20.ether().into_wei(), }, driver: Amounts { - sell: 30.ether().into_wei(), - buy: 28.ether().into_wei(), + sell: 15.ether().into_wei(), + buy: 20.ether().into_wei(), }, }, }; @@ -429,17 +429,17 @@ async fn volume_protocol_fee_partial_sell_order() { fee_policy, order: Order { sell_amount: 50.ether().into_wei(), - buy_amount: 40.ether().into_wei(), + buy_amount: 50.ether().into_wei(), side: order::Side::Sell, }, execution: Execution { // 10% of the solver proposed buy value is kept by the protocol solver: Amounts { - sell: 25.ether().into_wei(), + sell: 20.ether().into_wei(), buy: 30.ether().into_wei(), }, driver: Amounts { - sell: 25.ether().into_wei(), + sell: 20.ether().into_wei(), buy: 27.ether().into_wei(), }, }, diff --git a/crates/driver/src/tests/setup/mod.rs b/crates/driver/src/tests/setup/mod.rs index 5bbb6c9a0a..cbba7aaeec 100644 --- a/crates/driver/src/tests/setup/mod.rs +++ b/crates/driver/src/tests/setup/mod.rs @@ -1122,8 +1122,14 @@ impl<'a> SolveOk<'a> { fulfillment.quoted_order.buy, ), }; - assert!(u256(trade.get("sellAmount").unwrap()) == expected_sell); - assert!(u256(trade.get("buyAmount").unwrap()) == expected_buy); + let u257 = u256(trade.get("sellAmount").unwrap()); + let u258 = u256(trade.get("buyAmount").unwrap()); + tracing::info!("newlog u257={:?}", u257); + tracing::info!("newlog expected_sell={:?}", expected_sell); + tracing::info!("newlog u258={:?}", u258); + tracing::info!("newlog expected_buy={:?}", expected_buy); + assert!(u257 == expected_sell); + assert!(u258 == expected_buy); } self }