Skip to content

Commit

Permalink
fix: add workaround for rollFork issue
Browse files Browse the repository at this point in the history
  • Loading branch information
amusingaxl committed Aug 31, 2023
1 parent ddf0231 commit aefc5db
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/DssSpell.t.base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,33 @@ contract DssSpellTestBase is Config, DssTest {

function setUp() public {
setValues(address(chief));

spellValues.deployed_spell_created = spellValues.deployed_spell != address(0) ? spellValues.deployed_spell_created : block.timestamp;
_castPreviousSpell();
spell = spellValues.deployed_spell != address(0) ?
DssSpell(spellValues.deployed_spell) : new DssSpell();

spellValues.deployed_spell_created = spellValues.deployed_spell != address(0)
? spellValues.deployed_spell_created
: block.timestamp;
spell = spellValues.deployed_spell != address(0)
? DssSpell(spellValues.deployed_spell)
: new DssSpell();

if (spellValues.deployed_spell_block != 0 && spell.eta() != 0) {
// if we have a deployed spell in the config
// we want to roll our fork to the block where it was deployed
// this means the test suite will continue to accurately pass/fail
// even if mainnet has already scheduled/cast the spell
vm.makePersistent(address(this));
vm.makePersistent(address(rates));
vm.makePersistent(address(addr));
vm.makePersistent(address(deployers));
vm.makePersistent(address(wallets));
vm.rollFork(spellValues.deployed_spell_block);

// Reset `eta` to `0`, otherwise the tests will fail with "This spell has already been scheduled".
// This is a workaround for the issue described here:
// @see { https://github.com/foundry-rs/foundry/issues/5739 }
vm.store(
address(spell),
bytes32(0),
bytes32(0)
);
}
}

Expand Down

0 comments on commit aefc5db

Please sign in to comment.