Skip to content

Commit

Permalink
Better tests values
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Mar 14, 2024
1 parent d685908 commit 723515a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
60 changes: 30 additions & 30 deletions crates/driver/src/tests/cases/protocol_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
},
};
Expand All @@ -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(),
},
},
};
Expand Down Expand Up @@ -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(),
},
},
};
Expand All @@ -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(),
},
},
};
Expand Down Expand Up @@ -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(),
},
},
};
Expand All @@ -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(),
},
},
Expand Down
10 changes: 8 additions & 2 deletions crates/driver/src/tests/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 723515a

Please sign in to comment.