This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.18; | |
import { Test } from "forge-std/Test.sol"; | |
import { arange } from "solidity-generators/Generators.sol"; | |
contract MyTest is Test { | |
function testFuzz_OrderedArr(uint256[] memory arr) internal view { | |
vm.assume(arr.length != 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.17; | |
import { PRBTest } from "@prb/test/PRBTest.sol"; | |
contract ForgeTestNamingConvention is PRBTest { | |
// Standard tests | |
function test_Description() external {} | |
// Tests expecting a revert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity =0.8.17; | |
function quickSort(uint40[] memory arr, uint40 left, uint40 right) internal pure { | |
if (left >= right) { | |
return; | |
} | |
unchecked { | |
// p = the pivot element | |
uint40 p = arr[(left + right) / 2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "Cache RPC Responses" | |
uses: "actions/cache@v3" | |
with: | |
path: "~/.foundry/cache/rpc/mainnet/16183456" | |
key: "${{ runner.os }}-mainnet-16183456" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.13; | |
import "@prb/math/SD59x18.sol"; | |
function allMathFunctions(SD59x18 x, SD59x18 y) pure { | |
abs(x); | |
avg(x, y); | |
ceil(x); | |
div(x, y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @notice Finds the zero-based index of the first 1 in the binary representation of x. | |
/// @dev See the note on msb in the "Find First Set" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set | |
/// @param x The uint256 number for which to find the index of the most significant bit. | |
/// @return result The index of the most significant bit as an uint256. | |
function msb(uint256 x) pure returns (uint256 result) { | |
unchecked { | |
if (x >= 2 ** 128) { | |
x >>= 128; | |
result += 128; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.15; | |
function checkSameSign(int256 a, int256 b) pure returns (bool sameSign) { | |
// Get the signs of a and b. | |
uint256 sa; | |
uint256 sb; | |
assembly { | |
// This works due to two's complement representation. | |
// "sgt" stamds for "signed greater than". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.15; | |
contract StructMemberGetter { | |
error NotAuthorized(address caller); | |
struct MyStruct { | |
address owner; | |
} |
0x0d5aaf2f3cb80039dc489378a620f78034fdb30ba46d721c3191c92e9f56a06f