-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reduce the ConvictionVoting MaxVotes from 512 to 30 * Set MaxVote to 20
- Loading branch information
Showing
5 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
test/suites/dev/test-conviction-voting/test-conviction-delegation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}, | ||
}); | ||
}, | ||
}); |