Skip to content

Commit

Permalink
Tests/fin council (#1070)
Browse files Browse the repository at this point in the history
test: add techComm+finCouncil tests, remove duplicates
  • Loading branch information
Maksandre authored Jun 5, 2024
1 parent c9b1f9a commit ed0719f
Show file tree
Hide file tree
Showing 7 changed files with 561 additions and 1 deletion.
2 changes: 2 additions & 0 deletions js-packages/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
},
"mochaExplorer.files": "tests/**/*.test.ts",
"mochaExplorer.require": "ts-node/register",
"mochaExplorer.esmLoader": true,
"mochaExplorer.nodeArgv": ["--loader", "ts-node/esm"],
"eslint.format.enable": true,
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
Expand Down
22 changes: 22 additions & 0 deletions js-packages/test-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ export class Event {
}));
};

static FinCouncil = class extends EventSection('financialCouncil') {
static Proposed = this.Method('Proposed', data => ({
account: eventHumanData(data, 0),
proposalIndex: eventJsonData<number>(data, 1),
proposalHash: eventHumanData(data, 2),
threshold: eventJsonData<number>(data, 3),
}));
static Closed = this.Method('Closed', data => ({
proposalHash: eventHumanData(data, 0),
yes: eventJsonData<number>(data, 1),
no: eventJsonData<number>(data, 2),
}));
static Executed = this.Method('Executed', data => ({
proposalHash: eventHumanData(data, 0),
}));
};

static TechnicalCommittee = class extends EventSection('technicalCommittee') {
static Proposed = this.Method('Proposed', data => ({
account: eventHumanData(data, 0),
Expand Down Expand Up @@ -475,6 +492,7 @@ export class DevUniqueHelper extends UniqueHelper {
scheduler: SchedulerGroup;
collatorSelection: CollatorSelectionGroup;
council: ICollectiveGroup;
finCouncil: ICollectiveGroup;
technicalCommittee: ICollectiveGroup;
fellowship: IFellowshipGroup;
democracy: DemocracyGroup;
Expand All @@ -498,6 +516,10 @@ export class DevUniqueHelper extends UniqueHelper {
collective: new CollectiveGroup(this, 'council'),
membership: new CollectiveMembershipGroup(this, 'councilMembership'),
};
this.finCouncil = {
collective: new CollectiveGroup(this, 'financialCouncil'),
membership: new CollectiveMembershipGroup(this, 'financialCouncilMembership'),
};
this.technicalCommittee = {
collective: new CollectiveGroup(this, 'technicalCommittee'),
membership: new CollectiveMembershipGroup(this, 'technicalCommitteeMembership'),
Expand Down
1 change: 1 addition & 0 deletions js-packages/test-utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export enum Pallets {
Identity = 'identity',
Democracy = 'democracy',
Council = 'council',
FinancialCouncil = 'financialcouncil',
//CouncilMembership = 'councilmembership',
TechnicalCommittee = 'technicalcommittee',
Fellowship = 'fellowshipcollective',
Expand Down
37 changes: 36 additions & 1 deletion js-packages/tests/sub/governance/council.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type {IKeyringPair} from '@polkadot/types/types';
import {usingPlaygrounds, itSub, expect, Pallets, requirePalletsOrSkip, describeGov} from '@unique/test-utils/util.js';
import {Event} from '@unique/test-utils';
import {initCouncil, democracyLaunchPeriod, democracyVotingPeriod, democracyEnactmentPeriod, councilMotionDuration, democracyFastTrackVotingPeriod, fellowshipRankLimit, clearCouncil, clearTechComm, initTechComm, clearFellowship, dummyProposal, dummyProposalCall, initFellowship, defaultEnactmentMoment, fellowshipPropositionOrigin} from './util.js';
import {initCouncil, democracyLaunchPeriod, democracyVotingPeriod, democracyEnactmentPeriod, councilMotionDuration, democracyFastTrackVotingPeriod, fellowshipRankLimit, clearCouncil, clearTechComm, initTechComm, clearFellowship, dummyProposal, dummyProposalCall, initFellowship, defaultEnactmentMoment, fellowshipPropositionOrigin, initFinCouncil} from './util.js';
import type {ICounselors} from './util.js';

describeGov('Governance: Council tests', () => {
Expand Down Expand Up @@ -192,6 +192,25 @@ describeGov('Governance: Council tests', () => {
expect(techCommMembers).to.not.contains(techComm.andy.address);
});

itSub('Council can remove FinCouncil member', async ({helper}) => {
const finCouncil = await initFinCouncil(donor, sudoer);
const removeMemberPrpoposal = helper.finCouncil.membership.removeMemberCall(finCouncil.andy.address);
await proposalFromMoreThanHalfCouncil(removeMemberPrpoposal);

const finCouncilMembers = await helper.finCouncil.membership.getMembers();
expect(finCouncilMembers).to.not.contains(finCouncil.andy.address);
});

itSub('Council can add FinCouncil member', async ({helper}) => {
await initFinCouncil(donor, sudoer);
const newFinCouncilMember = helper.arrange.createEmptyAccount();
const addMemberPrpoposal = helper.finCouncil.membership.addMemberCall(newFinCouncilMember.address);
await proposalFromMoreThanHalfCouncil(addMemberPrpoposal);

const finCouncilMembers = await helper.finCouncil.membership.getMembers();
expect(finCouncilMembers).to.contains(newFinCouncilMember.address);
});

itSub.skip('Council member can add Fellowship member', async ({helper}) => {
const newFellowshipMember = helper.arrange.createEmptyAccount();
await expect(helper.council.collective.execute(
Expand Down Expand Up @@ -328,6 +347,22 @@ describeGov('Governance: Council tests', () => {
)).to.be.rejectedWith('BadOrigin');
});

itSub('[Negative] Council member can\'t add FinCouncil member', async ({helper}) => {
const newFinCouncilMember = helper.arrange.createEmptyAccount();
await expect(helper.council.collective.execute(
counselors.alex,
helper.finCouncil.membership.addMemberCall(newFinCouncilMember.address),
)).rejectedWith('BadOrigin');
});

itSub('[Negative] Council member can\'t remove FinCouncil member', async ({helper}) => {
const finCouncil = await initFinCouncil(donor, sudoer);
await expect(helper.council.collective.execute(
counselors.alex,
helper.finCouncil.membership.removeMemberCall(finCouncil.ildar.address),
)).rejectedWith('BadOrigin');
});

itSub('[Negative] Council member cannot promote/demote a Fellowship member', async ({helper}) => {
const fellowship = await initFellowship(donor, sudoer);
const memberWithRankOne = fellowship[1][0];
Expand Down
Loading

0 comments on commit ed0719f

Please sign in to comment.