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

Decrease the value of maximum concurrent votes is OpenGov #2401

Merged
merged 4 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/moonbase/src/governance/referenda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl pallet_conviction_voting::Config for Runtime {
type Polls = Referenda;
type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
// Maximum number of concurrent votes an account may have
type MaxVotes = ConstU32<512>;
type MaxVotes = ConstU32<20>;
// Minimum period of vote locking
type VoteLockingPeriod = VoteLockingPeriod;
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/moonbeam/src/governance/referenda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl pallet_conviction_voting::Config for Runtime {
type Polls = Referenda;
type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
// Maximum number of concurrent votes an account may have
type MaxVotes = ConstU32<512>;
type MaxVotes = ConstU32<20>;
// Minimum period of vote locking
type VoteLockingPeriod = VoteLockingPeriod;
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/moonriver/src/governance/referenda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl pallet_conviction_voting::Config for Runtime {
type Polls = Referenda;
type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
// Maximum number of concurrent votes an account may have
type MaxVotes = ConstU32<512>;
type MaxVotes = ConstU32<20>;
// Minimum period of vote locking
type VoteLockingPeriod = VoteLockingPeriod;
}
Expand Down
12 changes: 11 additions & 1 deletion test/helpers/expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,17 @@ export function expectSubstrateEvent<
event = foundEvents[0];
}
}
expect(event).to.not.be.undefined;
expect(
event,
`Event ${section.toString()}.${method.toString()} not found:\n${(Array.isArray(block.result)
? block.result.map((r) => r.events).flat()
: block.result
? block.result.events
: []
)
.map(({ event }) => ` - ${event.section.toString()}.${event.method.toString()}\n`)
.join("")}`
).to.not.be.undefined;
return event!.event as any;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import "@moonbeam-network/api-augment";
import { beforeAll, describeSuite, expect, proposeReferendaAndDeposit } from "@moonwall/cli";
import { ALITH_ADDRESS, GLMR, alith, baltathar, faith } from "@moonwall/util";
import { expectSubstrateEvent } from "../../../helpers/expect.js";

describeSuite({
id: "D2600",
title: "Conviction Voting - Delegation",
foundationMethods: "dev",
testCases: ({ context, it }) => {
let refIndex: number;
let proposalHash: string;
beforeAll(async () => {
// The proposal itself
const proposal = context.polkadotJs().tx.identity.setIdentity({ display: { raw: "Me" } });
[refIndex, proposalHash] = await proposeReferendaAndDeposit(context, alith, proposal, {
System: "root",
});
});

it({
id: "T01",
title: "Alith should be able to delegate to Baltathar",
test: async function () {
const rootTrack = context
.polkadotJs()
.consts.referenda.tracks.find(([, track]) => track.name.eq("root"))!;

const blockResult = await context.createBlock(
context
.polkadotJs()
.tx.convictionVoting.delegate(rootTrack[0], baltathar.address, "Locked1x", 100n * GLMR)
);

expectSubstrateEvent(blockResult, "convictionVoting", "Delegated");
const votingFor = await context
.polkadotJs()
.query.convictionVoting.votingFor(ALITH_ADDRESS, rootTrack[0]);
expect(votingFor.isDelegating).toBe(true);
expect(votingFor.asDelegating.target.toString()).toBe(baltathar.address);
expect(votingFor.asDelegating.balance.toBigInt()).toBe(100n * GLMR);
},
});

it({
id: "T02",
title: "Alith should not be able to delegate to the same track twice",
test: async function () {
const rootTrack = context
.polkadotJs()
.consts.referenda.tracks.find(([, track]) => track.name.eq("root"))!;

const blockResult = await context.createBlock(
context
.polkadotJs()
.tx.convictionVoting.delegate(rootTrack[0], faith.address, "Locked1x", 100n * GLMR)
);

expectSubstrateEvent(blockResult, "system", "ExtrinsicFailed");
},
});

it({
id: "T03",
title: "Alith should be able to undelegate",
test: async function () {
const rootTrack = context
.polkadotJs()
.consts.referenda.tracks.find(([, track]) => track.name.eq("root"))!;

const blockResult = await context.createBlock(
await context.polkadotJs().tx.convictionVoting.undelegate(rootTrack[0])
);

expectSubstrateEvent(blockResult, "convictionVoting", "Undelegated");
},
});
},
});