Skip to content

Commit

Permalink
revert block.number deadline (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xgregthedev authored Dec 11, 2023
1 parent 5731b5f commit b835af2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Starport.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions test/StarportTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/integration-testing/TestCaveats.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions test/unit-testing/TestStrategistOriginator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit b835af2

Please sign in to comment.