Browse Source

integration-tests: assert proposal execution

Mokhtar Naamani 3 years ago
parent
commit
9ada17527a

+ 9 - 0
tests/network-tests/src/fixtures/proposalsModule.ts

@@ -753,3 +753,12 @@ export class VoteForProposalFixture extends BaseFixture {
     this._events = proposalOutcome[1]
   }
 }
+
+export class VoteForProposalAndExpectExecutionFixture extends VoteForProposalFixture {
+  public async execute(): Promise<void> {
+    await super.execute()
+    if (!this.proposalExecuted) {
+      this.error(new Error('Proposal Expected to be executed'))
+    }
+  }
+}

+ 8 - 12
tests/network-tests/src/flows/proposals/manageLeaderRole.ts

@@ -10,7 +10,7 @@ import {
   SetLeaderRewardProposalFixture,
   SlashLeaderProposalFixture,
   TerminateLeaderRoleProposalFixture,
-  VoteForProposalFixture,
+  VoteForProposalAndExpectExecutionFixture,
 } from '../../fixtures/proposalsModule'
 import { ApplyForOpeningFixture } from '../../fixtures/workingGroupModule'
 import { PaidTermId } from '@joystream/types/members'
@@ -76,13 +76,12 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
   await new FixtureRunner(createWorkingGroupLeaderOpeningFixture).run()
 
   // Approve add opening proposal
-  const voteForCreateOpeningProposalFixture = new VoteForProposalFixture(
+  const voteForCreateOpeningProposalFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     createWorkingGroupLeaderOpeningFixture.getCreatedProposalId() as ProposalId
   )
 
   await new FixtureRunner(voteForCreateOpeningProposalFixture).run()
-  assert(voteForCreateOpeningProposalFixture.proposalExecuted)
 
   const openingId = api.findOpeningAddedEvent(voteForCreateOpeningProposalFixture.events, group) as OpeningId
   assert(openingId)
@@ -107,13 +106,12 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
   // Propose begin leader application review
   await new FixtureRunner(beginWorkingGroupLeaderApplicationReviewFixture).run()
 
-  const voteForBeginReviewProposal = new VoteForProposalFixture(
+  const voteForBeginReviewProposal = new VoteForProposalAndExpectExecutionFixture(
     api,
     beginWorkingGroupLeaderApplicationReviewFixture.getCreatedProposalId() as ProposalId
   )
 
   await new FixtureRunner(voteForBeginReviewProposal).run()
-  assert(voteForBeginReviewProposal.proposalExecuted)
 
   const fillLeaderOpeningProposalFixture = new FillLeaderOpeningProposalFixture(
     api,
@@ -128,13 +126,12 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
   // Propose fill leader opening
   await new FixtureRunner(fillLeaderOpeningProposalFixture).run()
 
-  const voteForFillLeaderProposalFixture = new VoteForProposalFixture(
+  const voteForFillLeaderProposalFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     fillLeaderOpeningProposalFixture.getCreatedProposalId() as ProposalId
   )
   // Approve fill leader opening
   await new FixtureRunner(voteForFillLeaderProposalFixture).run()
-  assert(voteForFillLeaderProposalFixture.proposalExecuted)
 
   const hiredLead = await api.getGroupLead(group)
   assert(hiredLead)
@@ -143,14 +140,13 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
   // Propose leader reward
   await new FixtureRunner(setLeaderRewardProposalFixture).run()
 
-  const voteForeLeaderRewardFixture = new VoteForProposalFixture(
+  const voteForeLeaderRewardFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     setLeaderRewardProposalFixture.getCreatedProposalId() as ProposalId
   )
 
   // Approve new leader reward
   await new FixtureRunner(voteForeLeaderRewardFixture).run()
-  assert(voteForeLeaderRewardFixture.proposalExecuted)
 
   const leadId = (await api.getLeadWorkerId(group)) as WorkerId
   assert(leadId)
@@ -172,7 +168,7 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
 
   // let newStake: BN = applicationStake.sub(stakeDecrement)
   // Approve decreased leader stake
-  const voteForDecreaseStakeProposal = new VoteForProposalFixture(
+  const voteForDecreaseStakeProposal = new VoteForProposalAndExpectExecutionFixture(
     api,
     decreaseLeaderStakeProposalFixture.getCreatedProposalId() as ProposalId
   )
@@ -184,7 +180,7 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
 
   // Approve leader slash
   // newStake = newStake.sub(slashAmount)
-  const voteForSlashProposalFixture = new VoteForProposalFixture(
+  const voteForSlashProposalFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     slashLeaderProposalFixture.getCreatedProposalId() as ProposalId
   )
@@ -194,7 +190,7 @@ async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: Working
   // Propose terminate leader role
   await new FixtureRunner(terminateLeaderRoleProposalFixture).run()
 
-  const voteForLeaderRoleTerminationFixture = new VoteForProposalFixture(
+  const voteForLeaderRoleTerminationFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     terminateLeaderRoleProposalFixture.getCreatedProposalId() as ProposalId
   )

+ 5 - 2
tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts

@@ -1,7 +1,10 @@
 import BN from 'bn.js'
 import { Api, WorkingGroups } from '../../Api'
 import { FlowProps } from '../../Flow'
-import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../../fixtures/proposalsModule'
+import {
+  VoteForProposalAndExpectExecutionFixture,
+  WorkingGroupMintCapacityProposalFixture,
+} from '../../fixtures/proposalsModule'
 import { ProposalId } from '@joystream/types/proposals'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
@@ -40,7 +43,7 @@ async function workingGroupMintCapactiy(api: Api, env: NodeJS.ProcessEnv, group:
   // Propose mint capacity
   await new FixtureRunner(workingGroupMintCapacityProposalFixture).run()
 
-  const voteForProposalFixture: VoteForProposalFixture = new VoteForProposalFixture(
+  const voteForProposalFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     workingGroupMintCapacityProposalFixture.getCreatedProposalId() as ProposalId
   )

+ 5 - 2
tests/network-tests/src/flows/workingGroup/workerPayout.ts

@@ -8,7 +8,10 @@ import {
   FillOpeningFixture,
 } from '../../fixtures/workingGroupModule'
 import BN from 'bn.js'
-import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../../fixtures/proposalsModule'
+import {
+  VoteForProposalAndExpectExecutionFixture,
+  WorkingGroupMintCapacityProposalFixture,
+} from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { ProposalId } from '@joystream/types/proposals'
@@ -61,7 +64,7 @@ async function workerPayouts(api: Api, env: NodeJS.ProcessEnv, group: WorkingGro
   await new FixtureRunner(workingGroupMintCapacityProposalFixture).run()
 
   // Approve mint capacity
-  const voteForProposalFixture = new VoteForProposalFixture(
+  const voteForProposalFixture = new VoteForProposalAndExpectExecutionFixture(
     api,
     workingGroupMintCapacityProposalFixture.getCreatedProposalId() as ProposalId
   )