fix: Fix executor address in test and remove duplicated test
--- don't change below this line --- ENG-4306 Took 12 minutes Took 18 seconds
This commit is contained in:
@@ -1059,7 +1059,7 @@ mod tests {
|
|||||||
Some(BigUint::from_str("2_999_000000000000000000").unwrap()),
|
Some(BigUint::from_str("2_999_000000000000000000").unwrap()),
|
||||||
U256::from_str("2_999_000000000000000000").unwrap(),
|
U256::from_str("2_999_000000000000000000").unwrap(),
|
||||||
)]
|
)]
|
||||||
fn test_sequential_swap_strategy_encoder_simple_route(
|
fn test_single_swap_strategy_encoder(
|
||||||
#[case] expected_amount: Option<BigUint>,
|
#[case] expected_amount: Option<BigUint>,
|
||||||
#[case] slippage: Option<f64>,
|
#[case] slippage: Option<f64>,
|
||||||
#[case] checked_amount: Option<BigUint>,
|
#[case] checked_amount: Option<BigUint>,
|
||||||
@@ -1085,7 +1085,7 @@ mod tests {
|
|||||||
split: 0f64,
|
split: 0f64,
|
||||||
};
|
};
|
||||||
let swap_encoder_registry = get_swap_encoder_registry();
|
let swap_encoder_registry = get_swap_encoder_registry();
|
||||||
let encoder = SequentialSwapStrategyEncoder::new(
|
let encoder = SingleSwapStrategyEncoder::new(
|
||||||
eth_chain(),
|
eth_chain(),
|
||||||
swap_encoder_registry,
|
swap_encoder_registry,
|
||||||
Some(private_key),
|
Some(private_key),
|
||||||
@@ -1111,7 +1111,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let expected_min_amount_encoded = hex::encode(U256::abi_encode(&expected_min_amount));
|
let expected_min_amount_encoded = hex::encode(U256::abi_encode(&expected_min_amount));
|
||||||
let expected_input = [
|
let expected_input = [
|
||||||
"51bcc7b6", // Function selector
|
"c378044e", // Function selector
|
||||||
"0000000000000000000000000000000000000000000000000de0b6b3a7640000", // amount out
|
"0000000000000000000000000000000000000000000000000de0b6b3a7640000", // amount out
|
||||||
"000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
"000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
||||||
"0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", // token out
|
"0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", // token out
|
||||||
@@ -1125,24 +1125,22 @@ mod tests {
|
|||||||
// after this there is the permit and because of the deadlines (that depend on block time)
|
// after this there is the permit and because of the deadlines (that depend on block time)
|
||||||
// it's hard to assert
|
// it's hard to assert
|
||||||
|
|
||||||
let expected_swaps = String::from(concat!(
|
let expected_swap = String::from(concat!(
|
||||||
// length of ple encoded swaps without padding
|
// length of ple encoded swaps without padding
|
||||||
"0000000000000000000000000000000000000000000000000000000000000053",
|
"0000000000000000000000000000000000000000000000000000000000000051",
|
||||||
// ple encoded swaps
|
|
||||||
"0051",
|
|
||||||
// Swap data
|
// Swap data
|
||||||
"f6c5be66fff9dc69962d73da0a617a827c382329", // executor address
|
"5615deb798bb3e4dfa0139dfa1b3d433cc23b72f", // executor address
|
||||||
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
||||||
"a478c2975ab1ea89e8196811f51a7b7ade33eb11", // component id
|
"a478c2975ab1ea89e8196811f51a7b7ade33eb11", // component id
|
||||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
||||||
"00", // zero2one
|
"00", // zero2one
|
||||||
"00", // exact out
|
"00", // exact out
|
||||||
"000000000000000000000000", // padding
|
"0000000000000000000000000000", // padding
|
||||||
));
|
));
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
|
|
||||||
assert_eq!(hex_calldata[..456], expected_input);
|
assert_eq!(hex_calldata[..456], expected_input);
|
||||||
assert_eq!(hex_calldata[1224..], expected_swaps);
|
assert_eq!(hex_calldata[1224..], expected_swap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1608,85 +1606,6 @@ mod tests {
|
|||||||
println!("{}", hex_calldata);
|
println!("{}", hex_calldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_single_swap_strategy_encoder_no_permit2() {
|
|
||||||
// Performs a single swap from WETH to DAI on a USV2 pool, without permit2 and no grouping
|
|
||||||
// optimizations.
|
|
||||||
|
|
||||||
let weth = Bytes::from_str("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2").unwrap();
|
|
||||||
let dai = Bytes::from_str("0x6b175474e89094c44da98b954eedeac495271d0f").unwrap();
|
|
||||||
|
|
||||||
let expected_amount = Some(BigUint::from_str("2_650_000000000000000000").unwrap());
|
|
||||||
let slippage = Some(0.01f64);
|
|
||||||
let checked_amount = Some(BigUint::from_str("2_640_000000000000000000").unwrap());
|
|
||||||
let expected_min_amount = U256::from_str("2_640_000000000000000000").unwrap();
|
|
||||||
|
|
||||||
let swap = Swap {
|
|
||||||
component: ProtocolComponent {
|
|
||||||
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
|
|
||||||
protocol_system: "uniswap_v2".to_string(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
token_in: weth.clone(),
|
|
||||||
token_out: dai.clone(),
|
|
||||||
split: 0f64,
|
|
||||||
};
|
|
||||||
let swap_encoder_registry = get_swap_encoder_registry();
|
|
||||||
let encoder = SingleSwapStrategyEncoder::new(
|
|
||||||
eth_chain(),
|
|
||||||
swap_encoder_registry,
|
|
||||||
None,
|
|
||||||
// TODO this should be OPTION
|
|
||||||
Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let solution = Solution {
|
|
||||||
exact_out: false,
|
|
||||||
given_token: weth,
|
|
||||||
given_amount: BigUint::from_str("1_000000000000000000").unwrap(),
|
|
||||||
checked_token: dai,
|
|
||||||
expected_amount,
|
|
||||||
slippage,
|
|
||||||
checked_amount,
|
|
||||||
sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(),
|
|
||||||
receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(),
|
|
||||||
swaps: vec![swap],
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let (calldata, _) = encoder
|
|
||||||
.encode_strategy(solution)
|
|
||||||
.unwrap();
|
|
||||||
let expected_min_amount_encoded = hex::encode(U256::abi_encode(&expected_min_amount));
|
|
||||||
let expected_input = [
|
|
||||||
"0f6cbbe8", // Function selector
|
|
||||||
"0000000000000000000000000000000000000000000000000de0b6b3a7640000", // amount out
|
|
||||||
"000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
|
||||||
"0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", // token out
|
|
||||||
&expected_min_amount_encoded, // min amount out
|
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000", // wrap
|
|
||||||
"0000000000000000000000000000000000000000000000000000000000000000", // unwrap
|
|
||||||
"000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2", // receiver
|
|
||||||
"0000000000000000000000000000000000000000000000000000000000000100", // offset of swap bytes
|
|
||||||
"0000000000000000000000000000000000000000000000000000000000000051", // length of swap bytes without padding
|
|
||||||
|
|
||||||
// Swap data
|
|
||||||
"f6c5be66fff9dc69962d73da0a617a827c382329", // executor address
|
|
||||||
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
|
||||||
"a478c2975ab1ea89e8196811f51a7b7ade33eb11", // component id
|
|
||||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
|
||||||
"00", // zero2one
|
|
||||||
"00", // exact out
|
|
||||||
"0000000000000000000000000000", // padding
|
|
||||||
]
|
|
||||||
.join("");
|
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
|
||||||
|
|
||||||
assert_eq!(hex_calldata, expected_input);
|
|
||||||
println!("{}", hex_calldata);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_encoding_strategy_ekubo() {
|
fn test_split_encoding_strategy_ekubo() {
|
||||||
// ETH ──(EKUBO)──> USDC
|
// ETH ──(EKUBO)──> USDC
|
||||||
@@ -1748,7 +1667,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_swap_strategy_encoder_simple_route_no_permit2() {
|
fn test_single_swap_strategy_encoder_no_permit2() {
|
||||||
// Performs a single swap from WETH to DAI on a USV2 pool, without permit2 and no grouping
|
// Performs a single swap from WETH to DAI on a USV2 pool, without permit2 and no grouping
|
||||||
// optimizations.
|
// optimizations.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user