Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Jun 7, 2024
1 parent 014c622 commit b80964b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/contracts/test/unit-testing/main-voting-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,25 @@ describe('Main Voting Plugin', function () {
});
});

context('Joining a space via MemberAccessPlugin', () => {
it('Proposing new members via MemberAccess plugin grants membership', async () => {
expect(await mainVotingPlugin.isMember(carol.address)).to.be.false;
await mainVotingPlugin.proposeAddMember(
toUtf8Bytes('ipfs://'),
carol.address
);
expect(await mainVotingPlugin.isMember(carol.address)).to.be.true;

// 2
expect(await mainVotingPlugin.isMember(ADDRESS_THREE)).to.be.false;
await mainVotingPlugin.proposeAddMember(
toUtf8Bytes('ipfs://'),
ADDRESS_THREE
);
expect(await mainVotingPlugin.isMember(ADDRESS_THREE)).to.be.true;
});
});

context('Leaving a space', () => {
it('Completely removes an editor', async () => {
await makeEditor(bob.address);
Expand Down
42 changes: 41 additions & 1 deletion packages/contracts/test/unit-testing/member-access-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,47 @@ describe('Member Access Plugin', function () {
});

describe('Before approving', () => {
it('Allows any address to request membership', async () => {
it('Only addresses with PROPOSER_PERMISSION_ID can propose members', async () => {
// ok
await expect(
mainVotingPlugin.proposeAddMember(toUtf8Bytes('ipfs://'), carol.address)
).to.not.be.reverted;

await dao.revoke(
memberAccessPlugin.address,
mainVotingPlugin.address,
PROPOSER_PERMISSION_ID
);

// Now it fails
await expect(
mainVotingPlugin.proposeAddMember(toUtf8Bytes('ipfs://'), dave.address)
).to.be.reverted;
});

it('Only callers implementing multisig can propose members', async () => {
// From a compatible plugin
await expect(
mainVotingPlugin.proposeAddMember(toUtf8Bytes('ipfs://'), carol.address)
).to.not.be.reverted;

await dao.grant(
memberAccessPlugin.address,
alice.address,
PROPOSER_PERMISSION_ID
);

// Fail despite the permission
await expect(
memberAccessPlugin.proposeAddMember(
toUtf8Bytes('ipfs://'),
dave.address,
alice.address
)
).to.be.reverted;
});

it('Allows any address to request membership via the MainVoting plugin', async () => {
// Random
expect(await mainVotingPlugin.isMember(carol.address)).to.be.false;
pid = await memberAccessPlugin.proposalCount();
Expand Down

0 comments on commit b80964b

Please sign in to comment.