Skip to content

Commit

Permalink
Remove unused TokenNetwork.max
Browse files Browse the repository at this point in the history
This reduces the contract size a bit.
  • Loading branch information
palango committed Mar 1, 2021
1 parent 74f45fb commit 2afdad0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
5 changes: 0 additions & 5 deletions raiden_contracts/data/source/raiden/TokenNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1692,11 +1692,6 @@ contract TokenNetwork is Utils {
return a > b ? b : a;
}

function max(uint256 a, uint256 b) internal pure returns (uint256)
{
return a > b ? a : b;
}

/// @dev Special subtraction function that does not fail when underflowing.
/// @param a Minuend
/// @param b Subtrahend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,6 @@ contract TokenNetworkUtilsTest is TokenNetwork {
return min(a,b);
}

function maxPublic(uint256 a, uint256 b) public view returns (uint256)
{
return max(a,b);
}

function failsafe_subtractPublic(uint256 a, uint256 b) public view returns (uint256, uint256)
{
return failsafe_subtract(a,b);
Expand Down
22 changes: 0 additions & 22 deletions raiden_contracts/tests/unit/test_unit_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ def test_min_uses_usigned(token_network_test_utils: Contract) -> None:
token_network_test_utils.functions.minPublic(a, b).call()


def test_max_uses_usigned(token_network_test_utils: Contract) -> None:
""" Max cannot be called with negative values """

INVALID_VALUES = [-UINT256_MAX, -1]
VALID_VALUES = [UINT256_MIN, UINT256_MAX, UINT256_MAX]

all_invalid = chain(
product(VALID_VALUES, INVALID_VALUES), product(INVALID_VALUES, VALID_VALUES)
)
for a, b in all_invalid:
with pytest.raises(ValidationError):
token_network_test_utils.functions.maxPublic(a, b).call()


def test_min(token_network_test_utils: Contract) -> None:
""" Min works like Python's min """

Expand All @@ -44,14 +30,6 @@ def test_min(token_network_test_utils: Contract) -> None:
assert token_network_test_utils.functions.minPublic(a, b).call() == min(a, b)


def test_max(token_network_test_utils: Contract) -> None:
""" Max works like Python's max """

VALUES = [UINT256_MIN, 1, UINT256_MAX, UINT256_MAX]
for a, b in product(VALUES, VALUES):
assert token_network_test_utils.functions.maxPublic(a, b).call() == max(a, b)


def test_too_big_runtime_code() -> None:
compilation = {"TestContract": {"bin-runtime": "33" * 0x6001}}
with pytest.raises(RuntimeError):
Expand Down

0 comments on commit 2afdad0

Please sign in to comment.