Skip to content

Commit

Permalink
add a check for zero address with governanceRebaseOptIn tx
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowDom committed Nov 23, 2024
1 parent db2044a commit 4495130
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions contracts/contracts/token/OUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ contract OUSD is Governable {
* @param _account Address of the account.
*/
function governanceRebaseOptIn(address _account) external onlyGovernor {
require(_account != address(0), "Zero address not allowed");
_rebaseOptIn(_account);
}

Expand Down
18 changes: 16 additions & 2 deletions contracts/test/token/ousd.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,20 @@ describe("Token", function () {
);
});

it("Should allow a governanceRebaseOptIn call", async () => {
let { ousd, governor, mockNonRebasing } = fixture;
await ousd.connect(governor).governanceRebaseOptIn(mockNonRebasing.address);
});

it("Should not allow a governanceRebaseOptIn of a zero address", async () => {
let { ousd, governor } = fixture;
await expect(
ousd
.connect(governor)
.governanceRebaseOptIn("0x0000000000000000000000000000000000000000")
).to.be.revertedWith("Zero address not allowed");
});

it("Should maintain the correct balances when rebaseOptIn is called from non-rebasing contract", async () => {
let { ousd, vault, matt, usdc, josh, mockNonRebasing } = fixture;

Expand Down Expand Up @@ -501,11 +515,11 @@ describe("Token", function () {

const balanceBefore = await ousd.balanceOf(josh.address);

for (let i = 0; i < 10 ; i++) {
for (let i = 0; i < 10; i++) {
await ousd.connect(josh).rebaseOptOut();
await ousd.connect(josh).rebaseOptIn();
}

expect(await ousd.balanceOf(josh.address)).to.equal(balanceBefore);
});

Expand Down

0 comments on commit 4495130

Please sign in to comment.