diff --git a/src/Starport.sol b/src/Starport.sol index 51dd67ad..7cd710aa 100644 --- a/src/Starport.sol +++ b/src/Starport.sol @@ -537,7 +537,7 @@ contract Starport is PausableNonReentrant { emit CaveatFilled(validator, hash, signedCaveats.salt); } - if (block.timestamp > signedCaveats.deadline) { + if (block.number > signedCaveats.deadline) { revert CaveatDeadlineExpired(); } if (!SignatureCheckerLib.isValidSignatureNowCalldata(validator, hash, signedCaveats.signature)) { diff --git a/test/StarportTest.sol b/test/StarportTest.sol index 346a4148..45fbc6ac 100644 --- a/test/StarportTest.sol +++ b/test/StarportTest.sol @@ -46,7 +46,6 @@ import {TestERC721} from "seaport/contracts/test/TestERC721.sol"; import {TestERC1155} from "seaport/contracts/test/TestERC1155.sol"; import {TestERC20} from "seaport/contracts/test/TestERC20.sol"; import {ConsiderationItemLib} from "seaport/lib/seaport-sol/src/lib/ConsiderationItemLib.sol"; -//import {AAVEPoolCustodian} from "starport-core/custodians/AAVEPoolCustodian.sol"; import {Custodian} from "starport-core/Custodian.sol"; import "seaport/lib/seaport-sol/src/lib/AdvancedOrderLib.sol"; import {Status} from "starport-core/status/Status.sol"; @@ -307,7 +306,7 @@ contract StarportTest is BaseOrderTest { signedCaveats = CaveatEnforcer.SignedCaveats({ signature: "", singleUse: invalidate, - deadline: block.timestamp + 1 days, + deadline: block.number + (1 days / 12), salt: salt, caveats: new CaveatEnforcer.Caveat[](1) }); @@ -410,7 +409,7 @@ contract StarportTest is BaseOrderTest { signedCaveats.caveats = new CaveatEnforcer.Caveat[](1); signedCaveats.salt = salt; signedCaveats.singleUse = true; - signedCaveats.deadline = block.timestamp + 1 days; + signedCaveats.deadline = block.number + (1 days / 12); signedCaveats.caveats[0] = CaveatEnforcer.Caveat({enforcer: enforcer, data: abi.encode(details)}); bytes32 hash = SP.hashCaveatWithSaltAndNonce( signer.addr, signedCaveats.singleUse, salt, signedCaveats.deadline, signedCaveats.caveats @@ -429,7 +428,7 @@ contract StarportTest is BaseOrderTest { signedCaveats.caveats = new CaveatEnforcer.Caveat[](1); signedCaveats.salt = salt; signedCaveats.singleUse = true; - signedCaveats.deadline = block.timestamp + 1 days; + signedCaveats.deadline = block.number + (1 days / 12); 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 4479896a..1e4f2529 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) }); - skip(borrowerCaveat.deadline + 1); + vm.roll(borrowerCaveat.deadline + 1); _setApprovalsForSpentItems(borrower.addr, loan.collateral); _setApprovalsForSpentItems(lender.addr, loan.debt); diff --git a/test/integration-testing/TestNewLoan.sol b/test/integration-testing/TestNewLoan.sol index 5099ee4d..590a0aa7 100644 --- a/test/integration-testing/TestNewLoan.sol +++ b/test/integration-testing/TestNewLoan.sol @@ -293,7 +293,7 @@ contract TestNewLoan is StarportTest { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.timestamp + 100, + deadline: block.number + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -334,7 +334,7 @@ contract TestNewLoan is StarportTest { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.timestamp + 100, + deadline: block.number + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(0), @@ -548,7 +548,7 @@ contract TestNewLoan is StarportTest { signedCaveats = CaveatEnforcer.SignedCaveats({ signature: "", singleUse: invalidate, - deadline: block.timestamp + 1 days, + deadline: block.number + (1 days / 12), salt: salt, caveats: new CaveatEnforcer.Caveat[](1) }); diff --git a/test/unit-testing/TestStrategistOriginator.sol b/test/unit-testing/TestStrategistOriginator.sol index c58b749f..7ba01d3b 100644 --- a/test/unit-testing/TestStrategistOriginator.sol +++ b/test/unit-testing/TestStrategistOriginator.sol @@ -68,7 +68,7 @@ contract TestStrategistOriginator is StarportTest, DeepEq { StrategistOriginator.Details memory newLoanDetails = StrategistOriginator.Details({ custodian: SP.defaultCustodian(), issuer: lender.addr, - deadline: block.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 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.timestamp + 100, + deadline: block.number + 8, offer: StrategistOriginator.Offer({ terms: loan.terms, salt: bytes32(uint256(1)),