Skip to content

Commit

Permalink
Fix broken tests. Refactor blueprint & utils test contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Psirex committed Aug 7, 2024
1 parent 80a0769 commit 5c6f205
Show file tree
Hide file tree
Showing 36 changed files with 2,633 additions and 2,481 deletions.
2 changes: 1 addition & 1 deletion contracts/types/PercentD16.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.26;

type PercentD16 is uint256;

uint256 constant HUNDRED_PERCENTS_UINT256 = 100 * 10 ** 18;
uint256 constant HUNDRED_PERCENTS_UINT256 = 100 * 10 ** 16;

error Overflow();

Expand Down
36 changes: 17 additions & 19 deletions test/scenario/agent-timelock.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ import {ExternalCall, ScenarioTestBlueprint} from "../utils/scenario-test-bluepr

contract AgentTimelockTest is ScenarioTestBlueprint {
function setUp() external {
_selectFork();
_deployTarget();
_deployDualGovernanceSetup( /* isEmergencyProtectionEnabled */ true);
_deployDualGovernanceSetup({isEmergencyProtectionEnabled: true});
}

function testFork_AgentTimelockHappyPath() external {
ExternalCall[] memory regularStaffCalls = _getTargetRegularStaffCalls();
ExternalCall[] memory regularStaffCalls = _getMockTargetRegularStaffCalls();

uint256 proposalId;
_step("1. THE PROPOSAL IS SUBMITTED");
{
proposalId = _submitProposal(
_dualGovernance, "Propose to doSmth on target passing dual governance", regularStaffCalls
proposalId = _submitProposalViaDualGovernance(
"Propose to doSmth on target passing dual governance", regularStaffCalls
);

_assertSubmittedProposalData(proposalId, _timelock.getAdminExecutor(), regularStaffCalls);
_assertCanSchedule(_dualGovernance, proposalId, false);
_assertSubmittedProposalData(proposalId, _getAdminExecutor(), regularStaffCalls);
_assertCanScheduleViaDualGovernance(proposalId, false);
}

_step("2. THE PROPOSAL IS SCHEDULED");
{
_waitAfterSubmitDelayPassed();
_assertCanSchedule(_dualGovernance, proposalId, true);
_scheduleProposal(_dualGovernance, proposalId);
_assertCanScheduleViaDualGovernance(proposalId, true);
_scheduleProposalViaDualGovernance(proposalId);

_assertProposalScheduled(proposalId);
_assertCanExecute(proposalId, false);
Expand All @@ -48,27 +46,27 @@ contract AgentTimelockTest is ScenarioTestBlueprint {
_assertProposalExecuted(proposalId);

_assertCanExecute(proposalId, false);
_assertCanSchedule(_dualGovernance, proposalId, false);
_assertCanScheduleViaDualGovernance(proposalId, false);

_assertTargetMockCalls(_timelock.getAdminExecutor(), regularStaffCalls);
_assertTargetMockCalls(_getAdminExecutor(), regularStaffCalls);
}
}

function testFork_TimelockEmergencyReset() external {
ExternalCall[] memory regularStaffCalls = _getTargetRegularStaffCalls();
ExternalCall[] memory regularStaffCalls = _getMockTargetRegularStaffCalls();

// ---
// 1. THE PROPOSAL IS SUBMITTED
// ---
uint256 proposalId;
{
proposalId = _submitProposal(
_dualGovernance, "Propose to doSmth on target passing dual governance", regularStaffCalls
proposalId = _submitProposalViaDualGovernance(
"Propose to doSmth on target passing dual governance", regularStaffCalls
);
_assertSubmittedProposalData(proposalId, _timelock.getAdminExecutor(), regularStaffCalls);
_assertSubmittedProposalData(proposalId, _getAdminExecutor(), regularStaffCalls);

// proposal can't be scheduled until the AFTER_SUBMIT_DELAY has passed
_assertCanSchedule(_dualGovernance, proposalId, false);
_assertCanScheduleViaDualGovernance(proposalId, false);
}

// ---
Expand All @@ -80,9 +78,9 @@ contract AgentTimelockTest is ScenarioTestBlueprint {

// when the first delay is passed and the is no opposition from the stETH holders
// the proposal can be scheduled
_assertCanSchedule(_dualGovernance, proposalId, true);
_assertCanScheduleViaDualGovernance(proposalId, true);

_scheduleProposal(_dualGovernance, proposalId);
_scheduleProposalViaDualGovernance(proposalId);

// proposal can't be executed until the second delay has ended
_assertProposalScheduled(proposalId);
Expand Down
Loading

0 comments on commit 5c6f205

Please sign in to comment.