-
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
Conversation
3c92d33
to
8725772
Compare
8725772
to
8d535bd
Compare
await memberRoles.connect(governanceContracts[0]).changeAuthorized(Role.AdvisoryBoard, defaultSender.address); | ||
const authorizedAddressAfter = await memberRoles.authorized(Role.AdvisoryBoard); | ||
|
||
expect(authorizedAddressBefore).not.to.be.eq(defaultSender.address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor, but we've been spelling out eq as equal in other tests
const { defaultSender, governanceContracts } = this.accounts; | ||
|
||
const authorizedAddressBefore = await memberRoles.authorized(Role.AdvisoryBoard); | ||
await memberRoles.connect(governanceContracts[0]).changeAuthorized(Role.AdvisoryBoard, defaultSender.address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use something else other than defaultSender.address
When you write tests, look to make the values arbitrary for generality, whatever that thing that you are switching to is. Arbitrary within constraints of course (eg. arbitrary member)
).to.be.reverted; | ||
await expect( | ||
memberRoles.connect(defaultSender).changeAuthorized(Role.AdvisoryBoard, governanceContracts[0].address), | ||
).to.not.reverted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to.not.be.reverted
const { governanceContracts } = this.accounts; | ||
|
||
const maxABCountBefore = await memberRoles.maxABCount(); | ||
await memberRoles.connect(governanceContracts[0]).changeMaxABCount(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use named constants
const newMaxABCount = 2;
test/unit/MemberRoles/setup.js
Outdated
} | ||
// Setting AB Member | ||
const [abMember] = accounts.advisoryBoardMembers; | ||
await master.enrollMember(abMember.address, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the right constant instead of the 2. Role.whatever
same as below
} = this.accounts; | ||
|
||
const [memberAddress, isActive] = await memberRoles.memberAtIndex(Role.Member, 0); | ||
expect(member.address).to.be.equal(memberAddress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the other way around.
expect(memberAddress).to.be.equal(member.address)
it('should clear storage', async function () { | ||
const { memberRoles } = this.contracts; | ||
|
||
await expect(memberRoles.storageCleanup()).to.not.reverted; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to.not.be.reverted
const isMemberABMember = await memberRoles.checkRole(member.address, Role.AdvisoryBoard); | ||
|
||
expect(isMemberMember).to.be.equal(true); | ||
expect(isMemberNonMember).to.be.equal(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is odd why is this true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isABMemberABMember = await memberRoles.checkRole(advisoryBoardMember.address, Role.AdvisoryBoard); | ||
|
||
expect(isABMemberMember).to.be.equal(true); | ||
expect(isABMemberNonMember).to.be.equal(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also odd that it's true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be "correct" but warrants at least a comment to clarify why since it looks counterintuitive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some changes necessary
8d535bd
to
b58f53e
Compare
b58f53e
to
cc8946d
Compare
a16c0dd
to
7d86896
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now
contracts/mocks/MasterMock.sol
Outdated
enum Role { | ||
NonMember, | ||
Member, | ||
AdvisoryBord, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mispelling here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use Unassigned
(capitalization) and AdvisoryBoard
(missing "a").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but let's fix that mispelling as well since we're here
const { InternalContractsIDs } = require('../utils').constants; | ||
const { expect } = require('chai'); | ||
const { hex } = require('../../../lib/helpers'); | ||
const { ZERO_ADDRESS } = require('../../../lib/constants'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use AddressZero
from ethers.constants
instead
before(async function () { | ||
const { quotationData, memberRoles } = this.contracts; | ||
const { governanceContracts, defaultSender } = this.accounts; | ||
await quotationData.connect(governanceContracts[0]).setKycAuthAddress(defaultSender.address); | ||
await memberRoles.connect(governanceContracts[0]).setKycAuthAddress(quotationData.address); | ||
}); | ||
|
||
it('should change authorized address for the role', async function () { | ||
const { memberRoles, master } = this.contracts; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given there's only one test here, move the contents of the before
in the test itself
a100367
to
bd9c68f
Compare
5caf4db
to
08d767e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still open questions
08d767e
to
6f3fc10
Compare
6f3fc10
to
b46fa6b
Compare
- formatting and code style fixes - added test for `changeDependentContractAddress`
- zero address from ethers - typo fixes - removing unnecessary before
f0a9f3d
to
3c875c9
Compare
Context
Issue: #345
Changes proposed in this pull request
Added unit test to increase the coverage of MomberRoles.
Test plan
N/A
Checklist
Review
When reviewing a PR, please indicate intention in comments using the following emojis: