Skip to content

Commit

Permalink
refactor: add test coverage for drop spell done()
Browse files Browse the repository at this point in the history
  • Loading branch information
amusingaxl committed May 15, 2024
1 parent 6e01020 commit c095eb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/EmergencyDropSpell.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ interface EmergencySpellLike {

/// @title A spell that drops a plan from `MCD_PAUSE` when is cast.
contract EmergencyDropSpell is EmergencySpellLike {
bool public constant done = false;
bool public constant officeHours = false;
uint256 public constant expiration = type(uint256).max;
address public constant log = address(0);
Expand Down Expand Up @@ -82,7 +81,7 @@ contract EmergencyDropSpell is EmergencySpellLike {
}

/// @notice Returns whether the original spell has been planned or not.
function planned() external view returns (bool) {
function planned() public view returns (bool) {
return protego.planned(action, tag, sig, eta);
}

Expand All @@ -91,6 +90,11 @@ contract EmergencyDropSpell is EmergencySpellLike {
pause.drop(action, tag, sig, eta);
}

/// @notice Returns whether the original spell has been dropped or not.
function done() external view returns (bool) {
return !planned();
}

/// @notice No-op
function cast() external {}

Expand Down
9 changes: 6 additions & 3 deletions src/Protego.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
pragma solidity ^0.8.16;

import {DssTest} from "dss-test/DssTest.sol";
import {Protego, EmergencyDropSpell, DsSpellLike} from "../src/Protego.sol";
import {Protego, EmergencyDropSpell} from "../src/Protego.sol";
import {ConformingSpell} from "./test/ConformingSpell.sol";
import {NonConformingSpell} from "./test/NonConformingSpell.sol";

Expand Down Expand Up @@ -137,12 +137,15 @@ contract ProtegoTest is DssTest {
_vote(address(badSpell));
badSpell.plot(usr, tag, sig, eta);

assertTrue(protego.planned(usr, tag, sig, eta), "Spell not planned");

EmergencyDropSpell goodSpell = EmergencyDropSpell(protego.deploy(usr, tag, sig, eta));

assertTrue(protego.planned(usr, tag, sig, eta), "Before drop spell: not planned");
assertFalse(goodSpell.done(), "Before drop spell: already done");

_vote(address(goodSpell));
goodSpell.schedule();

assertTrue(goodSpell.done(), "After drop spell: not done");
assertFalse(protego.planned(usr, tag, sig, eta), "After drop spell: spell still planned");
}

Expand Down

0 comments on commit c095eb0

Please sign in to comment.