Skip to content

Commit

Permalink
test: relax unix time test once again (foundry-rs#8362)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jul 4, 2024
1 parent 042b490 commit eff3f43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions testdata/default/cheats/UnixTime.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ contract UnixTimeTest is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

// This is really wide because CI sucks.
uint256 constant errMargin = 500;
uint256 constant errMargin = 1000;

function testUnixTimeAgainstDate() public {
string[] memory inputs = new string[](2);
inputs[0] = "date";
// OS X does not support precision more than 1 second
// OS X does not support precision more than 1 second.
inputs[1] = "+%s000";

bytes memory res = vm.ffi(inputs);
uint256 date = vm.parseUint(string(res));

// Limit precision to 1000 ms
// Limit precision to 1000 ms.
uint256 time = vm.unixTime() / 1000 * 1000;

assertEq(date, time, ".unixTime() is inaccurate");
vm.assertApproxEqAbs(date, time, errMargin, ".unixTime() is inaccurate vs date");
}

function testUnixTime() public {
Expand Down

0 comments on commit eff3f43

Please sign in to comment.