fix: Fix integration tests with transfer in method support
- For now, hardcode them to TRANSFER on the rust encoder side. This will be fixed in an upcoming PR. - Remove the split swap simple route integration test - seemed overkill since simple routes are tested in many other integration tests, the original rust test named doesn't exist anymore, and simple routes should anyway be passing through the single endpoint.
This commit is contained in:
committed by
Diana Carvalho
parent
e3ac394d27
commit
d3ff9fd0e2
@@ -709,9 +709,9 @@ mod tests {
|
||||
|
||||
let expected_swaps = String::from(concat!(
|
||||
// length of ple encoded swaps without padding
|
||||
"0000000000000000000000000000000000000000000000000000000000000058",
|
||||
"0000000000000000000000000000000000000000000000000000000000000059",
|
||||
// ple encoded swaps
|
||||
"0056",
|
||||
"0057",
|
||||
// Swap header
|
||||
"00", // token in index
|
||||
"01", // token out index
|
||||
@@ -722,7 +722,7 @@ mod tests {
|
||||
"a478c2975ab1ea89e8196811f51a7b7ade33eb11", // component id
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
||||
"00", // zero2one
|
||||
"00", // exact out
|
||||
"00", // transfer method
|
||||
"00000000000000", // padding
|
||||
));
|
||||
let hex_calldata = encode(&calldata);
|
||||
@@ -817,8 +817,8 @@ mod tests {
|
||||
// it's hard to assert
|
||||
|
||||
let expected_swap = String::from(concat!(
|
||||
// length of ple encoded swaps without padding
|
||||
"0000000000000000000000000000000000000000000000000000000000000051",
|
||||
// length of encoded swap without padding
|
||||
"0000000000000000000000000000000000000000000000000000000000000052",
|
||||
// Swap data
|
||||
"5615deb798bb3e4dfa0139dfa1b3d433cc23b72f", // executor address
|
||||
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // token in
|
||||
@@ -826,7 +826,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
||||
"00", // zero2one
|
||||
"00", // exact out
|
||||
"0000000000000000000000000000", // padding
|
||||
"00", // transfer method
|
||||
"00000000000000000000000000", // padding
|
||||
));
|
||||
let hex_calldata = encode(&calldata);
|
||||
|
||||
@@ -1475,7 +1476,7 @@ mod tests {
|
||||
"0000000000000000000000000000000000000000000000000000000000000000", // unwrap
|
||||
"000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2", // receiver
|
||||
"0000000000000000000000000000000000000000000000000000000000000100", // offset of swap bytes
|
||||
"0000000000000000000000000000000000000000000000000000000000000051", // length of swap bytes without padding
|
||||
"0000000000000000000000000000000000000000000000000000000000000052", // length of swap bytes without padding
|
||||
|
||||
// Swap data
|
||||
"5615deb798bb3e4dfa0139dfa1b3d433cc23b72f", // executor address
|
||||
@@ -1484,7 +1485,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
||||
"00", // zero2one
|
||||
"00", // exact out
|
||||
"0000000000000000000000000000", // padding
|
||||
"00", // transfer method
|
||||
"00000000000000000000000000", // padding
|
||||
]
|
||||
.join("");
|
||||
|
||||
@@ -1554,8 +1556,8 @@ mod tests {
|
||||
"0000000000000000000000000000000000000000000000000000000000000002", // tokens length
|
||||
"000000000000000000000000cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2", // receiver
|
||||
"0000000000000000000000000000000000000000000000000000000000000120", // offset of ple encoded swaps
|
||||
"0000000000000000000000000000000000000000000000000000000000000058", // length of ple encoded swaps without padding
|
||||
"0056", // ple encoded swaps
|
||||
"0000000000000000000000000000000000000000000000000000000000000059", // length of ple encoded swaps without padding
|
||||
"0057", // ple encoded swaps
|
||||
// Swap header
|
||||
"00", // token in index
|
||||
"01", // token out index
|
||||
@@ -1567,7 +1569,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // receiver
|
||||
"00", // zero2one
|
||||
"00", // exact out
|
||||
"00000000000000", // padding
|
||||
"00", // transfer method
|
||||
"000000000000", // padding
|
||||
]
|
||||
.join("");
|
||||
|
||||
@@ -1806,8 +1809,8 @@ mod tests {
|
||||
.join("");
|
||||
|
||||
let expected_swaps = [
|
||||
"00000000000000000000000000000000000000000000000000000000000000de", // length of ple encoded swaps without padding
|
||||
"006d", // ple encoded swaps
|
||||
"00000000000000000000000000000000000000000000000000000000000000e0", // length of ple encoded swaps without padding
|
||||
"006e", // ple encoded swaps
|
||||
"00", // token in index
|
||||
"01", // token out index
|
||||
"000000", // split
|
||||
@@ -1818,7 +1821,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"88e6a0c2ddd26feeb64f039a2c41296fcb3f5640", // component id
|
||||
"01", // zero2one
|
||||
"006d", // ple encoded swaps
|
||||
"00", // transfer method
|
||||
"006e", // ple encoded swaps
|
||||
"01", // token in index
|
||||
"00000000", // split
|
||||
"2e234dae75c793f67a35089c9d99245e1c58470b", // executor address
|
||||
@@ -1827,7 +1831,8 @@ mod tests {
|
||||
"000bb8", // pool fee
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"8ad599c3a0ff1de082011efddc58f1908eb6e6d8", // component id
|
||||
"000000", // zero2one
|
||||
"00", // zero2one
|
||||
"00", // transfer method
|
||||
]
|
||||
.join("");
|
||||
|
||||
@@ -1958,8 +1963,8 @@ mod tests {
|
||||
]
|
||||
.join("");
|
||||
let expected_swaps = [
|
||||
"0000000000000000000000000000000000000000000000000000000000000136", // length of ple encoded swaps without padding
|
||||
"006d", // ple encoded swaps
|
||||
"0000000000000000000000000000000000000000000000000000000000000139", // length of ple encoded swaps without padding
|
||||
"006e", // ple encoded swaps
|
||||
"00", // token in index
|
||||
"01", // token out index
|
||||
"999999", // split
|
||||
@@ -1970,7 +1975,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"88e6a0c2ddd26feeb64f039a2c41296fcb3f5640", // component id
|
||||
"01", // zero2one
|
||||
"006d", // ple encoded swaps
|
||||
"00", // transfer method
|
||||
"006e", // ple encoded swaps
|
||||
"00", // token in index
|
||||
"01", // token out index
|
||||
"000000", // split
|
||||
@@ -1981,7 +1987,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"8ad599c3a0ff1de082011efddc58f1908eb6e6d8", // component id
|
||||
"01", // zero2one
|
||||
"0056", // ple encoded swaps
|
||||
"00", // transfer method
|
||||
"0057", // ple encoded swaps
|
||||
"01", // token in index
|
||||
"00", // token out index
|
||||
"000000", // split
|
||||
@@ -1990,7 +1997,8 @@ mod tests {
|
||||
"b4e16d0168e52d35cacd2c6185b44281ec28c9dc", // component id,
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"00", // zero2one
|
||||
"00000000000000000000" // padding
|
||||
"00", // transfer method
|
||||
"00000000000000" // padding
|
||||
]
|
||||
.join("");
|
||||
assert_eq!(hex_calldata[..520], expected_input);
|
||||
@@ -2117,8 +2125,8 @@ mod tests {
|
||||
.join("");
|
||||
|
||||
let expected_swaps = [
|
||||
"0000000000000000000000000000000000000000000000000000000000000136", // length of ple encoded swaps without padding
|
||||
"0056", // ple encoded swaps
|
||||
"0000000000000000000000000000000000000000000000000000000000000139", // length of ple encoded swaps without padding
|
||||
"0057", // ple encoded swaps
|
||||
"00", // token in index
|
||||
"01", // token out index
|
||||
"000000", // split
|
||||
@@ -2127,7 +2135,8 @@ mod tests {
|
||||
"b4e16d0168e52d35cacd2c6185b44281ec28c9dc", // component id
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"01", // zero2one
|
||||
"006d", // ple encoded swaps
|
||||
"00", // transfer method
|
||||
"006e", // ple encoded swaps
|
||||
"01", // token in index
|
||||
"00", // token out index
|
||||
"999999", // split
|
||||
@@ -2138,7 +2147,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"88e6a0c2ddd26feeb64f039a2c41296fcb3f5640", // component id
|
||||
"00", // zero2one
|
||||
"006d", // ple encoded swaps
|
||||
"00", // transfer method
|
||||
"006e", // ple encoded swaps
|
||||
"01", // token in index
|
||||
"00", // token out index
|
||||
"000000", // split
|
||||
@@ -2149,7 +2159,8 @@ mod tests {
|
||||
"3ede3eca2a72b3aecc820e955b36f38437d01395", // router address
|
||||
"8ad599c3a0ff1de082011efddc58f1908eb6e6d8", // component id
|
||||
"00", // zero2one
|
||||
"00000000000000000000" // padding
|
||||
"00", // transfer method
|
||||
"00000000000000" // padding
|
||||
]
|
||||
.join("");
|
||||
|
||||
|
||||
@@ -22,6 +22,15 @@ use crate::encoding::{
|
||||
swap_encoder::SwapEncoder,
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(u8)]
|
||||
pub enum TransferType {
|
||||
Transfer = 0,
|
||||
TransferFrom = 1,
|
||||
Permit2Transfer = 2,
|
||||
None = 3,
|
||||
}
|
||||
|
||||
/// Encodes a swap on a Uniswap V2 pool through the given executor address.
|
||||
///
|
||||
/// # Fields
|
||||
@@ -66,6 +75,7 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
||||
component_id,
|
||||
bytes_to_address(&encoding_context.receiver)?,
|
||||
zero_to_one,
|
||||
(TransferType::Transfer as u8).to_be_bytes(),
|
||||
);
|
||||
|
||||
Ok(args.abi_encode_packed())
|
||||
@@ -128,6 +138,7 @@ impl SwapEncoder for UniswapV3SwapEncoder {
|
||||
bytes_to_address(&encoding_context.receiver)?,
|
||||
component_id,
|
||||
zero_to_one,
|
||||
(TransferType::Transfer as u8).to_be_bytes(),
|
||||
);
|
||||
|
||||
Ok(args.abi_encode_packed())
|
||||
@@ -606,6 +617,8 @@ mod tests {
|
||||
"0000000000000000000000000000000000000001",
|
||||
// zero for one
|
||||
"00",
|
||||
// transfer type (transfer)
|
||||
"00",
|
||||
))
|
||||
);
|
||||
}
|
||||
@@ -661,6 +674,8 @@ mod tests {
|
||||
"88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
|
||||
// zero for one
|
||||
"00",
|
||||
// transfer type (transfer)
|
||||
"00",
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user