Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update forge-std to v1.8.1 #222

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"contract-name-camelcase": "off",
"func-name-mixedcase": "off",
"func-visibility": ["error", { "ignoreConstructors": true }],
"gas-custom-errors": "off",
"max-line-length": ["error", 132],
"no-console": "off",
"no-global-import": "off",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"url": "https://github.com/PaulRBerg/prb-math/issues"
},
"devDependencies": {
"@prb/test": "0.6.5",
"forge-std": "github:foundry-rs/forge-std#v1.7.4",
"forge-std": "github:foundry-rs/forge-std#v1.8.1",
"prettier": "^3.1.1",
"solhint": "^4.0.0"
},
Expand Down Expand Up @@ -43,6 +42,7 @@
"lint": "bun run lint:sol && bun run prettier:check",
"lint:sol": "forge fmt --check && bun solhint \"{src,test}/**/*.sol\"",
"prettier:check": "prettier --check \"**/*.{json,md,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\""
"prettier:write": "prettier --write \"**/*.{json,md,yml}\"",
"test": "forge test"
}
}
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@prb/test/=node_modules/@prb/test/
forge-std/=node_modules/forge-std/
16 changes: 14 additions & 2 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.19 <0.9.0;

import { PRBTest } from "@prb/test/src/PRBTest.sol";
import { StdAssertions } from "forge-std/src/StdAssertions.sol";
import { StdCheats } from "forge-std/src/StdCheats.sol";
import { Vm } from "forge-std/src/Vm.sol";

import { PRBMathAssertions } from "./utils/Assertions.sol";
import { PRBMathUtils } from "./utils/Utils.sol";

/// @notice Base test contract with common logic needed by all tests.
abstract contract Base_Test is PRBTest, StdCheats, PRBMathAssertions, PRBMathUtils {
abstract contract Base_Test is StdAssertions, StdCheats, PRBMathAssertions, PRBMathUtils {
/*//////////////////////////////////////////////////////////////////////////
STRUCTS
//////////////////////////////////////////////////////////////////////////*/
Expand All @@ -19,14 +20,25 @@ abstract contract Base_Test is PRBTest, StdCheats, PRBMathAssertions, PRBMathUti
address eve;
}

/*//////////////////////////////////////////////////////////////////////////
CHEATCODES
//////////////////////////////////////////////////////////////////////////*/

/// @dev An instance of the Foundry VM, which contains cheatcodes for testing.
Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

/*//////////////////////////////////////////////////////////////////////////
CONSTANTS
//////////////////////////////////////////////////////////////////////////*/

int256 internal constant MAX_INT256 = type(int256).max;

uint128 internal constant MAX_UINT128 = type(uint128).max;

uint128 internal constant MAX_UINT40 = type(uint40).max;

int256 internal constant MIN_INT256 = type(int256).min;
PaulRBerg marked this conversation as resolved.
Show resolved Hide resolved

/*//////////////////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////////////////*/
Expand Down
8 changes: 4 additions & 4 deletions test/fuzz/casting/CastingUint128.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ contract CastingUint128_Test is Base_Test {
x.intoSD1x18();
}

function testFuzz_intoSD1x18(uint128 x) external {
function testFuzz_intoSD1x18(uint128 x) external pure {
x = boundUint128(x, 0, uint128(uint64(uMAX_SD1x18)));
SD1x18 actual = x.intoSD1x18();
SD1x18 expected = SD1x18.wrap(int64(uint64(x)));
assertEq(actual, expected, "uint128 intoSD1x18");
}

function testFuzz_intoSD59x18(uint128 x) external {
function testFuzz_intoSD59x18(uint128 x) external pure {
SD59x18 actual = x.intoSD59x18();
SD59x18 expected = SD59x18.wrap(int256(uint256(x)));
assertEq(actual, expected, "uint128 intoSD59x18");
Expand All @@ -44,14 +44,14 @@ contract CastingUint128_Test is Base_Test {
x.intoUD2x18();
}

function testFuzz_intoUD2x18(uint128 x) external {
function testFuzz_intoUD2x18(uint128 x) external pure {
x = boundUint128(x, 0, uint128(uMAX_UD2x18));
UD2x18 actual = x.intoUD2x18();
UD2x18 expected = UD2x18.wrap(uint64(x));
assertEq(actual, expected, "uint128 intoUD2x18");
}

function testFuzz_intoUD60x18(uint128 x) external {
function testFuzz_intoUD60x18(uint128 x) external pure {
UD60x18 actual = x.intoUD60x18();
UD60x18 expected = UD60x18.wrap(uint256(x));
assertEq(actual, expected, "uint128 intoUD60x18");
Expand Down
8 changes: 4 additions & 4 deletions test/fuzz/casting/CastingUint256.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract CastingUint256_Test is Base_Test {
x.intoSD1x18();
}

function testFuzz_intoSD1x18(uint256 x) external {
function testFuzz_intoSD1x18(uint256 x) external pure {
x = _bound(x, 0, uint64(uMAX_SD1x18));
SD1x18 actual = x.intoSD1x18();
SD1x18 expected = SD1x18.wrap(int64(uint64(x)));
Expand All @@ -40,7 +40,7 @@ contract CastingUint256_Test is Base_Test {
x.intoSD59x18();
}

function testFuzz_intoSD59x18(uint256 x) external {
function testFuzz_intoSD59x18(uint256 x) external pure {
x = _bound(x, 0, uint256(uMAX_SD59x18));
SD59x18 actual = x.intoSD59x18();
SD59x18 expected = SD59x18.wrap(int256(uint256(x)));
Expand All @@ -53,14 +53,14 @@ contract CastingUint256_Test is Base_Test {
x.intoUD2x18();
}

function testFuzz_intoUD2x18(uint256 x) external {
function testFuzz_intoUD2x18(uint256 x) external pure {
x = _bound(x, 0, uint256(uMAX_UD2x18));
UD2x18 actual = x.intoUD2x18();
UD2x18 expected = UD2x18.wrap(uint64(x));
assertEq(actual, expected, "uint256 intoUD2x18");
}

function testFuzz_intoUD60x18(uint256 x) external {
function testFuzz_intoUD60x18(uint256 x) external pure {
UD60x18 actual = x.intoUD60x18();
UD60x18 expected = UD60x18.wrap(x);
assertEq(actual, expected, "uint256 intoUD60x18");
Expand Down
8 changes: 4 additions & 4 deletions test/fuzz/casting/CastingUint40.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ import { Base_Test } from "../../Base.t.sol";
contract CastingUint40_Test is Base_Test {
using CastingUint40 for uint40;

function testFuzz_intoSD1x18(uint40 x) external {
function testFuzz_intoSD1x18(uint40 x) external pure {
SD1x18 actual = x.intoSD1x18();
SD1x18 expected = SD1x18.wrap(int64(uint64(x)));
assertEq(actual, expected, "uint40 intoSD1x18");
}

function testFuzz_intoSD59x18(uint40 x) external {
function testFuzz_intoSD59x18(uint40 x) external pure {
SD59x18 actual = x.intoSD59x18();
SD59x18 expected = SD59x18.wrap(int256(uint256(x)));
assertEq(actual, expected, "uint40 intoSD59x18");
}

function testFuzz_intoUD2x18(uint40 x) external {
function testFuzz_intoUD2x18(uint40 x) external pure {
UD2x18 actual = x.intoUD2x18();
UD2x18 expected = UD2x18.wrap(uint64(x));
assertEq(actual, expected, "uint40 intoUD2x18");
}

function testFuzz_intoUD60x18(uint40 x) external {
function testFuzz_intoUD60x18(uint40 x) external pure {
UD60x18 actual = x.intoUD60x18();
UD60x18 expected = UD60x18.wrap(uint256(x));
assertEq(actual, expected, "uint40 intoUD60x18");
Expand Down
18 changes: 9 additions & 9 deletions test/fuzz/sd1x18/casting/Casting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Base_Test } from "../../../Base.t.sol";

/// @dev Collection of tests for the casting functions available in SD1x18.
contract Casting_Fuzz_Test is Base_Test {
function testFuzz_IntoSD59x18(SD1x18 x) external {
function testFuzz_IntoSD59x18(SD1x18 x) external pure {
SD59x18 actual = x.intoSD59x18();
SD59x18 expected = SD59x18.wrap(int256(x.unwrap()));
assertEq(actual, expected, "SD1x18 intoSD59x18");
Expand All @@ -32,7 +32,7 @@ contract Casting_Fuzz_Test is Base_Test {
x.intoUD2x18();
}

function testFuzz_IntoUD2x18(SD1x18 x) external {
function testFuzz_IntoUD2x18(SD1x18 x) external pure {
x = _bound(x, 0, MAX_SD1x18);
UD2x18 actual = x.intoUD2x18();
UD2x18 expected = UD2x18.wrap(uint64(x.unwrap()));
Expand All @@ -45,7 +45,7 @@ contract Casting_Fuzz_Test is Base_Test {
x.intoUD60x18();
}

function testFuzz_IntoUD60x18(SD1x18 x) external {
function testFuzz_IntoUD60x18(SD1x18 x) external pure {
x = _bound(x, 0, MAX_SD1x18);
UD60x18 actual = x.intoUD60x18();
UD60x18 expected = UD60x18.wrap(uint64(x.unwrap()));
Expand All @@ -58,7 +58,7 @@ contract Casting_Fuzz_Test is Base_Test {
x.intoUint256();
}

function testFuzz_IntoUint256(SD1x18 x) external {
function testFuzz_IntoUint256(SD1x18 x) external pure {
x = _bound(x, 0, MAX_SD1x18);
uint256 actual = x.intoUint256();
uint256 expected = uint64(x.unwrap());
Expand All @@ -71,7 +71,7 @@ contract Casting_Fuzz_Test is Base_Test {
x.intoUint128();
}

function testFuzz_IntoUint128(SD1x18 x) external {
function testFuzz_IntoUint128(SD1x18 x) external pure {
x = _bound(x, 0, MAX_SD1x18);
uint128 actual = x.intoUint128();
uint128 expected = uint64(x.unwrap());
Expand All @@ -90,26 +90,26 @@ contract Casting_Fuzz_Test is Base_Test {
x.intoUint40();
}

function testFuzz_IntoUint40(SD1x18 x) external {
function testFuzz_IntoUint40(SD1x18 x) external pure {
x = _bound(x, 0, int64(uint64(MAX_UINT40)));
uint40 actual = x.intoUint40();
uint40 expected = uint40(uint64(x.unwrap()));
assertEq(actual, expected, "SD1x18 intoUint40");
}

function testFuzz_sd1x18(int64 x) external {
function testFuzz_sd1x18(int64 x) external pure {
SD1x18 actual = sd1x18(x);
SD1x18 expected = SD1x18.wrap(x);
assertEq(actual, expected, "sd1x18");
}

function testFuzz_Unwrap(SD1x18 x) external {
function testFuzz_Unwrap(SD1x18 x) external pure {
int64 actual = x.unwrap();
int64 expected = SD1x18.unwrap(x);
assertEq(actual, expected, "SD1x18 unwrap");
}

function testFuzz_Wrap(int64 x) external {
function testFuzz_Wrap(int64 x) external pure {
SD1x18 actual = wrap(x);
SD1x18 expected = SD1x18.wrap(x);
assertEq(actual, expected, "SD1x18 wrap");
Expand Down
22 changes: 11 additions & 11 deletions test/fuzz/sd59x18/casting/Casting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Base_Test } from "../../../Base.t.sol";

/// @dev Collection of tests for the casting functions available in SD59x18.
contract SD59x18_Casting_Fuzz_Test is Base_Test {
function testFuzz_IntoInt256(SD59x18 x) external {
function testFuzz_IntoInt256(SD59x18 x) external pure {
int256 actual = x.intoInt256();
int256 expected = SD59x18.unwrap(x);
assertEq(actual, expected, "SD59x18 intoInt256");
Expand All @@ -44,7 +44,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test {
x.intoSD1x18();
}

function testFuzz_IntoSD1x18(SD59x18 x) external {
function testFuzz_IntoSD1x18(SD59x18 x) external pure {
x = _bound(x, uMIN_SD1x18, uMAX_SD1x18);
SD1x18 actual = x.intoSD1x18();
SD1x18 expected = SD1x18.wrap(int64(x.unwrap()));
Expand All @@ -63,7 +63,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test {
x.intoUD2x18();
}

function testFuzz_IntoUD2x18(SD59x18 x) external {
function testFuzz_IntoUD2x18(SD59x18 x) external pure {
x = _bound(x, 0, int256(uint256(uMAX_UD2x18)));
UD2x18 actual = x.intoUD2x18();
UD2x18 expected = UD2x18.wrap(uint64(uint256(x.unwrap())));
Expand All @@ -76,7 +76,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test {
x.intoUD60x18();
}

function testFuzz_IntoUD60x18(SD59x18 x) external {
function testFuzz_IntoUD60x18(SD59x18 x) external pure {
x = _bound(x, 0, MAX_SD59x18);
UD60x18 actual = x.intoUD60x18();
UD60x18 expected = UD60x18.wrap(uint256(x.unwrap()));
Expand All @@ -95,7 +95,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test {
x.intoUint128();
}

function testFuzz_IntoUint128(SD59x18 x) external {
function testFuzz_IntoUint128(SD59x18 x) external pure {
x = _bound(x, 0, int256(uint256(MAX_UINT128)));
uint128 actual = x.intoUint128();
uint128 expected = uint128(uint256(x.unwrap()));
Expand All @@ -108,7 +108,7 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test {
x.intoUint256();
}

function testFuzz_IntoUint256(SD59x18 x) external {
function testFuzz_IntoUint256(SD59x18 x) external pure {
x = _bound(x, 0, MAX_SD59x18);
uint256 actual = x.intoUint256();
uint256 expected = uint256(x.unwrap());
Expand All @@ -127,32 +127,32 @@ contract SD59x18_Casting_Fuzz_Test is Base_Test {
x.intoUint40();
}

function testFuzz_IntoUint40(SD59x18 x) external {
function testFuzz_IntoUint40(SD59x18 x) external pure {
x = _bound(x, 0, int256(uint256(MAX_UINT40)));
uint40 actual = x.intoUint40();
uint40 expected = uint40(uint256(x.unwrap()));
assertEq(actual, expected, "SD59x18 intoUint40");
}

function testFuzz_Sd(int256 x) external {
function testFuzz_Sd(int256 x) external pure {
SD59x18 actual = sd(x);
SD59x18 expected = SD59x18.wrap(x);
assertEq(actual, expected, "sd");
}

function testFuzz_sd59x18(int256 x) external {
function testFuzz_sd59x18(int256 x) external pure {
SD59x18 actual = sd59x18(x);
SD59x18 expected = SD59x18.wrap(x);
assertEq(actual, expected, "sd59x18");
}

function testFuzz_Unwrap(SD59x18 x) external {
function testFuzz_Unwrap(SD59x18 x) external pure {
int256 actual = x.unwrap();
int256 expected = SD59x18.unwrap(x);
assertEq(actual, expected, "SD59x18 unwrap");
}

function testFuzz_Wrap(int256 x) external {
function testFuzz_Wrap(int256 x) external pure {
SD59x18 actual = wrap(x);
SD59x18 expected = SD59x18.wrap(x);
assertEq(actual, expected, "SD59x18 wrap");
Expand Down
Loading