diff --git a/src/Starport.sol b/src/Starport.sol index d5ccf284..22a81af8 100644 --- a/src/Starport.sol +++ b/src/Starport.sol @@ -543,7 +543,7 @@ contract Starport is PausableNonReentrant { emit CaveatFilled(validator, hash, signedCaveats.salt); } - if (block.number > signedCaveats.deadline) { + if (block.timestamp > signedCaveats.deadline) { revert CaveatDeadlineExpired(); } if (!SignatureCheckerLib.isValidSignatureNowCalldata(validator, hash, signedCaveats.signature)) { diff --git a/test/StarportTest.sol b/test/StarportTest.sol index fdd80811..bd351fc0 100644 --- a/test/StarportTest.sol +++ b/test/StarportTest.sol @@ -311,7 +311,7 @@ contract StarportTest is BaseOrderTest, Stargate { signedCaveats = CaveatEnforcer.SignedCaveats({ signature: "", singleUse: invalidate, - deadline: block.number + (1 days / 12), + deadline: block.timestamp + (1 days / 12), salt: salt, caveats: new CaveatEnforcer.Caveat[](1) }); @@ -414,7 +414,7 @@ contract StarportTest is BaseOrderTest, Stargate { signedCaveats.caveats = new CaveatEnforcer.Caveat[](1); signedCaveats.salt = salt; signedCaveats.singleUse = true; - signedCaveats.deadline = block.number + (1 days / 12); + signedCaveats.deadline = block.timestamp + 1 days; signedCaveats.caveats[0] = CaveatEnforcer.Caveat({enforcer: enforcer, data: abi.encode(details)}); bytes32 hash = SP.hashCaveatWithSaltAndNonce( signer.addr, signedCaveats.singleUse, salt, signedCaveats.deadline, signedCaveats.caveats @@ -433,7 +433,7 @@ contract StarportTest is BaseOrderTest, Stargate { signedCaveats.caveats = new CaveatEnforcer.Caveat[](1); signedCaveats.salt = salt; signedCaveats.singleUse = true; - signedCaveats.deadline = block.number + (1 days / 12); + signedCaveats.deadline = block.timestamp + 1 days; signedCaveats.caveats[0] = CaveatEnforcer.Caveat({enforcer: enforcer, data: abi.encode(details)}); bytes32 hash = SP.hashCaveatWithSaltAndNonce( signer.addr, signedCaveats.singleUse, salt, signedCaveats.deadline, signedCaveats.caveats diff --git a/test/integration-testing/TestCaveats.sol b/test/integration-testing/TestCaveats.sol index 1e4f2529..3602b03a 100644 --- a/test/integration-testing/TestCaveats.sol +++ b/test/integration-testing/TestCaveats.sol @@ -68,7 +68,7 @@ contract IntegrationTestCaveats is StarportTest, DeepEq, MockCall { salt: bytes32(uint256(1)), enforcer: address(borrowerEnforcer) }); - vm.roll(borrowerCaveat.deadline + 1); + vm.warp(borrowerCaveat.deadline + 1); _setApprovalsForSpentItems(borrower.addr, loan.collateral); _setApprovalsForSpentItems(lender.addr, loan.debt); diff --git a/test/unit-testing/TestStrategistOriginator.sol b/test/unit-testing/TestStrategistOriginator.sol index 7ba01d3b..c0a24dde 100644 --- a/test/unit-testing/TestStrategistOriginator.sol +++ b/test/unit-testing/TestStrategistOriginator.sol @@ -49,7 +49,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { } function testIncrementCounterAsStrategist() public { - uint256 newCounter = SO.getCounter() + uint256(blockhash(block.number - 1) << 0x80); + uint256 newCounter = SO.getCounter() + uint256(blockhash(block.timestamp - 1) << 0x80); vm.expectEmit(); emit CounterUpdated(newCounter); vm.prank(strategist.addr); @@ -68,7 +68,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -110,7 +110,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -153,7 +153,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -196,7 +196,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -240,7 +240,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -282,7 +282,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -324,7 +324,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -368,7 +368,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -412,7 +412,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.number + 8, + deadline: block.timestamp + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(uint256(1)),