Skip to content
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

feat: add financial council #1059

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб удалим это?

TechnicalCommittee = 'technicalcommittee',
Fellowship = 'fellowshipcollective',
Expand Down
2 changes: 2 additions & 0 deletions js-packages/tests/pallet-presence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ describe('Pallet presence', () => {
'scheduler',
'technicalcommittee',
'technicalcommitteemembership',
'financialcouncil',
'financialcouncilmembership',
'identity',
];
const testUtils = 'testutils';
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
Loading