Browse Source

bug fixing, code cleaning

Gleb Urvanov 4 years ago
parent
commit
0c860cc843
25 changed files with 279 additions and 137 deletions
  1. 1 1
      .prettierrc.js
  2. 1 1
      tests/network-tests/package.json
  3. 7 7
      tests/network-tests/src/iznik/tests/council/electingCouncilTest.ts
  4. 5 2
      tests/network-tests/src/iznik/tests/fixtures/councilElectionModule.ts
  5. 0 0
      tests/network-tests/src/iznik/tests/fixtures/interfaces/fixture.ts
  6. 7 1
      tests/network-tests/src/iznik/tests/fixtures/membershipModule.ts
  7. 59 18
      tests/network-tests/src/iznik/tests/fixtures/proposalsModule.ts
  8. 65 25
      tests/network-tests/src/iznik/tests/fixtures/workingGroupModule.ts
  9. 7 7
      tests/network-tests/src/iznik/tests/membership/membershipCreationTest.ts
  10. 4 4
      tests/network-tests/src/iznik/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts
  11. 4 4
      tests/network-tests/src/iznik/tests/proposals/electionParametersProposalTest.ts
  12. 7 7
      tests/network-tests/src/iznik/tests/proposals/manageLeaderRole.ts
  13. 4 4
      tests/network-tests/src/iznik/tests/proposals/setLeadProposalTest.ts
  14. 4 4
      tests/network-tests/src/iznik/tests/proposals/spendingProposalTest.ts
  15. 4 4
      tests/network-tests/src/iznik/tests/proposals/textProposalTest.ts
  16. 4 4
      tests/network-tests/src/iznik/tests/proposals/updateRuntimet.ts
  17. 4 4
      tests/network-tests/src/iznik/tests/proposals/validatorCountProposalTest.ts
  18. 5 5
      tests/network-tests/src/iznik/tests/proposals/workingGroupMintCapacityProposalTest.ts
  19. 3 3
      tests/network-tests/src/iznik/tests/workingGroup/atLeastValueBugTest.ts
  20. 5 5
      tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsLeadTest.ts
  21. 5 5
      tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsWorkerTest.ts
  22. 3 3
      tests/network-tests/src/iznik/tests/workingGroup/workerApplicationHappyCaseTest.ts
  23. 3 3
      tests/network-tests/src/iznik/tests/workingGroup/workerApplicationRejectionCaseTest.ts
  24. 67 15
      tests/network-tests/src/iznik/tests/workingGroup/workerPayoutTest.ts
  25. 1 1
      tests/network-tests/src/iznik/utils/closeApi.ts

+ 1 - 1
.prettierrc.js

@@ -1,3 +1,3 @@
 module.exports = {
-  ...require('./devops/prettier-config'),
+  ...require('@joystream/prettier-config'),
 }

+ 1 - 1
tests/network-tests/package.json

@@ -7,7 +7,7 @@
     "test": "tap --files src/nicaea/tests/proposals/*Test.ts --files src/nicaea/tests/workingGroup/*Test.ts -T",
     "test-migration-constantinople": "tap --files src/rome/tests/romeRuntimeUpgradeTest.ts --files src/constantinople/tests/electingCouncilTest.ts -T",
     "test-migration-nicaea": "tap --files src/constantinople/tests/proposals/updateRuntimeTest.ts --files src/nicaea/tests/electingCouncilTest.ts -T",
-    "debug": "tap --files src/iznik/tests/proposals/manageLeaderRole.ts -T",
+    "debug": "tap --files src/iznik/tests/workingGroup/*Test.ts -T",
     "lint": "eslint . --quiet --ext .ts",
     "checks": "yarn lint && tsc --noEmit --pretty && prettier ./ --check",
     "format": "prettier ./ --write "

+ 7 - 7
tests/network-tests/src/iznik/tests/electingCouncilTest.ts → tests/network-tests/src/iznik/tests/council/electingCouncilTest.ts

@@ -1,15 +1,15 @@
 import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../utils/config'
+import { initConfig } from '../../utils/config'
 import { Keyring, WsProvider } from '@polkadot/api'
-import { setTestTimeout } from '../utils/setTestTimeout'
+import { setTestTimeout } from '../../utils/setTestTimeout'
 import BN from 'bn.js'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { closeApi } from './impl/closeApi'
-import { BuyMembershipHappyCaseFixture } from './impl/membershipModule'
-import { ElectCouncilFixture } from './impl/councilElectionModule'
-import { Utils } from '../utils/utils'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { closeApi } from '../../utils/closeApi'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { Utils } from '../../utils/utils'
 
 tap.mocha.describe('Electing council scenario', async () => {
   initConfig()

+ 5 - 2
tests/network-tests/src/iznik/tests/impl/councilElectionModule.ts → tests/network-tests/src/iznik/tests/fixtures/councilElectionModule.ts

@@ -5,7 +5,7 @@ import { assert } from 'chai'
 import { Seat } from '@nicaea/types/council'
 import { v4 as uuid } from 'uuid'
 import { Utils } from '../../utils/utils'
-import { Fixture } from '../../utils/fixture'
+import { Fixture } from './interfaces/fixture'
 
 export class ElectCouncilFixture implements Fixture {
   private apiWrapper: ApiWrapper
@@ -67,7 +67,7 @@ export class ElectCouncilFixture implements Fixture {
       this.apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
         assert(
           stake.eq(this.greaterStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${this.greaterStake}`
+          `${keyPair.address} not applied correctly for council election with stake ${stake} versus expected ${this.greaterStake}`
         )
       })
     )
@@ -133,5 +133,8 @@ export class ElectCouncilFixture implements Fixture {
         `Member ${seat.member} has unexpected stake ${Utils.getTotalStake(seat)}`
       )
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }

+ 0 - 0
tests/network-tests/src/iznik/utils/fixture.ts → tests/network-tests/src/iznik/tests/fixtures/interfaces/fixture.ts


+ 7 - 1
tests/network-tests/src/iznik/tests/impl/membershipModule.ts → tests/network-tests/src/iznik/tests/fixtures/membershipModule.ts

@@ -2,7 +2,7 @@ import { ApiWrapper } from '../../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'
-import { Fixture } from '../../utils/fixture'
+import { Fixture } from './interfaces/fixture'
 
 export class BuyMembershipHappyCaseFixture implements Fixture {
   private apiWrapper: ApiWrapper
@@ -48,6 +48,9 @@ export class BuyMembershipHappyCaseFixture implements Fixture {
         .getMemberIds(keyPair.address)
         .then((membership) => assert(membership.length > 0, `Account ${keyPair.address} is not a member`))
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -96,5 +99,8 @@ export class BuyMembershipWithInsufficienFundsFixture implements Fixture {
     this.apiWrapper
       .getMemberIds(this.aKeyPair.address)
       .then((membership) => assert(membership.length === 0, 'Account A is a member'))
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }

+ 59 - 18
tests/network-tests/src/iznik/tests/proposals/impl/proposalsModule.ts → tests/network-tests/src/iznik/tests/fixtures/proposalsModule.ts

@@ -1,10 +1,10 @@
 import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper, WorkingGroups } from '../../../utils/apiWrapper'
+import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { v4 as uuid } from 'uuid'
 import BN from 'bn.js'
-import { WorkingGroupOpening } from '../../../dto/workingGroupOpening'
-import { FillOpeningParameters } from '../../../dto/fillOpeningParameters'
-import { Fixture } from '../../../utils/fixture'
+import { WorkingGroupOpening } from '../../dto/workingGroupOpening'
+import { FillOpeningParameters } from '../../dto/fillOpeningParameters'
+import { Fixture } from './interfaces/fixture'
 import { Bytes } from '@polkadot/types'
 import { assert } from 'chai'
 
@@ -81,6 +81,9 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
     )
     const proposalNumber: BN = await proposalPromise
     this.result = proposalNumber
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -131,8 +134,10 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
       this.openingId,
       this.workingGroup
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -207,8 +212,10 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
       proposalStake,
       fillOpeningParameters
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -270,8 +277,10 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
       this.slash,
       workingGroupString
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -325,8 +334,10 @@ export class SetLeaderRewardProposalFixture implements Fixture {
       this.payoutAmount,
       workingGroupString
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -380,8 +391,10 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
       this.stakeDecrement,
       workingGroupString
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -435,8 +448,10 @@ export class SlashLeaderProposalFixture implements Fixture {
       this.slashAmount,
       workingGroupString
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -488,8 +503,10 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
       this.mintCapacity,
       workingGroupString
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -610,6 +627,9 @@ export class ElectionParametersProposalFixture implements Fixture {
       proposedMinVotingStake.eq(newMinVotingStake),
       `Min voting stake has unexpected value ${newMinVotingStake}, expected ${proposedMinVotingStake}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -657,6 +677,9 @@ export class SetLeadProposalFixture implements Fixture {
       newLead === this.m1KeyPairs[1].address,
       `New lead has unexpected value ${newLead}, expected ${this.m1KeyPairs[1].address}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -726,6 +749,9 @@ export class SpendingProposalFixture implements Fixture {
         this.m1KeyPairs[0].address
       } has unexpected balance ${balanceAfterMinting}, expected ${balanceBeforeMinting.add(this.spendingBalance)}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -769,6 +795,9 @@ export class TextProposalFixture implements Fixture {
     const textProposalPromise = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await textProposalPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -827,6 +856,9 @@ export class ValidatorCountProposalFixture implements Fixture {
       proposedValidatorCount.eq(newValidatorCount),
       `Validator count has unexpeccted value ${newValidatorCount}, expected ${proposedValidatorCount}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -889,6 +921,9 @@ export class ContentWorkingGroupMintCapacityProposalFixture implements Fixture {
       proposedMintingCapacity.eq(newMintingCapacity),
       `Content working group has unexpected minting capacity ${newMintingCapacity}, expected ${proposedMintingCapacity}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -937,6 +972,9 @@ export class UpdateRuntimeFixture implements Fixture {
     const runtimePromise = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await runtimePromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -961,5 +999,8 @@ export class VoteForProposalFixture implements Fixture {
     const proposalExecutionPromise = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, this.proposalNumber)
     await proposalExecutionPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }

+ 65 - 25
tests/network-tests/src/iznik/tests/workingGroup/impl/workingGroupModule.ts → tests/network-tests/src/iznik/tests/fixtures/workingGroupModule.ts

@@ -1,16 +1,16 @@
 import BN from 'bn.js'
 import { assert } from 'chai'
-import { ApiWrapper, WorkingGroups } from '../../../utils/apiWrapper'
+import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { Balance, Event } from '@polkadot/types/interfaces'
 import { Keyring } from '@polkadot/api'
 import { v4 as uuid } from 'uuid'
 import { RewardRelationship } from '@nicaea/types/recurring-rewards'
 import { Worker, ApplicationIdToWorkerIdMap, Application } from '@nicaea/types/working-group'
-import { Utils } from '../../../utils/utils'
+import { Utils } from '../../utils/utils'
 import { Opening as HiringOpening } from '@nicaea/types/hiring'
-import { WorkingGroupOpening } from '../../../dto/workingGroupOpening'
-import { Fixture } from '../../../utils/fixture'
+import { WorkingGroupOpening } from '../../dto/workingGroupOpening'
+import { Fixture } from './interfaces/fixture'
 
 export class AddWorkerOpeningFixture implements Fixture {
   private apiWrapper: ApiWrapper
@@ -156,8 +156,10 @@ export class AddLeaderOpeningFixture implements Fixture {
     const addOpeningPromise: Promise<Event> = this.apiWrapper.expectEvent('OpeningAdded')
     await this.apiWrapper.sudoAddOpening(this.sudo, opening, this.module)
     const openingId: BN = ((await addOpeningPromise).data[0] as unknown) as BN
-
     this.result = openingId
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -192,6 +194,9 @@ export class AcceptApplicationsFixture implements Fixture {
 
     const opening: HiringOpening = await this.apiWrapper.getHiringOpening(this.openingId)
     assert(opening.is_active, `Opening ${this.openingId} is not active`)
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -272,6 +277,9 @@ export class WithdrawApplicationFixture implements Fixture {
       )
       assert(activeApplications.length === 0, `Unexpected active application found for ${keyPair.address}`)
     })
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -299,6 +307,9 @@ export class BeginApplicationReviewFixture implements Fixture {
     const beginApplicantReviewPromise: Promise<BN> = this.apiWrapper.expectApplicationReviewBegan()
     await this.apiWrapper.beginApplicantReview(this.lead, this.openingId, this.module)
     await beginApplicantReviewPromise
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -318,6 +329,9 @@ export class BeginLeaderApplicationReviewFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     // Begin application review
     await this.apiWrapper.sudoBeginApplicantReview(this.sudo, this.openingId, this.module)
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -395,6 +409,9 @@ export class FillOpeningFixture implements Fixture {
     this.membersKeyPairs.forEach((keyPair) =>
       assert(openingWorkersAccounts.includes(keyPair.address), `Account ${keyPair.address} is not worker`)
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -468,6 +485,9 @@ export class FillLeaderOpeningFixture implements Fixture {
       openingLeaderAccount === this.membersKeyPairs[0].address,
       `Unexpected leader account ${openingLeaderAccount}, expected ${this.membersKeyPairs[0].address}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -505,6 +525,9 @@ export class IncreaseStakeFixture implements Fixture {
       increasedWorkerStake.eq(newWorkerStake),
       `Unexpected worker stake ${newWorkerStake}, expected ${increasedWorkerStake}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -543,6 +566,9 @@ export class UpdateRewardAccountFixture implements Fixture {
       newRewardAccount === createdAccount.address,
       `Unexpected role account ${newRewardAccount}, expected ${createdAccount.address}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -585,6 +611,9 @@ export class UpdateRoleAccountFixture implements Fixture {
     )
 
     this.membersKeyPairs[0] = createdAccount
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -627,6 +656,9 @@ export class TerminateApplicationsFixture implements Fixture {
       )
       assert(activeApplications.length === 0, `Account ${keyPair.address} has unexpected active applications`)
     })
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -768,7 +800,7 @@ export class LeaveRoleFixture implements Fixture {
     const leaveRoleFee = this.apiWrapper.estimateLeaveRoleFee(this.module)
     await this.apiWrapper.transferBalanceToAccounts(this.sudo, this.membersKeyPairs, leaveRoleFee)
 
-    await this.apiWrapper.batchLeaveRole(this.membersKeyPairs, uuid().substring(0, 8), false, this.module)
+    await this.apiWrapper.batchLeaveRole(this.membersKeyPairs, uuid().substring(0, 8), expectFailure, this.module)
 
     // Assertions
     this.membersKeyPairs.forEach(async (keyPair) => {
@@ -821,28 +853,12 @@ export class AwaitPayoutFixture implements Fixture {
       balanceAfterSecondPayout.eq(expectedBalanceSecond),
       `Unexpected balance, expected ${expectedBalanceSecond} got ${balanceAfterSecondPayout}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
-// export class SetMintCapacityFixture implements Fixture {
-//   private apiWrapper: ApiWrapper
-//   private sudo: KeyringPair
-//   private capacity: BN
-//   private module: WorkingGroups
-//
-//   constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, capacity:, module: WorkingGroups) {
-//     this.apiWrapper = apiWrapper;
-//     this.sudo = sudo;
-//     this.capacity = capacity;
-//     this.module = module;
-//   }
-//
-//   public async runner(expectFailure: boolean): Promise<void> {
-//     await this.apiWrapper.sudoSetWorkingGroupMintCapacity(this.sudo, this.capacity, this.module)
-//   }
-//
-// }
-
 export class ExpectLeadOpeningAddedFixture implements Fixture {
   private apiWrapper: ApiWrapper
 
@@ -866,6 +882,9 @@ export class ExpectLeadOpeningAddedFixture implements Fixture {
     const event: Event = await this.apiWrapper.expectEvent('OpeningAdded')
     this.events.push(event)
     this.result = (event.data as unknown) as BN
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -906,6 +925,9 @@ export class ExpectLeaderSetFixture implements Fixture {
       `Role account ids does not match, leader account: ${worker.role_account_id}, application account ${application.role_account_id}`
     )
     this.result = leadWorkerId
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -931,6 +953,9 @@ export class ExpectBeganApplicationReviewFixture implements Fixture {
     const event: Event = await this.apiWrapper.expectEvent('BeganApplicationReview')
     this.events.push(event)
     this.result = (event.data as unknown) as BN
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -959,6 +984,9 @@ export class ExpectLeaderRoleTerminatedFixture implements Fixture {
     this.events.push(event)
     const leadWorkerId: BN | undefined = await this.apiWrapper.getLeadWorkerId(this.module)
     assert(leadWorkerId === undefined, `Unexpected lead worker id: ${leadWorkerId}, expected none`)
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -995,6 +1023,9 @@ export class ExpectLeaderRewardAmountUpdatedFixture implements Fixture {
       receivedReward.eq(this.expectedReward),
       `Unexpected reward amount for worker with id ${leadWorkerId}: ${receivedReward}, expected ${this.expectedReward}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -1029,6 +1060,9 @@ export class ExpectLeaderStakeDecreasedFixture implements Fixture {
       receivedStake.eq(this.expectedStake),
       `Unexpected stake amount for worker with id ${leadWorkerId}: ${receivedStake}, expected ${this.expectedStake}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -1063,6 +1097,9 @@ export class ExpectLeaderSlashedFixture implements Fixture {
       receivedStake.eq(this.expectedStake),
       `Unexpected stake amount for worker with id after slash ${leadWorkerId}: ${receivedStake}, expected ${this.expectedStake}`
     )
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }
 
@@ -1095,5 +1132,8 @@ export class ExpectMintCapacityChangedFixture implements Fixture {
       `Unexpected mint capacity: ${receivedMintCapacity}, expected ${this.expectedMintCapacity}`
     )
     this.result = receivedMintCapacity
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    }
   }
 }

+ 7 - 7
tests/network-tests/src/iznik/tests/membershipCreationTest.ts → tests/network-tests/src/iznik/tests/membership/membershipCreationTest.ts

@@ -1,13 +1,13 @@
 import { KeyringPair } from '@polkadot/keyring/types'
 import { Keyring, WsProvider } from '@polkadot/api'
-import { initConfig } from '../utils/config'
-import { setTestTimeout } from '../utils/setTestTimeout'
+import { initConfig } from '../../utils/config'
+import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { closeApi } from './impl/closeApi'
-import { BuyMembershipHappyCaseFixture, BuyMembershipWithInsufficienFundsFixture } from './impl/membershipModule'
-import { Utils } from '../utils/utils'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { closeApi } from '../../utils/closeApi'
+import { BuyMembershipHappyCaseFixture, BuyMembershipWithInsufficienFundsFixture } from '../fixtures/membershipModule'
+import { Utils } from '../../utils/utils'
 
 tap.mocha.describe('Membership creation scenario', async () => {
   initConfig()
@@ -22,7 +22,7 @@ tap.mocha.describe('Membership creation scenario', async () => {
 
   const N: number = +process.env.MEMBERSHIP_CREATION_N!
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let aKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
+  const aKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
   const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
 
   const durationInBlocks = 7

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts

@@ -5,11 +5,11 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
-import { ContentWorkingGroupMintCapacityProposalFixture } from './impl/proposalsModule'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
+import { ContentWorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { Utils } from '../../utils/utils'
 
 tap.mocha.describe('Validator count proposal scenario', async () => {

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/electionParametersProposalTest.ts

@@ -5,12 +5,12 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { Utils } from '../../utils/utils'
-import { ElectionParametersProposalFixture } from './impl/proposalsModule'
+import { ElectionParametersProposalFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Election parameters proposal scenario', async () => {
   initConfig()

+ 7 - 7
tests/network-tests/src/iznik/tests/proposals/manageLeaderRole.ts

@@ -5,10 +5,10 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import {
   BeginWorkingGroupLeaderApplicationReviewFixture,
   CreateWorkingGroupLeaderOpeningFixture,
@@ -18,7 +18,7 @@ import {
   SlashLeaderProposalFixture,
   TerminateLeaderRoleProposalFixture,
   VoteForProposalFixture,
-} from './impl/proposalsModule'
+} from '../fixtures/proposalsModule'
 import {
   ApplyForOpeningFixture,
   ExpectBeganApplicationReviewFixture,
@@ -28,7 +28,7 @@ import {
   ExpectLeaderSlashedFixture,
   ExpectLeaderStakeDecreasedFixture,
   ExpectLeadOpeningAddedFixture,
-} from '../workingGroup/impl/workingGroupModule'
+} from '../fixtures/workingGroupModule'
 import { Utils } from '../../utils/utils'
 
 tap.mocha.describe('Set lead proposal scenario', async () => {
@@ -109,7 +109,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
   tap.test('Propose create leader opening', async () => createWorkingGroupLeaderOpeningFixture.runner(false))
 
   let voteForCreateOpeningProposalFixture: VoteForProposalFixture
-  let expectLeadOpeningAddedFixture: ExpectLeadOpeningAddedFixture = new ExpectLeadOpeningAddedFixture(apiWrapper)
+  const expectLeadOpeningAddedFixture: ExpectLeadOpeningAddedFixture = new ExpectLeadOpeningAddedFixture(apiWrapper)
   tap.test('Approve add opening proposal', async () => {
     voteForCreateOpeningProposalFixture = new VoteForProposalFixture(
       apiWrapper,
@@ -148,7 +148,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
   })
 
   let voteForBeginReviewProposal: VoteForProposalFixture
-  let expectBeganApplicationReviewFixture: ExpectBeganApplicationReviewFixture = new ExpectBeganApplicationReviewFixture(
+  const expectBeganApplicationReviewFixture: ExpectBeganApplicationReviewFixture = new ExpectBeganApplicationReviewFixture(
     apiWrapper
   )
   tap.test('Approve begin application review', async () => {

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/setLeadProposalTest.ts

@@ -5,12 +5,12 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
-import { SetLeadProposalFixture } from './impl/proposalsModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { SetLeadProposalFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Set lead proposal scenario', async () => {
   initConfig()

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/spendingProposalTest.ts

@@ -5,12 +5,12 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
-import { SpendingProposalFixture } from './impl/proposalsModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { SpendingProposalFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Spending proposal scenario', async () => {
   initConfig()

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/textProposalTest.ts

@@ -5,12 +5,12 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
-import { TextProposalFixture } from './impl/proposalsModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { TextProposalFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Text proposal scenario', async () => {
   initConfig()

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/updateRuntimeTest.ts → tests/network-tests/src/iznik/tests/proposals/updateRuntimet.ts

@@ -5,12 +5,12 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
-import { UpdateRuntimeFixture } from './impl/proposalsModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { UpdateRuntimeFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Update runtime scenario', async () => {
   initConfig()

+ 4 - 4
tests/network-tests/src/iznik/tests/proposals/validatorCountProposalTest.ts

@@ -5,12 +5,12 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
-import { ValidatorCountProposalFixture } from './impl/proposalsModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { ValidatorCountProposalFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Validator count proposal scenario', async () => {
   initConfig()

+ 5 - 5
tests/network-tests/src/iznik/tests/proposals/workingGroupMintCapacityProposalTest.ts

@@ -5,13 +5,13 @@ import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import tap from 'tap'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
-import { ElectCouncilFixture } from '../impl/councilElectionModule'
-import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from './impl/proposalsModule'
-import { ExpectMintCapacityChangedFixture } from '../workingGroup/impl/workingGroupModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
+import { ExpectMintCapacityChangedFixture } from '../fixtures/workingGroupModule'
 
 tap.mocha.describe('Set storage working group mint capacity scenario', async () => {
   initConfig()

+ 3 - 3
tests/network-tests/src/iznik/tests/workingGroup/atLeastValueBugTest.ts

@@ -1,6 +1,6 @@
 import { initConfig } from '../../utils/config'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { WsProvider, Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
@@ -12,10 +12,10 @@ import {
   BeginLeaderApplicationReviewFixture,
   FillLeaderOpeningFixture,
   LeaveRoleFixture,
-} from './impl/workingGroupModule'
+} from '../fixtures/workingGroupModule'
 import BN from 'bn.js'
 import tap from 'tap'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {

+ 5 - 5
tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsLeadTest.ts

@@ -1,6 +1,6 @@
 import { initConfig } from '../../utils/config'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { WsProvider, Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
@@ -18,11 +18,11 @@ import {
   DecreaseStakeFixture,
   SlashFixture,
   TerminateRoleFixture,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap = require('tap')
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
+} from '../fixtures/workingGroupModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
+import BN from 'bn.js'
+import tap from 'tap'
 
 tap.mocha.describe('Manage worker as worker scenario', async () => {
   initConfig()

+ 5 - 5
tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsWorkerTest.ts

@@ -1,6 +1,6 @@
 import { initConfig } from '../../utils/config'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { WsProvider, Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
@@ -16,11 +16,11 @@ import {
   IncreaseStakeFixture,
   LeaveRoleFixture,
   UpdateRewardAccountFixture,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap = require('tap')
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
+} from '../fixtures/workingGroupModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
+import BN from 'bn.js'
+import tap from 'tap'
 
 tap.mocha.describe('Manage worker as worker scenario', async () => {
   initConfig()

+ 3 - 3
tests/network-tests/src/iznik/tests/workingGroup/workerApplicationHappyCaseTest.ts

@@ -1,13 +1,13 @@
 import { initConfig } from '../../utils/config'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { WsProvider, Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import BN from 'bn.js'
 import tap from 'tap'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
 import {
   AddLeaderOpeningFixture,
@@ -19,7 +19,7 @@ import {
   FillOpeningFixture,
   LeaveRoleFixture,
   WithdrawApplicationFixture,
-} from './impl/workingGroupModule'
+} from '../fixtures/workingGroupModule'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()

+ 3 - 3
tests/network-tests/src/iznik/tests/workingGroup/workerApplicationRejectionCaseTest.ts

@@ -1,13 +1,13 @@
 import { initConfig } from '../../utils/config'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { WsProvider, Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { setTestTimeout } from '../../utils/setTestTimeout'
 import BN from 'bn.js'
 import tap from 'tap'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
 import {
   AcceptApplicationsFixture,
@@ -18,7 +18,7 @@ import {
   FillLeaderOpeningFixture,
   LeaveRoleFixture,
   TerminateApplicationsFixture,
-} from './impl/workingGroupModule'
+} from '../fixtures/workingGroupModule'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()

+ 67 - 15
tests/network-tests/src/iznik/tests/workingGroup/workerPayoutTest.ts

@@ -1,6 +1,6 @@
 import { initConfig } from '../../utils/config'
 import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
+import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { WsProvider, Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
@@ -12,14 +12,17 @@ import {
   AwaitPayoutFixture,
   BeginApplicationReviewFixture,
   BeginLeaderApplicationReviewFixture,
+  ExpectMintCapacityChangedFixture,
   FillLeaderOpeningFixture,
   FillOpeningFixture,
   LeaveRoleFixture,
-} from './impl/workingGroupModule'
+} from '../fixtures/workingGroupModule'
 import BN from 'bn.js'
 import tap from 'tap'
-import { BuyMembershipHappyCaseFixture } from '../impl/membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
+import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
+import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()
@@ -33,12 +36,18 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
   const N: number = +process.env.WORKING_GROUP_N!
-  const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
   const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const K: number = +process.env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
   const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
+  const leaderFirstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
+  const leaderRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
   const firstRewardInterval: BN = new BN(process.env.SHORT_FIRST_REWARD_INTERVAL!)
   const rewardInterval: BN = new BN(process.env.SHORT_REWARD_INTERVAL!)
   const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
@@ -49,13 +58,32 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
 
   setTestTimeout(apiWrapper, durationInBlocks)
 
-  const happyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
+  const firstMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
     apiWrapper,
     sudo,
-    nKeyPairs,
+    m1KeyPairs,
     paidTerms
   )
-  tap.test('Creating a set of members', async () => happyCaseFixture.runner(false))
+  tap.test('Creating first set of members', async () => firstMemberSetFixture.runner(false))
+
+  const secondMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
+    apiWrapper,
+    sudo,
+    m2KeyPairs,
+    paidTerms
+  )
+  tap.test('Creating second set of members', async () => secondMemberSetFixture.runner(false))
+
+  const electCouncilFixture: ElectCouncilFixture = new ElectCouncilFixture(
+    apiWrapper,
+    m1KeyPairs,
+    m2KeyPairs,
+    K,
+    sudo,
+    greaterStake,
+    lesserStake
+  )
+  tap.test('Elect council', async () => electCouncilFixture.runner(false))
 
   const leaderHappyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
     apiWrapper,
@@ -67,14 +95,13 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
 
   const addLeaderOpeningFixture: AddLeaderOpeningFixture = new AddLeaderOpeningFixture(
     apiWrapper,
-    nKeyPairs,
+    m1KeyPairs,
     sudo,
     applicationStake,
     roleStake,
     openingActivationDelay,
     WorkingGroups.StorageWorkingGroup
   )
-  // let leadOpenignId: BN
   tap.test('Add lead opening', async () => await addLeaderOpeningFixture.runner(false))
 
   let applyForLeaderOpeningFixture: ApplyForOpeningFixture
@@ -109,17 +136,42 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       leadKeyPair,
       sudo,
       addLeaderOpeningFixture.getResult()!,
-      firstRewardInterval,
-      rewardInterval,
+      leaderFirstRewardInterval,
+      leaderRewardInterval,
       payoutAmount,
       WorkingGroups.StorageWorkingGroup
     )
     await fillLeaderOpeningFixture.runner(false)
   })
 
+  const workingGroupMintCapacityProposalFixture: WorkingGroupMintCapacityProposalFixture = new WorkingGroupMintCapacityProposalFixture(
+    apiWrapper,
+    m1KeyPairs,
+    sudo,
+    mintCapacity,
+    WorkingGroups.StorageWorkingGroup
+  )
+  tap.test('Propose mint capacity', async () => workingGroupMintCapacityProposalFixture.runner(false))
+
+  let voteForProposalFixture: VoteForProposalFixture
+  const expectMintCapacityChanged: ExpectMintCapacityChangedFixture = new ExpectMintCapacityChangedFixture(
+    apiWrapper,
+    mintCapacity
+  )
+  tap.test('Approve mint capacity', async () => {
+    voteForProposalFixture = new VoteForProposalFixture(
+      apiWrapper,
+      m2KeyPairs,
+      sudo,
+      workingGroupMintCapacityProposalFixture.getResult()!
+    )
+    voteForProposalFixture.runner(false)
+    await expectMintCapacityChanged.runner(false)
+  })
+
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
     apiWrapper,
-    nKeyPairs,
+    m1KeyPairs,
     leadKeyPair[0],
     sudo,
     applicationStake,
@@ -134,7 +186,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   tap.test('First apply for worker opening', async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
-      nKeyPairs,
+      m1KeyPairs,
       sudo,
       applicationStake,
       roleStake,
@@ -160,7 +212,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   tap.test('Fill worker opening', async () => {
     fillOpeningFixture = new FillOpeningFixture(
       apiWrapper,
-      nKeyPairs,
+      m1KeyPairs,
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getResult()!,
@@ -174,7 +226,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
 
   const awaitPayoutFixture: AwaitPayoutFixture = new AwaitPayoutFixture(
     apiWrapper,
-    nKeyPairs,
+    m1KeyPairs,
     WorkingGroups.StorageWorkingGroup
   )
   tap.test('Await worker payout', async () => awaitPayoutFixture.runner(false))

+ 1 - 1
tests/network-tests/src/iznik/tests/impl/closeApi.ts → tests/network-tests/src/iznik/utils/closeApi.ts

@@ -1,4 +1,4 @@
-import { ApiWrapper } from '../../utils/apiWrapper'
+import { ApiWrapper } from './apiWrapper'
 import tap from 'tap'
 
 export function closeApi(apiWrapper: ApiWrapper) {