Skip to content

Commit

Permalink
calldatadecoder test
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis committed Aug 1, 2024
1 parent e891903 commit 7b4b6ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ contract PositionManager is
}

function _settlePair(Currency currency0, Currency currency1) internal {
// the locker is the payer or receiver
// the locker is the payer when settling
address caller = _msgSender();
_settle(currency0, caller, _getFullSettleAmount(currency0));
_settle(currency1, caller, _getFullSettleAmount(currency1));
Expand Down
8 changes: 8 additions & 0 deletions test/libraries/CalldataDecoder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ contract CalldataDecoderTest is Test {
assertEq(Currency.unwrap(currency), Currency.unwrap(_currency));
}

function test_fuzz_decodeCurrencyPair(Currency _currency0, Currency _currency1) public view {
bytes memory params = abi.encode(_currency0, _currency1);
(Currency currency0, Currency currency1) = decoder.decodeCurrencyPair(params);

assertEq(Currency.unwrap(currency0), Currency.unwrap(_currency0));
assertEq(Currency.unwrap(currency1), Currency.unwrap(_currency1));
}

function _assertEq(PositionConfig memory config1, PositionConfig memory config2) internal pure {
assertEq(Currency.unwrap(config1.poolKey.currency0), Currency.unwrap(config2.poolKey.currency0));
assertEq(Currency.unwrap(config1.poolKey.currency1), Currency.unwrap(config2.poolKey.currency1));
Expand Down
4 changes: 4 additions & 0 deletions test/mocks/MockCalldataDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ contract MockCalldataDecoder {
function decodeCurrency(bytes calldata params) external pure returns (Currency currency) {
return params.decodeCurrency();
}

function decodeCurrencyPair(bytes calldata params) external pure returns (Currency currency0, Currency currency1) {
return params.decodeCurrencyPair();
}
}

0 comments on commit 7b4b6ec

Please sign in to comment.