-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDFacility: contract is disabled upon deployment
- Loading branch information
Showing
13 changed files
with
297 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/policies/ConvertibleDepositFacility/activate.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: Unlicensed | ||
pragma solidity 0.8.15; | ||
|
||
import {ConvertibleDepositFacilityTest} from "./ConvertibleDepositFacilityTest.sol"; | ||
|
||
contract ActivateCDFTest is ConvertibleDepositFacilityTest { | ||
event Activated(); | ||
|
||
// given the caller does not have the emergency_shutdown role | ||
// [X] it reverts | ||
// given the contract is already active | ||
// [X] it does nothing | ||
// [X] it sets the contract to active | ||
// [X] it emits an Activated event | ||
|
||
function test_callerDoesNotHaveRole_reverts() public { | ||
_expectRoleRevert("emergency_shutdown"); | ||
|
||
// Call function | ||
facility.activate(); | ||
} | ||
|
||
function test_contractActive() public givenLocallyActive { | ||
// Call function | ||
vm.prank(emergency); | ||
facility.activate(); | ||
|
||
// Assert state | ||
assertEq(facility.locallyActive(), true, "active"); | ||
} | ||
|
||
function test_success() public { | ||
// Emits event | ||
vm.expectEmit(true, true, true, true); | ||
emit Activated(); | ||
|
||
// Call function | ||
vm.prank(emergency); | ||
facility.activate(); | ||
|
||
// Assert state | ||
assertEq(facility.locallyActive(), true, "active"); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/policies/ConvertibleDepositFacility/constructor.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: Unlicensed | ||
pragma solidity 0.8.15; | ||
|
||
import {ConvertibleDepositFacilityTest} from "./ConvertibleDepositFacilityTest.sol"; | ||
|
||
import {CDFacility} from "src/policies/CDFacility.sol"; | ||
|
||
contract ConstructorCDFTest is ConvertibleDepositFacilityTest { | ||
// [X] it sets the contract to inactive | ||
|
||
function test_success() public { | ||
facility = new CDFacility(address(kernel)); | ||
|
||
// Assert state | ||
assertEq(facility.locallyActive(), false, "inactive"); | ||
} | ||
} |
Oops, something went wrong.