Skip to content

Commit

Permalink
test: add regression test for #351
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Oct 9, 2023
1 parent 23bffbf commit 0065c4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions crates/json-abi/tests/abi/UniswapV3Position.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"contract IUniswapV3Pool","name":"pool_","type":"IUniswapV3Pool"},{"internalType":"address","name":"self_","type":"address"},{"internalType":"int24","name":"lowerTick_","type":"int24"},{"internalType":"int24","name":"upperTick_","type":"int24"}],"name":"getLiquidityByRange","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"self_","type":"address"},{"internalType":"int24","name":"lowerTick_","type":"int24"},{"internalType":"int24","name":"upperTick_","type":"int24"}],"name":"getPositionId","outputs":[{"internalType":"bytes32","name":"positionId","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"int24","name":"lowerTick","type":"int24"},{"internalType":"int24","name":"upperTick","type":"int24"},{"internalType":"uint24","name":"feeTier","type":"uint24"}],"internalType":"struct Range[]","name":"currentRanges_","type":"tuple[]"},{"components":[{"internalType":"int24","name":"lowerTick","type":"int24"},{"internalType":"int24","name":"upperTick","type":"int24"},{"internalType":"uint24","name":"feeTier","type":"uint24"}],"internalType":"struct Range","name":"range_","type":"tuple"}],"name":"rangeExists","outputs":[{"internalType":"bool","name":"ok","type":"bool"},{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"pure","type":"function"}]
29 changes: 26 additions & 3 deletions crates/sol-types/tests/sol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ fn error() {
assert_eq!(e.abi_encoded_size(), 64);
}

// Handle empty call encoding/decoding correctly
// https://github.com/alloy-rs/core/issues/158
#[test]
fn empty_call() {
Expand Down Expand Up @@ -409,6 +410,7 @@ fn nested_items() {
assert_eq!(f2Call::SIGNATURE, "f2((bytes,bool))");
}

// Allow enums as fields of structs
// https://github.com/alloy-rs/core/issues/319
#[test]
fn enum_field_of_struct() {
Expand Down Expand Up @@ -456,9 +458,8 @@ fn rust_keywords() {
}
}

// TODO
// Translate contract types to `address`
// https://github.com/alloy-rs/core/issues/347
// https://github.com/alloy-rs/core/issues/351
#[test]
#[cfg(TODO)]
fn contract_type() {
Expand All @@ -471,6 +472,7 @@ fn contract_type() {
}
}

// Correctly identify whether a type is dynamic
// https://github.com/alloy-rs/core/issues/352
#[test]
fn word_dynarray_event() {
Expand Down Expand Up @@ -548,11 +550,11 @@ fn abigen_json_seaport() {
);
}

// Handle multiple identical error objects in the JSON ABI
// https://github.com/alloy-rs/core/issues/344
#[test]
#[cfg(feature = "json")]
fn abigen_json_aggregation_router_v5() {
// There's multiple identical error objects in the JSON ABI
sol!(
AggregationRouterV5,
"../json-abi/tests/abi/AggregationRouterV5.json"
Expand All @@ -568,6 +570,27 @@ fn abigen_json_aggregation_router_v5() {
);
}

// Handle contract types in JSON ABI
// https://github.com/alloy-rs/core/issues/351
#[test]
#[cfg(feature = "json")]
fn abigen_json_uniswap_v3_position() {
sol!(
UniswapV3Position,
"../json-abi/tests/abi/UniswapV3Position.json"
);

let _ = UniswapV3Position::getPositionIdCall {
self_: Address::ZERO,
lowerTick_: 0,
upperTick_: 0,
};
assert_eq!(
UniswapV3Position::getPositionIdCall::SIGNATURE,
"getPositionId(address,int24,int24)"
);
}

#[test]
fn eip712_encode_type_nesting() {
sol! {
Expand Down

0 comments on commit 0065c4c

Please sign in to comment.