-
Notifications
You must be signed in to change notification settings - Fork 66
Test: Unit tests for Member Role #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e57e33b
Add test for Member Role
MilGard91 672362a
Review changes:
MilGard91 5a4e136
fix: Roles discrepancy in MemberRoles and MasterMock
MilGard91 8d0b82e
Fix: UnAssigned naming
MilGard91 26667d6
Review changes:
MilGard91 002aefd
Replace `UnAssigned` with `Unassigned`
shark0der 249e9ee
Simplify QD deploy and padding of the role name/description strings
shark0der 0a1845a
Remove oz import and implement revert using chai's expect
shark0der 3c875c9
Use deep equal for arrays and other stylistic fixes
shark0der 6539b25
Remove unused variable
shark0der File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,11 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
pragma solidity ^0.8.16; | ||
|
||
contract MRMockQuotationData { | ||
address public kycAuthAddress; | ||
|
||
function setKycAuthAddress(address _add) external { | ||
kycAuthAddress = _add; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
const { Role } = require('../utils').constants; | ||
const { expect } = require('chai'); | ||
|
||
describe('changeAuthorized', function () { | ||
it('should change authorized address for the role', async function () { | ||
const { memberRoles } = this.contracts; | ||
const { | ||
advisoryBoardMembers: [advisoryBoardMember], | ||
governanceContracts, | ||
} = this.accounts; | ||
|
||
const authorizedAddressBefore = await memberRoles.authorized(Role.AdvisoryBoard); | ||
await memberRoles.connect(governanceContracts[0]).changeAuthorized(Role.AdvisoryBoard, advisoryBoardMember.address); | ||
const authorizedAddressAfter = await memberRoles.authorized(Role.AdvisoryBoard); | ||
|
||
expect(authorizedAddressBefore).not.to.be.equal(advisoryBoardMember.address); | ||
expect(authorizedAddressAfter).to.be.equal(advisoryBoardMember.address); | ||
|
||
await expect( | ||
memberRoles.connect(governanceContracts[0]).changeAuthorized(Role.AdvisoryBoard, governanceContracts[0].address), | ||
).to.be.reverted; | ||
await expect( | ||
memberRoles.connect(advisoryBoardMember).changeAuthorized(Role.AdvisoryBoard, governanceContracts[0].address), | ||
).to.not.be.reverted; | ||
}); | ||
roxdanila marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('should revert if the caller is not authorized', async function () { | ||
const { memberRoles } = this.contracts; | ||
const { defaultSender } = this.accounts; | ||
|
||
await expect( | ||
memberRoles.connect(defaultSender).changeAuthorized(Role.AdvisoryBoard, defaultSender.address), | ||
).to.be.revertedWith('Not Authorized'); | ||
}); | ||
}); |
This file contains hidden or 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,43 @@ | ||
const { ethers } = require('hardhat'); | ||
const { expect } = require('chai'); | ||
|
||
const { InternalContractsIDs } = require('../utils').constants; | ||
const { hex } = require('../utils').helpers; | ||
|
||
const { AddressZero } = ethers.constants; | ||
|
||
describe('changeDependentContractAddress', function () { | ||
it('should change authorized address for the role', async function () { | ||
const { quotationData, memberRoles, master } = this.contracts; | ||
const { governanceContracts, defaultSender } = this.accounts; | ||
|
||
await quotationData.connect(governanceContracts[0]).setKycAuthAddress(defaultSender.address); | ||
await memberRoles.connect(governanceContracts[0]).setKycAuthAddress(quotationData.address); | ||
|
||
const tkAddressBefore = await memberRoles.internalContracts(InternalContractsIDs.TK); | ||
const tcAddressBefore = await memberRoles.internalContracts(InternalContractsIDs.TC); | ||
const p1AddressBefore = await memberRoles.internalContracts(InternalContractsIDs.P1); | ||
const coAddressBefore = await memberRoles.internalContracts(InternalContractsIDs.CO); | ||
|
||
await master.setLatestAddress(hex('CO'), AddressZero); | ||
await master.setTokenAddress(AddressZero); | ||
await master.setLatestAddress(hex('TC'), AddressZero); | ||
await master.setLatestAddress(hex('P1'), AddressZero); | ||
|
||
await memberRoles.changeDependentContractAddress(); | ||
const tkAddressAfter = await memberRoles.internalContracts(InternalContractsIDs.TK); | ||
const tcAddressAfter = await memberRoles.internalContracts(InternalContractsIDs.TC); | ||
const p1AddressAfter = await memberRoles.internalContracts(InternalContractsIDs.P1); | ||
const coAddressAfter = await memberRoles.internalContracts(InternalContractsIDs.CO); | ||
|
||
expect(tkAddressAfter).not.to.be.equal(tkAddressBefore); | ||
expect(p1AddressAfter).not.to.be.equal(tcAddressBefore); | ||
expect(tcAddressAfter).not.to.be.equal(p1AddressBefore); | ||
expect(coAddressAfter).not.to.be.equal(coAddressBefore); | ||
|
||
expect(tkAddressAfter).to.be.equal(AddressZero); | ||
expect(tcAddressAfter).to.be.equal(AddressZero); | ||
expect(p1AddressAfter).to.be.equal(AddressZero); | ||
expect(coAddressAfter).to.be.equal(AddressZero); | ||
}); | ||
}); |
This file contains hidden or 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,25 @@ | ||
const { expect } = require('chai'); | ||
|
||
describe('changeMaxABCount', function () { | ||
const newMaxABCount = 2; | ||
it('should change max AB count', async function () { | ||
const { memberRoles } = this.contracts; | ||
const { governanceContracts } = this.accounts; | ||
|
||
const maxABCountBefore = await memberRoles.maxABCount(); | ||
await memberRoles.connect(governanceContracts[0]).changeMaxABCount(newMaxABCount); | ||
const maxABCountAfter = await memberRoles.maxABCount(); | ||
|
||
expect(maxABCountBefore).not.to.be.eq(maxABCountAfter); | ||
expect(maxABCountAfter).to.be.eq(newMaxABCount); | ||
}); | ||
shark0der marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('should revert if the caller is not authorized to govern', async function () { | ||
const { memberRoles } = this.contracts; | ||
const { defaultSender } = this.accounts; | ||
|
||
await expect(memberRoles.connect(defaultSender).changeMaxABCount(newMaxABCount)).to.be.revertedWith( | ||
'Caller is not authorized to govern', | ||
); | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.