Browse Source

network tests refactor code, gutted out node-tap

Mokhtar Naamani 4 years ago
parent
commit
c7d8d73bcd
42 changed files with 914 additions and 1892 deletions
  1. 2 3
      tests/network-tests/package.json
  2. 1 1
      tests/network-tests/run-tests.sh
  3. 4 5
      tests/network-tests/src/fixtures/councilElectionHappyCase.ts
  4. 2 2
      tests/network-tests/src/fixtures/councilElectionModule.ts
  5. 0 0
      tests/network-tests/src/fixtures/interfaces/fixture.ts
  6. 16 11
      tests/network-tests/src/fixtures/leaderHiringHappyCase.ts
  7. 1 1
      tests/network-tests/src/fixtures/membershipModule.ts
  8. 2 136
      tests/network-tests/src/fixtures/proposalsModule.ts
  9. 2 2
      tests/network-tests/src/fixtures/workingGroupModule.ts
  10. 46 0
      tests/network-tests/src/flows/councilSetup.ts
  11. 15 25
      tests/network-tests/src/flows/leaderSetup.ts
  12. 47 0
      tests/network-tests/src/flows/membership/creatingMemberships.ts
  13. 57 0
      tests/network-tests/src/flows/proposals/electionParametersProposal.ts
  14. 94 101
      tests/network-tests/src/flows/proposals/manageLeaderRole.ts
  15. 57 0
      tests/network-tests/src/flows/proposals/spendingProposal.ts
  16. 47 0
      tests/network-tests/src/flows/proposals/textProposal.ts
  17. 63 0
      tests/network-tests/src/flows/proposals/updateRuntime.ts
  18. 54 0
      tests/network-tests/src/flows/proposals/validatorCountProposal.ts
  19. 71 0
      tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts
  20. 23 38
      tests/network-tests/src/flows/workingGroup/atLeastValueBug.ts
  21. 51 49
      tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts
  22. 36 40
      tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts
  23. 35 40
      tests/network-tests/src/flows/workingGroup/workerApplicationHappyCase.ts
  24. 39 40
      tests/network-tests/src/flows/workingGroup/workerApplicationRejectionCase.ts
  25. 48 51
      tests/network-tests/src/flows/workingGroup/workerPayout.ts
  26. 85 0
      tests/network-tests/src/scenarios/full.ts
  27. 0 0
      tests/network-tests/src/tap-parallel-not-ok
  28. 0 64
      tests/network-tests/src/tests/council/electingCouncilTest.ts
  29. 0 57
      tests/network-tests/src/tests/councilSetup.ts
  30. 0 56
      tests/network-tests/src/tests/membership/membershipCreationTest.ts
  31. 0 70
      tests/network-tests/src/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts
  32. 0 65
      tests/network-tests/src/tests/proposals/electionParametersProposalTest.ts
  33. 0 65
      tests/network-tests/src/tests/proposals/setLeadProposalTest.ts
  34. 0 68
      tests/network-tests/src/tests/proposals/spendingProposalTest.ts
  35. 0 59
      tests/network-tests/src/tests/proposals/textProposalTest.ts
  36. 0 75
      tests/network-tests/src/tests/proposals/updateRuntime.ts
  37. 0 66
      tests/network-tests/src/tests/proposals/validatorCountProposalTest.ts
  38. 0 87
      tests/network-tests/src/tests/proposals/workingGroupMintCapacityProposalTest.ts
  39. 0 12
      tests/network-tests/src/utils/apiWrapper.ts
  40. 0 8
      tests/network-tests/src/utils/closeApi.ts
  41. 1 2
      tests/network-tests/src/utils/setTestTimeout.ts
  42. 15 593
      yarn.lock

+ 2 - 3
tests/network-tests/package.json

@@ -4,7 +4,8 @@
   "license": "GPL-3.0-only",
   "scripts": {
     "build": "tsc --noEmit",
-    "test": "yarn db-path-setup && tap --files src/tests/unknown.unknown src/tests/councilSetup.ts src/tests/proposals/*Test.ts src/tests/leaderSetup.ts src/tests/workingGroup/*Test.ts -T",
+    "run-tests": "./run-tests.sh",
+    "scenario-full": "yarn db-path-setup && ts-node src/scenarios/full.ts",
     "lint": "eslint . --quiet --ext .ts",
     "checks": "tsc --noEmit --pretty && prettier ./ --check && yarn lint",
     "format": "prettier ./ --write ",
@@ -25,11 +26,9 @@
   "devDependencies": {
     "@polkadot/ts": "^0.3.14",
     "@types/chai": "^4.2.11",
-    "@types/tap": "^14.10.0",
     "@types/uuid": "^7.0.2",
     "chai": "^4.2.0",
     "prettier": "2.0.2",
-    "tap": "^14.10.7",
     "ts-node": "^8.8.1",
     "typescript": "^3.8.3"
   }

+ 1 - 1
tests/network-tests/run-tests.sh

@@ -57,4 +57,4 @@ function cleanup() {
 trap cleanup EXIT
 
 # Execute the tests
-yarn workspace network-tests test
+time DEBUG=* yarn workspace network-tests scenario-full

+ 4 - 5
tests/network-tests/src/tests/fixtures/councilElectionHappyCase.ts → tests/network-tests/src/fixtures/councilElectionHappyCase.ts

@@ -1,8 +1,7 @@
 import { Fixture } from './interfaces/fixture'
 import { BuyMembershipHappyCaseFixture } from './membershipModule'
-import tap from 'tap'
 import { ElectCouncilFixture } from './councilElectionModule'
-import { ApiWrapper } from '../../utils/apiWrapper'
+import { ApiWrapper } from '../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
@@ -44,7 +43,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
       this.membersKeyPairs,
       this.paidTerms
     )
-    tap.test('Creating first set of members', async () => firstMemberSetFixture.runner(false))
+    await firstMemberSetFixture.runner(false)
 
     const secondMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
       this.apiWrapper,
@@ -52,7 +51,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
       this.councilKeyPairs,
       this.paidTerms
     )
-    tap.test('Creating second set of members', async () => secondMemberSetFixture.runner(false))
+    await secondMemberSetFixture.runner(false)
 
     const electCouncilFixture: ElectCouncilFixture = new ElectCouncilFixture(
       this.apiWrapper,
@@ -63,6 +62,6 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
       this.greaterStake,
       this.lesserStake
     )
-    tap.test('Elect council', async () => electCouncilFixture.runner(false))
+    await electCouncilFixture.runner(false)
   }
 }

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

@@ -1,10 +1,10 @@
-import { ApiWrapper } from '../../utils/apiWrapper'
+import { ApiWrapper } from '../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'
 import { Seat } from '@joystream/types/council'
 import { v4 as uuid } from 'uuid'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../utils/utils'
 import { Fixture } from './interfaces/fixture'
 
 export class ElectCouncilFixture implements Fixture {

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


+ 16 - 11
tests/network-tests/src/tests/fixtures/leaderHiringHappyCase.ts → tests/network-tests/src/fixtures/leaderHiringHappyCase.ts

@@ -1,5 +1,4 @@
 import { Fixture } from './interfaces/fixture'
-import tap from 'tap'
 import {
   AddLeaderOpeningFixture,
   ApplyForOpeningFixture,
@@ -7,7 +6,7 @@ import {
   FillLeaderOpeningFixture,
 } from './workingGroupModule'
 import { BuyMembershipHappyCaseFixture } from './membershipModule'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { ApiWrapper, WorkingGroups } from '../utils/apiWrapper'
 import { OpeningId } from '@joystream/types/hiring'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { PaidTermId } from '@joystream/types/members'
@@ -62,7 +61,8 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
       this.nKeyPairs,
       this.paidTerms
     )
-    tap.test('Creating a set of members', async () => happyCaseFixture.runner(false))
+    // Creating a set of members
+    await happyCaseFixture.runner(false)
 
     const leaderHappyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
       this.apiWrapper,
@@ -70,7 +70,8 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
       this.leadKeyPair,
       this.paidTerms
     )
-    tap.test('Buying membership for leader account', async () => leaderHappyCaseFixture.runner(false))
+    // Buying membership for leader account
+    await leaderHappyCaseFixture.runner(false)
 
     const addLeaderOpeningFixture: AddLeaderOpeningFixture = new AddLeaderOpeningFixture(
       this.apiWrapper,
@@ -81,10 +82,12 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
       this.openingActivationDelay,
       this.workingGroup
     )
-    tap.test('Add lead opening', async () => await addLeaderOpeningFixture.runner(false))
+    // Add lead opening
+    await addLeaderOpeningFixture.runner(false)
 
     let applyForLeaderOpeningFixture: ApplyForOpeningFixture
-    tap.test('Apply for lead opening', async () => {
+    // Apply for lead opening
+    await (async () => {
       applyForLeaderOpeningFixture = new ApplyForOpeningFixture(
         this.apiWrapper,
         this.leadKeyPair,
@@ -95,10 +98,11 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
         this.workingGroup
       )
       await applyForLeaderOpeningFixture.runner(false)
-    })
+    })()
 
     let beginLeaderApplicationReviewFixture: BeginLeaderApplicationReviewFixture
-    tap.test('Begin lead application review', async () => {
+    // Begin lead application review
+    await (async () => {
       beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
         this.apiWrapper,
         this.sudo,
@@ -106,10 +110,11 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
         this.workingGroup
       )
       await beginLeaderApplicationReviewFixture.runner(false)
-    })
+    })()
 
     let fillLeaderOpeningFixture: FillLeaderOpeningFixture
-    tap.test('Fill lead opening', async () => {
+    // Fill lead opening
+    await (async () => {
       fillLeaderOpeningFixture = new FillLeaderOpeningFixture(
         this.apiWrapper,
         this.leadKeyPair,
@@ -121,6 +126,6 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
         this.workingGroup
       )
       await fillLeaderOpeningFixture.runner(false)
-    })
+    })()
   }
 }

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

@@ -1,4 +1,4 @@
-import { ApiWrapper } from '../../utils/apiWrapper'
+import { ApiWrapper } from '../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'

+ 2 - 136
tests/network-tests/src/tests/fixtures/proposalsModule.ts → tests/network-tests/src/fixtures/proposalsModule.ts

@@ -1,5 +1,5 @@
 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 { ProposalId } from '@joystream/types/proposals'
@@ -7,7 +7,7 @@ import { Fixture } from './interfaces/fixture'
 import { assert } from 'chai'
 import { ApplicationId, OpeningId } from '@joystream/types/hiring'
 import { WorkerId } from '@joystream/types/working-group'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../utils/utils'
 
 export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
   private apiWrapper: ApiWrapper
@@ -669,71 +669,6 @@ export class ElectionParametersProposalFixture implements Fixture {
   }
 }
 
-export class SetLeadProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
-  private membersKeyPairs: KeyringPair[]
-  private councilKeyPairs: KeyringPair[]
-  private treasury: KeyringPair
-
-  constructor(
-    apiWrapper: ApiWrapper,
-    membersKeyPairs: KeyringPair[],
-    councilKeyPairs: KeyringPair[],
-    treasury: KeyringPair
-  ) {
-    this.apiWrapper = apiWrapper
-    this.membersKeyPairs = membersKeyPairs
-    this.councilKeyPairs = councilKeyPairs
-    this.treasury = treasury
-  }
-
-  public async runner(expectFailure: boolean): Promise<void> {
-    // Setup
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing validator count proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()
-    await this.apiWrapper.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeLeadFee(
-      description,
-      description,
-      proposalStake,
-      this.treasury.address
-    )
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
-
-    // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeLead(
-      this.membersKeyPairs[0],
-      proposalTitle,
-      description,
-      proposalStake,
-      this.membersKeyPairs[1]
-    )
-    const proposalNumber: ProposalId = await proposalPromise
-
-    // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
-    await proposalExecutionPromise
-    const newLead: string = await this.apiWrapper.getCurrentLeadAddress()
-    assert(
-      newLead === this.membersKeyPairs[1].address,
-      `New lead has unexpected value ${newLead}, expected ${this.membersKeyPairs[1].address}`
-    )
-    if (expectFailure) {
-      throw new Error('Successful fixture run while expecting failure')
-    }
-  }
-}
-
 export class SpendingProposalFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private membersKeyPairs: KeyringPair[]
@@ -930,75 +865,6 @@ export class ValidatorCountProposalFixture implements Fixture {
   }
 }
 
-export class ContentWorkingGroupMintCapacityProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
-  private membersKeyPairs: KeyringPair[]
-  private councilKeyPairs: KeyringPair[]
-  private treasury: KeyringPair
-  private mintingCapacityIncrement: BN
-
-  constructor(
-    apiWrapper: ApiWrapper,
-    membersKeyPairs: KeyringPair[],
-    councilKeyPairs: KeyringPair[],
-    treasury: KeyringPair,
-    mintingCapacityIncrement: BN
-  ) {
-    this.apiWrapper = apiWrapper
-    this.membersKeyPairs = membersKeyPairs
-    this.councilKeyPairs = councilKeyPairs
-    this.treasury = treasury
-    this.mintingCapacityIncrement = mintingCapacityIncrement
-  }
-
-  public async runner(expectFailure: boolean): Promise<void> {
-    // Setup
-    const description = 'Mint capacity proposal which is used for API network testing'
-    const runtimeVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()
-    const initialMintingCapacity: BN = await this.apiWrapper.getContentWorkingGroupMintCapacity()
-
-    // Topping the balances
-    const proposalStake: BN = new BN(50000)
-    const runtimeProposalFee: BN = this.apiWrapper.estimateProposeContentWorkingGroupMintCapacityFee(
-      description,
-      description,
-      proposalStake,
-      initialMintingCapacity.add(this.mintingCapacityIncrement)
-    )
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      runtimeProposalFee.add(proposalStake)
-    )
-    await this.apiWrapper.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
-
-    // Proposal creation
-    const proposedMintingCapacity: BN = initialMintingCapacity.add(this.mintingCapacityIncrement)
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeContentWorkingGroupMintCapacity(
-      this.membersKeyPairs[0],
-      'testing mint capacity' + uuid().substring(0, 8),
-      'mint capacity to test proposal functionality' + uuid().substring(0, 8),
-      proposalStake,
-      proposedMintingCapacity
-    )
-    const proposalNumber: ProposalId = await proposalPromise
-
-    // Approving mint capacity proposal
-    const mintCapacityPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
-    await mintCapacityPromise
-    const newMintingCapacity: BN = await this.apiWrapper.getContentWorkingGroupMintCapacity()
-    assert(
-      proposedMintingCapacity.eq(newMintingCapacity),
-      `Content working group has unexpected minting capacity ${newMintingCapacity}, expected ${proposedMintingCapacity}`
-    )
-    if (expectFailure) {
-      throw new Error('Successful fixture run while expecting failure')
-    }
-  }
-}
-
 export class UpdateRuntimeFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private membersKeyPairs: KeyringPair[]

+ 2 - 2
tests/network-tests/src/tests/fixtures/workingGroupModule.ts → tests/network-tests/src/fixtures/workingGroupModule.ts

@@ -1,13 +1,13 @@
 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 { Event } from '@polkadot/types/interfaces'
 import { Keyring } from '@polkadot/api'
 import { v4 as uuid } from 'uuid'
 import { RewardRelationship } from '@joystream/types/recurring-rewards'
 import { Application, ApplicationIdToWorkerIdMap, Worker, WorkerId } from '@joystream/types/working-group'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../utils/utils'
 import { ApplicationId, Opening as HiringOpening, OpeningId } from '@joystream/types/hiring'
 import { Fixture } from './interfaces/fixture'
 

+ 46 - 0
tests/network-tests/src/flows/councilSetup.ts

@@ -0,0 +1,46 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { PaidTermId } from '@joystream/types/members'
+import { DbService } from '../services/dbService'
+
+import { ApiWrapper } from '../utils/apiWrapper'
+import { Utils } from '../utils/utils'
+import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
+
+// Electing council scenario
+export default async function councilSetup(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  if (db.hasCouncil()) {
+    return
+  }
+
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+
+  // const durationInBlocks = 25
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+    apiWrapper,
+    sudo,
+    m1KeyPairs,
+    m2KeyPairs,
+    paidTerms,
+    K,
+    greaterStake,
+    lesserStake
+  )
+  await councilElectionHappyCaseFixture.runner(false)
+
+  db.setMembers(m1KeyPairs)
+  db.setCouncil(m2KeyPairs)
+}

+ 15 - 25
tests/network-tests/src/tests/leaderSetup.ts → tests/network-tests/src/flows/leaderSetup.ts

@@ -1,43 +1,35 @@
-import { initConfig } from '../utils/config'
-import { closeApi } from '../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
+import { 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 { Utils } from '../utils/utils'
 import { PaidTermId } from '@joystream/types/members'
 import { DbService } from '../services/dbService'
-import { LeaderHiringHappyCaseFixture } from './fixtures/leaderHiringHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 
-tap.mocha.describe('Worker application happy case scenario', async () => {
-  initConfig()
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Worker application happy case scenario
+export default async function leaderSetup(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     return
   }
 
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const durationInBlocks = 48
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
   const openingActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 48
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
     apiWrapper,
@@ -57,6 +49,4 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
 
   db.setMembers(nKeyPairs)
   db.setLeader(leadKeyPair[0], apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})
+}

+ 47 - 0
tests/network-tests/src/flows/membership/creatingMemberships.ts

@@ -0,0 +1,47 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import {
+  BuyMembershipHappyCaseFixture,
+  BuyMembershipWithInsufficienFundsFixture,
+} from '../../fixtures/membershipModule'
+import { Utils } from '../../utils/utils'
+import { PaidTermId } from '@joystream/types/members'
+import BN from 'bn.js'
+
+// Membership creation scenario
+export default async function memberShipCreation(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  const aKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+
+  // const durationInBlocks = 7
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  const happyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
+    apiWrapper,
+    sudo,
+    nKeyPairs,
+    paidTerms
+  )
+  // Buy membeship is accepted with sufficient funds
+  await happyCaseFixture.runner(false)
+
+  const insufficientFundsFixture: BuyMembershipWithInsufficienFundsFixture = new BuyMembershipWithInsufficienFundsFixture(
+    apiWrapper,
+    sudo,
+    aKeyPair[0],
+    paidTerms
+  )
+  // Account A can not buy the membership with insufficient funds
+  await insufficientFundsFixture.runner(false)
+
+  const buyMembershipAfterAccountTopUp = new BuyMembershipHappyCaseFixture(apiWrapper, sudo, aKeyPair, paidTerms)
+  // Account A was able to buy the membership with sufficient funds
+  await buyMembershipAfterAccountTopUp.runner(false)
+}

+ 57 - 0
tests/network-tests/src/flows/proposals/electionParametersProposal.ts

@@ -0,0 +1,57 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { Utils } from '../../utils/utils'
+import { ElectionParametersProposalFixture } from '../../fixtures/proposalsModule'
+import { PaidTermId } from '@joystream/types/members'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { DbService } from '../../services/dbService'
+
+// Election parameters proposal scenario
+export default async function electionParametersProposal(
+  apiWrapper: ApiWrapper,
+  env: NodeJS.ProcessEnv,
+  db: DbService
+) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+
+  // const durationInBlocks = 29
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  if (db.hasCouncil()) {
+    m1KeyPairs = db.getMembers()
+    m2KeyPairs = db.getCouncil()
+  } else {
+    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+      apiWrapper,
+      sudo,
+      m1KeyPairs,
+      m2KeyPairs,
+      paidTerms,
+      K,
+      greaterStake,
+      lesserStake
+    )
+    await councilElectionHappyCaseFixture.runner(false)
+  }
+
+  const electionParametersProposalFixture: ElectionParametersProposalFixture = new ElectionParametersProposalFixture(
+    apiWrapper,
+    m1KeyPairs,
+    m2KeyPairs,
+    sudo
+  )
+  await electionParametersProposalFixture.runner(false)
+}

+ 94 - 101
tests/network-tests/src/tests/proposals/manageLeaderRoleTest.ts → tests/network-tests/src/flows/proposals/manageLeaderRole.ts

@@ -1,12 +1,9 @@
 import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
+import { Keyring } from '@polkadot/api'
 import BN from 'bn.js'
 import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import {
   BeginWorkingGroupLeaderApplicationReviewFixture,
   CreateWorkingGroupLeaderOpeningFixture,
@@ -16,7 +13,7 @@ import {
   SlashLeaderProposalFixture,
   TerminateLeaderRoleProposalFixture,
   VoteForProposalFixture,
-} from '../fixtures/proposalsModule'
+} from '../../fixtures/proposalsModule'
 import {
   ApplyForOpeningFixture,
   ExpectBeganApplicationReviewFixture,
@@ -26,43 +23,36 @@ import {
   ExpectLeaderSlashedFixture,
   ExpectLeaderStakeDecreasedFixture,
   ExpectLeadOpeningAddedFixture,
-} from '../fixtures/workingGroupModule'
+} from '../../fixtures/workingGroupModule'
 import { Utils } from '../../utils/utils'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { ProposalId } from '@joystream/types/proposals'
 import { DbService } from '../../services/dbService'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
 
-tap.mocha.describe('Set lead proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
+  const N: number = +env.MEMBERSHIP_CREATION_N!
   let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const alteredPayoutAmount: BN = new BN(process.env.ALTERED_PAYOUT_AMOUNT!)
-  const stakeDecrement: BN = new BN(process.env.STAKE_DECREMENT!)
-  const slashAmount: BN = new BN(process.env.SLASH_AMOUNT!)
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const alteredPayoutAmount: BN = new BN(env.ALTERED_PAYOUT_AMOUNT!)
+  const stakeDecrement: BN = new BN(env.STAKE_DECREMENT!)
+  const slashAmount: BN = new BN(env.SLASH_AMOUNT!)
   const durationInBlocks = 70
 
   setTestTimeout(apiWrapper, durationInBlocks)
@@ -90,7 +80,8 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     leadKeyPair,
     paidTerms
   )
-  tap.test('Buy membership for lead', async () => await leaderMembershipFixture.runner(false))
+  // Buy membership for lead
+  await leaderMembershipFixture.runner(false)
 
   const createWorkingGroupLeaderOpeningFixture: CreateWorkingGroupLeaderOpeningFixture = new CreateWorkingGroupLeaderOpeningFixture(
     apiWrapper,
@@ -100,11 +91,13 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     roleStake,
     'Storage'
   )
-  tap.test('Propose create leader opening', async () => await createWorkingGroupLeaderOpeningFixture.runner(false))
+  // Propose create leader opening
+  await createWorkingGroupLeaderOpeningFixture.runner(false)
 
   let voteForCreateOpeningProposalFixture: VoteForProposalFixture
   const expectLeadOpeningAddedFixture: ExpectLeadOpeningAddedFixture = new ExpectLeadOpeningAddedFixture(apiWrapper)
-  tap.test('Approve add opening proposal', async () => {
+  // Approve add opening proposal
+  await (async () => {
     voteForCreateOpeningProposalFixture = new VoteForProposalFixture(
       apiWrapper,
       m2KeyPairs,
@@ -113,10 +106,11 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     )
     voteForCreateOpeningProposalFixture.runner(false)
     await expectLeadOpeningAddedFixture.runner(false)
-  })
+  })()
 
   let applyForLeaderOpeningFixture: ApplyForOpeningFixture
-  tap.test('Apply for lead opening', async () => {
+  // Apply for lead opening
+  await (async () => {
     applyForLeaderOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       leadKeyPair,
@@ -127,25 +121,25 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
-  })
+  })()
 
-  let beginWorkingGroupLeaderApplicationReviewFixture: BeginWorkingGroupLeaderApplicationReviewFixture
-  tap.test('Propose begin leader application review', async () => {
-    beginWorkingGroupLeaderApplicationReviewFixture = new BeginWorkingGroupLeaderApplicationReviewFixture(
-      apiWrapper,
-      m1KeyPairs,
-      sudo,
-      expectLeadOpeningAddedFixture.getCreatedOpeningId() as OpeningId,
-      'Storage'
-    )
-    await beginWorkingGroupLeaderApplicationReviewFixture.runner(false)
-  })
+  const beginWorkingGroupLeaderApplicationReviewFixture: BeginWorkingGroupLeaderApplicationReviewFixture = new BeginWorkingGroupLeaderApplicationReviewFixture(
+    apiWrapper,
+    m1KeyPairs,
+    sudo,
+    expectLeadOpeningAddedFixture.getCreatedOpeningId() as OpeningId,
+    'Storage'
+  )
+
+  // Propose begin leader application review
+  await beginWorkingGroupLeaderApplicationReviewFixture.runner(false)
 
   let voteForBeginReviewProposal: VoteForProposalFixture
   const expectBeganApplicationReviewFixture: ExpectBeganApplicationReviewFixture = new ExpectBeganApplicationReviewFixture(
     apiWrapper
   )
-  tap.test('Approve begin application review', async () => {
+  // Approve begin application review
+  await (async () => {
     voteForBeginReviewProposal = new VoteForProposalFixture(
       apiWrapper,
       m2KeyPairs,
@@ -154,40 +148,36 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     )
     voteForBeginReviewProposal.runner(false)
     await expectBeganApplicationReviewFixture.runner(false)
-  })
+  })()
 
-  let fillLeaderOpeningProposalFixture: FillLeaderOpeningProposalFixture
-  tap.test('Propose fill leader opening', async () => {
-    fillLeaderOpeningProposalFixture = new FillLeaderOpeningProposalFixture(
-      apiWrapper,
-      m1KeyPairs,
-      leadKeyPair[0].address,
-      sudo,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      expectLeadOpeningAddedFixture.getCreatedOpeningId() as OpeningId,
-      WorkingGroups.StorageWorkingGroup
-    )
-    await fillLeaderOpeningProposalFixture.runner(false)
-  })
+  const fillLeaderOpeningProposalFixture: FillLeaderOpeningProposalFixture = new FillLeaderOpeningProposalFixture(
+    apiWrapper,
+    m1KeyPairs,
+    leadKeyPair[0].address,
+    sudo,
+    firstRewardInterval,
+    rewardInterval,
+    payoutAmount,
+    expectLeadOpeningAddedFixture.getCreatedOpeningId() as OpeningId,
+    WorkingGroups.StorageWorkingGroup
+  )
+  // Propose fill leader opening
+  await fillLeaderOpeningProposalFixture.runner(false)
 
-  let voteForFillLeaderProposalFixture: VoteForProposalFixture
+  const voteForFillLeaderProposalFixture: VoteForProposalFixture = new VoteForProposalFixture(
+    apiWrapper,
+    m2KeyPairs,
+    sudo,
+    fillLeaderOpeningProposalFixture.getCreatedProposalId() as ProposalId
+  )
   const expectLeaderSetFixture: ExpectLeaderSetFixture = new ExpectLeaderSetFixture(
     apiWrapper,
     leadKeyPair[0].address,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Approve fill leader opening', async () => {
-    voteForFillLeaderProposalFixture = new VoteForProposalFixture(
-      apiWrapper,
-      m2KeyPairs,
-      sudo,
-      fillLeaderOpeningProposalFixture.getCreatedProposalId() as ProposalId
-    )
-    voteForFillLeaderProposalFixture.runner(false)
-    await expectLeaderSetFixture.runner(false)
-  })
+  // Approve fill leader opening
+  voteForFillLeaderProposalFixture.runner(false)
+  await expectLeaderSetFixture.runner(false)
 
   const setLeaderRewardProposalFixture: SetLeaderRewardProposalFixture = new SetLeaderRewardProposalFixture(
     apiWrapper,
@@ -196,24 +186,23 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     alteredPayoutAmount,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Propose leader reward', async () => setLeaderRewardProposalFixture.runner(false))
+  // Propose leader reward
+  await setLeaderRewardProposalFixture.runner(false)
 
-  let voteForeLeaderRewardFixture: VoteForProposalFixture
+  const voteForeLeaderRewardFixture: VoteForProposalFixture = new VoteForProposalFixture(
+    apiWrapper,
+    m2KeyPairs,
+    sudo,
+    setLeaderRewardProposalFixture.getCreatedProposalId() as ProposalId
+  )
   const expectLeaderRewardAmountUpdatedFixture: ExpectLeaderRewardAmountUpdatedFixture = new ExpectLeaderRewardAmountUpdatedFixture(
     apiWrapper,
     alteredPayoutAmount,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Approve new leader reward', async () => {
-    voteForeLeaderRewardFixture = new VoteForProposalFixture(
-      apiWrapper,
-      m2KeyPairs,
-      sudo,
-      setLeaderRewardProposalFixture.getCreatedProposalId() as ProposalId
-    )
-    voteForeLeaderRewardFixture.runner(false)
-    await expectLeaderRewardAmountUpdatedFixture.runner(false)
-  })
+  // Approve new leader reward
+  voteForeLeaderRewardFixture.runner(false)
+  await expectLeaderRewardAmountUpdatedFixture.runner(false)
 
   const decreaseLeaderStakeProposalFixture: DecreaseLeaderStakeProposalFixture = new DecreaseLeaderStakeProposalFixture(
     apiWrapper,
@@ -222,13 +211,15 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     stakeDecrement,
     WorkingGroups.StorageWorkingGroup
   )
-  let newStake: BN
-  tap.test('Propose decrease stake', async () => decreaseLeaderStakeProposalFixture.runner(false))
+
+  // Propose decrease stake
+  await decreaseLeaderStakeProposalFixture.runner(false)
 
   let voteForDecreaseStakeProposal: VoteForProposalFixture
   let expectLeaderStakeDecreasedFixture: ExpectLeaderStakeDecreasedFixture
-  tap.test('Approve decreased leader stake', async () => {
-    newStake = applicationStake.sub(stakeDecrement)
+  let newStake: BN = applicationStake.sub(stakeDecrement)
+  // Approve decreased leader stake
+  await (async () => {
     voteForDecreaseStakeProposal = new VoteForProposalFixture(
       apiWrapper,
       m2KeyPairs,
@@ -242,7 +233,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await expectLeaderStakeDecreasedFixture.runner(false)
-  })
+  })()
 
   const slashLeaderProposalFixture: SlashLeaderProposalFixture = new SlashLeaderProposalFixture(
     apiWrapper,
@@ -251,11 +242,13 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     slashAmount,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Propose leader slash', async () => await slashLeaderProposalFixture.runner(false))
+  // Propose leader slash
+  await slashLeaderProposalFixture.runner(false)
 
   let voteForSlashProposalFixture: VoteForProposalFixture
   let expectLeaderSlashedFixture: ExpectLeaderSlashedFixture
-  tap.test('Approve leader slash', async () => {
+  // Approve leader slash
+  await (async () => {
     newStake = newStake.sub(slashAmount)
     voteForSlashProposalFixture = new VoteForProposalFixture(
       apiWrapper,
@@ -266,7 +259,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     voteForSlashProposalFixture.runner(false)
     expectLeaderSlashedFixture = new ExpectLeaderSlashedFixture(apiWrapper, newStake, WorkingGroups.StorageWorkingGroup)
     await expectLeaderSlashedFixture.runner(false)
-  })
+  })()
 
   const terminateLeaderRoleProposalFixture: TerminateLeaderRoleProposalFixture = new TerminateLeaderRoleProposalFixture(
     apiWrapper,
@@ -276,14 +269,16 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     false,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Propose terminate leader role', async () => await terminateLeaderRoleProposalFixture.runner(false))
+  // Propose terminate leader role
+  await terminateLeaderRoleProposalFixture.runner(false)
 
   let voteForLeaderRoleTerminationFixture: VoteForProposalFixture
   const expectLeaderRoleTerminatedFixture: ExpectLeaderRoleTerminatedFixture = new ExpectLeaderRoleTerminatedFixture(
     apiWrapper,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Approve leader role termination', async () => {
+  // Approve leader role termination
+  await (async () => {
     voteForLeaderRoleTerminationFixture = new VoteForProposalFixture(
       apiWrapper,
       m2KeyPairs,
@@ -292,7 +287,5 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
     )
     voteForLeaderRoleTerminationFixture.runner(false)
     await expectLeaderRoleTerminatedFixture.runner(false)
-  })
-
-  closeApi(apiWrapper)
-})
+  })()
+}

+ 57 - 0
tests/network-tests/src/flows/proposals/spendingProposal.ts

@@ -0,0 +1,57 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { Utils } from '../../utils/utils'
+import { SpendingProposalFixture } from '../../fixtures/proposalsModule'
+import { PaidTermId } from '@joystream/types/members'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { DbService } from '../../services/dbService'
+
+export default async function spendingProposal(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+  const spendingBalance: BN = new BN(+env.SPENDING_BALANCE!)
+  const mintCapacity: BN = new BN(+env.COUNCIL_MINTING_CAPACITY!)
+
+  // const durationInBlocks = 29
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  if (db.hasCouncil()) {
+    m1KeyPairs = db.getMembers()
+    m2KeyPairs = db.getCouncil()
+  } else {
+    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+      apiWrapper,
+      sudo,
+      m1KeyPairs,
+      m2KeyPairs,
+      paidTerms,
+      K,
+      greaterStake,
+      lesserStake
+    )
+    await councilElectionHappyCaseFixture.runner(false)
+  }
+
+  const spendingProposalFixture: SpendingProposalFixture = new SpendingProposalFixture(
+    apiWrapper,
+    m1KeyPairs,
+    m2KeyPairs,
+    sudo,
+    spendingBalance,
+    mintCapacity
+  )
+  // Spending proposal test
+  await spendingProposalFixture.runner(false)
+}

+ 47 - 0
tests/network-tests/src/flows/proposals/textProposal.ts

@@ -0,0 +1,47 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { Utils } from '../../utils/utils'
+import { TextProposalFixture } from '../../fixtures/proposalsModule'
+import { PaidTermId } from '@joystream/types/members'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { DbService } from '../../services/dbService'
+
+export default async function textProposal(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+
+  // const durationInBlocks = 28
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  if (db.hasCouncil()) {
+    m1KeyPairs = db.getMembers()
+    m2KeyPairs = db.getCouncil()
+  } else {
+    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+      apiWrapper,
+      sudo,
+      m1KeyPairs,
+      m2KeyPairs,
+      paidTerms,
+      K,
+      greaterStake,
+      lesserStake
+    )
+    await councilElectionHappyCaseFixture.runner(false)
+  }
+
+  const textProposalFixture: TextProposalFixture = new TextProposalFixture(apiWrapper, m1KeyPairs, m2KeyPairs, sudo)
+  await textProposalFixture.runner(false)
+}

+ 63 - 0
tests/network-tests/src/flows/proposals/updateRuntime.ts

@@ -0,0 +1,63 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { Utils } from '../../utils/utils'
+import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
+import { UpdateRuntimeFixture } from '../../fixtures/proposalsModule'
+import { PaidTermId } from '@joystream/types/members'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { DbService } from '../../services/dbService'
+
+export default async function updateRuntime(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+  const runtimePath: string = env.RUNTIME_WASM_PATH!
+
+  // const durationInBlocks = 54
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  if (db.hasCouncil()) {
+    m1KeyPairs = db.getMembers()
+    m2KeyPairs = db.getCouncil()
+  } else {
+    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+      apiWrapper,
+      sudo,
+      m1KeyPairs,
+      m2KeyPairs,
+      paidTerms,
+      K,
+      greaterStake,
+      lesserStake
+    )
+    await councilElectionHappyCaseFixture.runner(false)
+  }
+
+  const updateRuntimeFixture: UpdateRuntimeFixture = new UpdateRuntimeFixture(
+    apiWrapper,
+    m1KeyPairs,
+    m2KeyPairs,
+    sudo,
+    runtimePath
+  )
+  await updateRuntimeFixture.runner(false)
+
+  const thirdMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
+    apiWrapper,
+    sudo,
+    Utils.createKeyPairs(keyring, N),
+    paidTerms
+  )
+  await thirdMemberSetFixture.runner(false)
+}

+ 54 - 0
tests/network-tests/src/flows/proposals/validatorCountProposal.ts

@@ -0,0 +1,54 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { ApiWrapper } from '../../utils/apiWrapper'
+import { Utils } from '../../utils/utils'
+import { ValidatorCountProposalFixture } from '../../fixtures/proposalsModule'
+import { PaidTermId } from '@joystream/types/members'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { DbService } from '../../services/dbService'
+
+export default async function validatorCount(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+  const validatorCountIncrement: BN = new BN(+env.VALIDATOR_COUNT_INCREMENT!)
+
+  // const durationInBlocks = 29
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  if (db.hasCouncil()) {
+    m1KeyPairs = db.getMembers()
+    m2KeyPairs = db.getCouncil()
+  } else {
+    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+      apiWrapper,
+      sudo,
+      m1KeyPairs,
+      m2KeyPairs,
+      paidTerms,
+      K,
+      greaterStake,
+      lesserStake
+    )
+    await councilElectionHappyCaseFixture.runner(false)
+  }
+
+  const validatorCountProposalFixture: ValidatorCountProposalFixture = new ValidatorCountProposalFixture(
+    apiWrapper,
+    m1KeyPairs,
+    m2KeyPairs,
+    sudo,
+    validatorCountIncrement
+  )
+  await validatorCountProposalFixture.runner(false)
+}

+ 71 - 0
tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts

@@ -0,0 +1,71 @@
+import { KeyringPair } from '@polkadot/keyring/types'
+import { Keyring } from '@polkadot/api'
+import BN from 'bn.js'
+import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Utils } from '../../utils/utils'
+import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../../fixtures/proposalsModule'
+import { ExpectMintCapacityChangedFixture } from '../../fixtures/workingGroupModule'
+import { PaidTermId } from '@joystream/types/members'
+import { ProposalId } from '@joystream/types/proposals'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { DbService } from '../../services/dbService'
+
+export default async function workingGroupMintCapactiy(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
+  const keyring = new Keyring({ type: 'sr25519' })
+  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
+
+  const N: number = +env.MEMBERSHIP_CREATION_N!
+  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
+
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+  const mintCapacityIncrement: BN = new BN(env.MINT_CAPACITY_INCREMENT!)
+
+  // const durationInBlocks = 30
+  // setTestTimeout(apiWrapper, durationInBlocks)
+
+  if (db.hasCouncil()) {
+    m1KeyPairs = db.getMembers()
+    m2KeyPairs = db.getCouncil()
+  } else {
+    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
+      apiWrapper,
+      sudo,
+      m1KeyPairs,
+      m2KeyPairs,
+      paidTerms,
+      K,
+      greaterStake,
+      lesserStake
+    )
+    await councilElectionHappyCaseFixture.runner(false)
+  }
+
+  const newMintCapacity: BN = (await apiWrapper.getWorkingGroupMintCapacity(WorkingGroups.StorageWorkingGroup)).add(
+    mintCapacityIncrement
+  )
+  const workingGroupMintCapacityProposalFixture: WorkingGroupMintCapacityProposalFixture = new WorkingGroupMintCapacityProposalFixture(
+    apiWrapper,
+    m1KeyPairs,
+    sudo,
+    newMintCapacity,
+    WorkingGroups.StorageWorkingGroup
+  )
+  // Propose mint capacity
+  await workingGroupMintCapacityProposalFixture.runner(false)
+
+  const voteForProposalFixture: VoteForProposalFixture = new VoteForProposalFixture(
+    apiWrapper,
+    m2KeyPairs,
+    sudo,
+    workingGroupMintCapacityProposalFixture.getCreatedProposalId() as ProposalId
+  )
+  const expectMintCapacityChanged = new ExpectMintCapacityChangedFixture(apiWrapper, newMintCapacity)
+  // Approve mint capacity
+  voteForProposalFixture.runner(false)
+  await expectMintCapacityChanged.runner(false)
+}

+ 23 - 38
tests/network-tests/src/tests/workingGroup/atLeastValueBugTest.ts → tests/network-tests/src/flows/workingGroup/atLeastValueBug.ts

@@ -1,44 +1,34 @@
-import { initConfig } from '../../utils/config'
-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 { AddWorkerOpeningFixture, LeaveRoleFixture } from '../fixtures/workingGroupModule'
+import { Keyring } from '@polkadot/api'
+import { AddWorkerOpeningFixture, LeaveRoleFixture } from '../../fixtures/workingGroupModule'
 import BN from 'bn.js'
-import tap from 'tap'
 import { Utils } from '../../utils/utils'
 import { PaidTermId } from '@joystream/types/members'
 import { DbService } from '../../services/dbService'
-import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
-tap.mocha.describe('Zero at least value bug scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Zero at least value bug scenario
+export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 48
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
   const openingActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 48
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
@@ -72,10 +62,8 @@ tap.mocha.describe('Zero at least value bug scenario', async () => {
     unstakingPeriod,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test(
-    'Add worker opening with 0 stake, expect failure',
-    async () => await addWorkerOpeningWithoutStakeFixture.runner(true)
-  )
+  // Add worker opening with 0 stake, expect failure
+  await addWorkerOpeningWithoutStakeFixture.runner(true)
 
   const addWorkerOpeningWithoutUnstakingPeriodFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
     apiWrapper,
@@ -88,10 +76,8 @@ tap.mocha.describe('Zero at least value bug scenario', async () => {
     new BN(0),
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test(
-    'Add worker opening with 0 unstaking period, expect failure',
-    async () => await addWorkerOpeningWithoutUnstakingPeriodFixture.runner(true)
-  )
+  // Add worker opening with 0 unstaking period, expect failure
+  await addWorkerOpeningWithoutUnstakingPeriodFixture.runner(true)
 
   if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
@@ -100,8 +86,7 @@ tap.mocha.describe('Zero at least value bug scenario', async () => {
       sudo,
       WorkingGroups.StorageWorkingGroup
     )
-    tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+    // Leaving lead role
+    await leaveRoleFixture.runner(false)
   }
-
-  closeApi(apiWrapper)
-})
+}

+ 51 - 49
tests/network-tests/src/tests/workingGroup/manageWorkerAsLeadTest.ts → tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts

@@ -1,9 +1,6 @@
-import { initConfig } from '../../utils/config'
-import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
+import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
 import {
   AddLeaderOpeningFixture,
   ApplyForOpeningFixture,
@@ -16,42 +13,35 @@ import {
   DecreaseStakeFixture,
   SlashFixture,
   TerminateRoleFixture,
-} from '../fixtures/workingGroupModule'
+} from '../../fixtures/workingGroupModule'
 import { Utils } from '../../utils/utils'
 import BN from 'bn.js'
-import tap from 'tap'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
-import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
-tap.mocha.describe('Manage worker as lead scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Manage worker as lead scenario
+export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 60
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
   const openingActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 60
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
@@ -85,10 +75,12 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     unstakingPeriod,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Add worker opening', async () => await addWorkerOpeningFixture.runner(false))
+  // Add worker opening
+  await addWorkerOpeningFixture.runner(false)
 
   let applyForWorkerOpeningFixture: ApplyForOpeningFixture
-  tap.test('First apply for worker opening', async () => {
+  // First apply for worker opening
+  await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -99,10 +91,11 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
-  })
+  })()
 
   let beginApplicationReviewFixture: BeginApplicationReviewFixture
-  tap.test('Begin application review', async () => {
+  // Begin application review
+  await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
       apiWrapper,
       leadKeyPair[0],
@@ -111,10 +104,11 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
-  })
+  })()
 
   let fillOpeningFixture: FillOpeningFixture
-  tap.test('Fill worker opening', async () => {
+  // Fill worker opening
+  await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -127,7 +121,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await fillOpeningFixture.runner(false)
-  })
+  })()
 
   const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
     apiWrapper,
@@ -135,7 +129,8 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+  // Leaving lead role
+  await leaveRoleFixture.runner(false)
 
   const decreaseStakeFailureFixture: DecreaseStakeFixture = new DecreaseStakeFixture(
     apiWrapper,
@@ -144,7 +139,8 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Decrease worker stake, expect failure', async () => await decreaseStakeFailureFixture.runner(true))
+  // Decrease worker stake, expect failure
+  await decreaseStakeFailureFixture.runner(true)
 
   const addNewLeaderOpeningFixture: AddLeaderOpeningFixture = new AddLeaderOpeningFixture(
     apiWrapper,
@@ -155,10 +151,12 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     openingActivationDelay,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Add lead opening', async () => await addNewLeaderOpeningFixture.runner(false))
+  // Add lead opening
+  await addNewLeaderOpeningFixture.runner(false)
 
   let applyForNewLeaderOpeningFixture: ApplyForOpeningFixture
-  tap.test('Apply for lead opening', async () => {
+  // Apply for lead opening
+  await (async () => {
     applyForNewLeaderOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       leadKeyPair,
@@ -169,10 +167,11 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForNewLeaderOpeningFixture.runner(false)
-  })
+  })()
 
   let beginNewLeaderApplicationReviewFixture: BeginLeaderApplicationReviewFixture
-  tap.test('Begin lead application review', async () => {
+  // Begin lead application review
+  await (async () => {
     beginNewLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
@@ -180,10 +179,11 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await beginNewLeaderApplicationReviewFixture.runner(false)
-  })
+  })()
 
   let fillNewLeaderOpeningFixture: FillLeaderOpeningFixture
-  tap.test('Fill lead opening', async () => {
+  // Fill lead opening
+  await (async () => {
     fillNewLeaderOpeningFixture = new FillLeaderOpeningFixture(
       apiWrapper,
       leadKeyPair,
@@ -195,7 +195,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await fillNewLeaderOpeningFixture.runner(false)
-  })
+  })()
 
   const decreaseStakeFixture: DecreaseStakeFixture = new DecreaseStakeFixture(
     apiWrapper,
@@ -204,7 +204,8 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Decrease worker stake', async () => await decreaseStakeFixture.runner(false))
+  // Decrease worker stake
+  await decreaseStakeFixture.runner(false)
 
   const slashFixture: SlashFixture = new SlashFixture(
     apiWrapper,
@@ -213,7 +214,8 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Slash worker', async () => await slashFixture.runner(false))
+  // Slash worker
+  await slashFixture.runner(false)
 
   const terminateRoleFixture: TerminateRoleFixture = new TerminateRoleFixture(
     apiWrapper,
@@ -222,7 +224,8 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Terminate worker role', async () => await terminateRoleFixture.runner(false))
+  // Terminate worker role
+  await terminateRoleFixture.runner(false)
 
   if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
@@ -231,8 +234,7 @@ tap.mocha.describe('Manage worker as lead scenario', async () => {
       sudo,
       WorkingGroups.StorageWorkingGroup
     )
-    tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+    // Leaving lead role
+    await leaveRoleFixture.runner(false)
   }
-
-  closeApi(apiWrapper)
-})
+}

+ 36 - 40
tests/network-tests/src/tests/workingGroup/manageWorkerAsWorkerTest.ts → tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts

@@ -1,9 +1,6 @@
-import { initConfig } from '../../utils/config'
-import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
+import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
 import {
   AddWorkerOpeningFixture,
   ApplyForOpeningFixture,
@@ -12,42 +9,35 @@ import {
   IncreaseStakeFixture,
   LeaveRoleFixture,
   UpdateRewardAccountFixture,
-} from '../fixtures/workingGroupModule'
+} from '../../fixtures/workingGroupModule'
 import { Utils } from '../../utils/utils'
 import BN from 'bn.js'
-import tap from 'tap'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
-import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
-tap.mocha.describe('Manage worker as worker scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Manage worker as worker
+export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 38
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
   const openingActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 38
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
@@ -81,10 +71,12 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     unstakingPeriod,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Add worker opening', async () => await addWorkerOpeningFixture.runner(false))
+  // Add worker opening
+  await addWorkerOpeningFixture.runner(false)
 
   let applyForWorkerOpeningFixture: ApplyForOpeningFixture
-  tap.test('First apply for worker opening', async () => {
+  // First apply for worker opening
+  await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -95,10 +87,11 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
-  })
+  })()
 
   let beginApplicationReviewFixture: BeginApplicationReviewFixture
-  tap.test('Begin application review', async () => {
+  // Begin application review
+  await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
       apiWrapper,
       leadKeyPair[0],
@@ -107,10 +100,11 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
-  })
+  })()
 
   let fillOpeningFixture: FillOpeningFixture
-  tap.test('Fill worker opening', async () => {
+  // Fill worker opening
+  await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -123,7 +117,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await fillOpeningFixture.runner(false)
-  })
+  })()
 
   const increaseStakeFixture: IncreaseStakeFixture = new IncreaseStakeFixture(
     apiWrapper,
@@ -131,7 +125,8 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Increase worker stake', async () => await increaseStakeFixture.runner(false))
+  // Increase worker stake
+  await increaseStakeFixture.runner(false)
 
   const updateRewardAccountFixture: UpdateRewardAccountFixture = new UpdateRewardAccountFixture(
     apiWrapper,
@@ -140,7 +135,8 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Update reward account', async () => await updateRewardAccountFixture.runner(false))
+  // Update reward account
+  await updateRewardAccountFixture.runner(false)
 
   const updateRoleAccountFixture: UpdateRewardAccountFixture = new UpdateRewardAccountFixture(
     apiWrapper,
@@ -149,7 +145,8 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Update role account', async () => await updateRoleAccountFixture.runner(false))
+  // Update role account
+  await updateRoleAccountFixture.runner(false)
 
   if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
@@ -158,8 +155,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       sudo,
       WorkingGroups.StorageWorkingGroup
     )
-    tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+    // Leaving lead role
+    await leaveRoleFixture.runner(false)
   }
-
-  closeApi(apiWrapper)
-})
+}

+ 35 - 40
tests/network-tests/src/tests/workingGroup/workerApplicationHappyCaseTest.ts → tests/network-tests/src/flows/workingGroup/workerApplicationHappyCase.ts

@@ -1,11 +1,7 @@
-import { initConfig } from '../../utils/config'
-import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
+import { 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 { Utils } from '../../utils/utils'
 import {
   AddWorkerOpeningFixture,
@@ -14,39 +10,33 @@ import {
   FillOpeningFixture,
   LeaveRoleFixture,
   WithdrawApplicationFixture,
-} from '../fixtures/workingGroupModule'
+} from '../../fixtures/workingGroupModule'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
-import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
-tap.mocha.describe('Worker application happy case scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Worker application happy case scenario
+export default async function workerApplication(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 48
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
   const openingActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 48
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
@@ -80,10 +70,12 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
     unstakingPeriod,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Add worker opening', async () => await addWorkerOpeningFixture.runner(false))
+  // Add worker opening
+  await addWorkerOpeningFixture.runner(false)
 
   let firstApplyForWorkerOpeningFixture: ApplyForOpeningFixture
-  tap.test('First apply for worker opening', async () => {
+  // First apply for worker opening
+  await (async () => {
     firstApplyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -94,7 +86,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await firstApplyForWorkerOpeningFixture.runner(false)
-  })
+  })()
 
   const withdrawApplicationFixture: WithdrawApplicationFixture = new WithdrawApplicationFixture(
     apiWrapper,
@@ -102,10 +94,12 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Withdraw worker application', async () => await withdrawApplicationFixture.runner(false))
+  // Withdraw worker application
+  await withdrawApplicationFixture.runner(false)
 
   let secondApplyForWorkerOpeningFixture: ApplyForOpeningFixture
-  tap.test('Second apply for worker opening', async () => {
+  // Second apply for worker opening
+  await (async () => {
     secondApplyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -116,10 +110,11 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await secondApplyForWorkerOpeningFixture.runner(false)
-  })
+  })()
 
   let beginApplicationReviewFixture: BeginApplicationReviewFixture
-  tap.test('Begin application review', async () => {
+  // Begin application review
+  await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
       apiWrapper,
       leadKeyPair[0],
@@ -128,10 +123,11 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
-  })
+  })()
 
   let fillOpeningFixture: FillOpeningFixture
-  tap.test('Fill worker opening', async () => {
+  // Fill worker opening
+  await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -144,7 +140,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await fillOpeningFixture.runner(false)
-  })
+  })()
 
   if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
@@ -153,8 +149,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       WorkingGroups.StorageWorkingGroup
     )
-    tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+    // Leaving lead role
+    await leaveRoleFixture.runner(false)
   }
-
-  closeApi(apiWrapper)
-})
+}

+ 39 - 40
tests/network-tests/src/tests/workingGroup/workerApplicationRejectionCaseTest.ts → tests/network-tests/src/flows/workingGroup/workerApplicationRejectionCase.ts

@@ -1,11 +1,7 @@
-import { initConfig } from '../../utils/config'
-import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
+import { 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 { Utils } from '../../utils/utils'
 import {
   AcceptApplicationsFixture,
@@ -13,41 +9,39 @@ import {
   ApplyForOpeningFixture,
   LeaveRoleFixture,
   TerminateApplicationsFixture,
-} from '../fixtures/workingGroupModule'
+} from '../../fixtures/workingGroupModule'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
-import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
-tap.mocha.describe('Worker application rejection case scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Worker application rejection case scenario
+export default async function workerApplicationRejection(
+  apiWrapper: ApiWrapper,
+  env: NodeJS.ProcessEnv,
+  db: DbService
+) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
   const nonMemberKeyPairs = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 38
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
   const openingActivationDelay: BN = new BN(100)
   const leadOpeningActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 38
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
@@ -81,10 +75,12 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
     unstakingPeriod,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Add worker opening', async () => await addWorkerOpeningFixture.runner(false))
+  // Add worker opening
+  await addWorkerOpeningFixture.runner(false)
 
   let applyForWorkerOpeningBeforeAcceptanceFixture: ApplyForOpeningFixture
-  tap.test('Apply for worker opening, expect failure', async () => {
+  // Apply for worker opening, expect failure
+  await (async () => {
     applyForWorkerOpeningBeforeAcceptanceFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -95,10 +91,11 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningBeforeAcceptanceFixture.runner(true)
-  })
+  })()
 
   let acceptApplicationsFixture: AcceptApplicationsFixture
-  tap.test('Begin accepting worker applications', async () => {
+  // Begin accepting worker applications
+  await (async () => {
     acceptApplicationsFixture = new AcceptApplicationsFixture(
       apiWrapper,
       leadKeyPair[0],
@@ -107,10 +104,11 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await acceptApplicationsFixture.runner(false)
-  })
+  })()
 
   let applyForWorkerOpeningAsNonMemberFixture: ApplyForOpeningFixture
-  tap.test('Apply for worker opening as non-member, expect failure', async () => {
+  // Apply for worker opening as non-member, expect failure
+  await (async () => {
     applyForWorkerOpeningAsNonMemberFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nonMemberKeyPairs,
@@ -121,10 +119,11 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningAsNonMemberFixture.runner(true)
-  })
+  })()
 
   let applyForWorkerOpeningFixture: ApplyForOpeningFixture
-  tap.test('Apply for worker opening', async () => {
+  // Apply for worker opening
+  await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       nKeyPairs,
@@ -135,7 +134,7 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
-  })
+  })()
 
   const terminateApplicationsFixture: TerminateApplicationsFixture = new TerminateApplicationsFixture(
     apiWrapper,
@@ -144,7 +143,8 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
     sudo,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Terminate worker applicaitons', async () => await terminateApplicationsFixture.runner(false))
+  // Terminate worker applicaitons
+  await terminateApplicationsFixture.runner(false)
 
   if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
@@ -153,8 +153,7 @@ tap.mocha.describe('Worker application rejection case scenario', async () => {
       sudo,
       WorkingGroups.StorageWorkingGroup
     )
-    tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+    // Leaving lead role
+    await leaveRoleFixture.runner(false)
   }
-
-  closeApi(apiWrapper)
-})
+}

+ 48 - 51
tests/network-tests/src/tests/workingGroup/workerPayoutTest.ts → tests/network-tests/src/flows/workingGroup/workerPayout.ts

@@ -1,9 +1,6 @@
-import { initConfig } from '../../utils/config'
-import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
+import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
 import {
   AddWorkerOpeningFixture,
   ApplyForOpeningFixture,
@@ -12,54 +9,47 @@ import {
   ExpectMintCapacityChangedFixture,
   FillOpeningFixture,
   LeaveRoleFixture,
-} from '../fixtures/workingGroupModule'
+} from '../../fixtures/workingGroupModule'
 import BN from 'bn.js'
-import tap from 'tap'
 import { Utils } from '../../utils/utils'
-import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
+import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
 import { ProposalId } from '@joystream/types/proposals'
 import { DbService } from '../../services/dbService'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
-import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
+import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
+import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
+import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 
-tap.mocha.describe('Worker payout scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
+// Worker payout scenario
+export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+  const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
 
-  const N: number = +process.env.WORKING_GROUP_N!
+  const N: number = +env.WORKING_GROUP_N!
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m3KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const mintCapacity: BN = new BN(process.env.STORAGE_WORKING_GROUP_MINTING_CAPACITY!)
-  const durationInBlocks = 58
+  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const K: number = +env.COUNCIL_ELECTION_K!
+  const greaterStake: BN = new BN(+env.COUNCIL_STAKE_GREATER_AMOUNT!)
+  const lesserStake: BN = new BN(+env.COUNCIL_STAKE_LESSER_AMOUNT!)
+  const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
+  const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
+  const leaderFirstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const leaderRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
+  const firstRewardInterval: BN = new BN(env.SHORT_FIRST_REWARD_INTERVAL!)
+  const rewardInterval: BN = new BN(env.SHORT_REWARD_INTERVAL!)
+  const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
+  const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
+  const mintCapacity: BN = new BN(env.STORAGE_WORKING_GROUP_MINTING_CAPACITY!)
   const openingActivationDelay: BN = new BN(0)
 
-  setTestTimeout(apiWrapper, durationInBlocks)
+  // const durationInBlocks = 58
+  // setTestTimeout(apiWrapper, durationInBlocks)
 
   if (db.hasCouncil()) {
     const memberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
@@ -68,7 +58,8 @@ tap.mocha.describe('Worker payout scenario', async () => {
       m1KeyPairs,
       paidTerms
     )
-    tap.test('Recreating set of members', async () => await memberSetFixture.runner(false))
+    // Recreating set of members
+    await memberSetFixture.runner(false)
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
@@ -111,14 +102,16 @@ tap.mocha.describe('Worker payout scenario', async () => {
     mintCapacity,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Propose mint capacity', async () => await workingGroupMintCapacityProposalFixture.runner(false))
+  // Propose mint capacity
+  await workingGroupMintCapacityProposalFixture.runner(false)
 
   let voteForProposalFixture: VoteForProposalFixture
   const expectMintCapacityChanged: ExpectMintCapacityChangedFixture = new ExpectMintCapacityChangedFixture(
     apiWrapper,
     mintCapacity
   )
-  tap.test('Approve mint capacity', async () => {
+  // Approve mint capacity
+  await (async () => {
     voteForProposalFixture = new VoteForProposalFixture(
       apiWrapper,
       m2KeyPairs,
@@ -127,7 +120,7 @@ tap.mocha.describe('Worker payout scenario', async () => {
     )
     voteForProposalFixture.runner(false)
     await expectMintCapacityChanged.runner(false)
-  })
+  })()
 
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
     apiWrapper,
@@ -140,10 +133,12 @@ tap.mocha.describe('Worker payout scenario', async () => {
     unstakingPeriod,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Add worker opening', async () => await addWorkerOpeningFixture.runner(false))
+  // Add worker opening
+  await addWorkerOpeningFixture.runner(false)
 
   let applyForWorkerOpeningFixture: ApplyForOpeningFixture
-  tap.test('First apply for worker opening', async () => {
+  // First apply for worker opening
+  await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
       apiWrapper,
       m1KeyPairs,
@@ -154,10 +149,11 @@ tap.mocha.describe('Worker payout scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
-  })
+  })()
 
   let beginApplicationReviewFixture: BeginApplicationReviewFixture
-  tap.test('Begin application review', async () => {
+  // Begin application review
+  await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
       apiWrapper,
       leadKeyPair[0],
@@ -166,10 +162,11 @@ tap.mocha.describe('Worker payout scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
-  })
+  })()
 
   let fillOpeningFixture: FillOpeningFixture
-  tap.test('Fill worker opening', async () => {
+  // Fill worker opening
+  await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
       apiWrapper,
       m1KeyPairs,
@@ -182,14 +179,15 @@ tap.mocha.describe('Worker payout scenario', async () => {
       WorkingGroups.StorageWorkingGroup
     )
     await fillOpeningFixture.runner(false)
-  })
+  })()
 
   const awaitPayoutFixture: AwaitPayoutFixture = new AwaitPayoutFixture(
     apiWrapper,
     m1KeyPairs,
     WorkingGroups.StorageWorkingGroup
   )
-  tap.test('Await worker payout', async () => await awaitPayoutFixture.runner(false))
+  // Await worker payout
+  await awaitPayoutFixture.runner(false)
 
   if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
@@ -198,8 +196,7 @@ tap.mocha.describe('Worker payout scenario', async () => {
       sudo,
       WorkingGroups.StorageWorkingGroup
     )
-    tap.test('Leaving lead role', async () => await leaveRoleFixture.runner(false))
+    // Leaving lead role
+    await leaveRoleFixture.runner(false)
   }
-
-  closeApi(apiWrapper)
-})
+}

+ 85 - 0
tests/network-tests/src/scenarios/full.ts

@@ -0,0 +1,85 @@
+import { WsProvider } from '@polkadot/api'
+import { ApiWrapper } from '../utils/apiWrapper'
+import { initConfig } from '../utils/config'
+import { DbService } from '../services/dbService'
+
+import creatingMemberships from '../flows/membership/creatingMemberships'
+import councilSetup from '../flows/councilSetup'
+import leaderSetup from '../flows/leaderSetup'
+import electionParametersProposal from '../flows/proposals/electionParametersProposal'
+import manageLeaderRole from '../flows/proposals/manageLeaderRole'
+import spendingProposal from '../flows/proposals/spendingProposal'
+import textProposal from '../flows/proposals/textProposal'
+import validatorCountProposal from '../flows/proposals/validatorCountProposal'
+import workingGroupMintCapacityProposal from '../flows/proposals/workingGroupMintCapacityProposal'
+import atLeastValueBug from '../flows/workingGroup/atLeastValueBug'
+import manageWorkerAsLead from '../flows/workingGroup/manageWorkerAsLead'
+import manageWorkerAsWorker from '../flows/workingGroup/manageWorkerAsWorker'
+import workerApplicaionHappyCase from '../flows/workingGroup/workerApplicationHappyCase'
+import workerApplicationRejectionCase from '../flows/workingGroup/workerApplicationRejectionCase'
+import workerPayout from '../flows/workingGroup/workerPayout'
+
+import createDebug from 'debug'
+const debug = createDebug('network-tests')
+
+const scenario = async () => {
+  // Load env variables
+  initConfig()
+  const env = process.env
+
+  // Connect api to the chain
+  const nodeUrl: string = process.env.NODE_URL!
+  const provider = new WsProvider(nodeUrl)
+  const api: ApiWrapper = await ApiWrapper.create(provider)
+
+  // Create shared state instance
+  const db: DbService = DbService.getInstance()
+
+  // Run flows serially passing them a 'context'
+
+  debug('Memberships')
+  await creatingMemberships(api, env)
+
+  debug('Council')
+  await councilSetup(api, env, db)
+
+  // Proposals...
+  debug('Election Parameters')
+  await electionParametersProposal(api, env, db)
+
+  debug('Spending Proposal')
+  await spendingProposal(api, env, db)
+
+  debug('Text Proposal')
+  await textProposal(api, env, db)
+
+  debug('Validator Count Proposal')
+  await validatorCountProposal(api, env, db)
+
+  debug('Working Group Mint Capacity Proposal')
+  await workingGroupMintCapacityProposal(api, env, db)
+
+  // Leads are fired at the end of the scenarios
+  debug('Lead Role Proposals')
+  await manageLeaderRole(api, env, db /*, storage group */)
+  // await manageLeaderRole(api, env, db /*, content group */)
+
+  /* workers tests */
+
+  debug('Lead Setup')
+  await leaderSetup(api, env, db) /* storage */
+
+  debug('Worker Tests')
+  await atLeastValueBug(api, env, db)
+  await manageWorkerAsLead(api, env, db)
+  await manageWorkerAsWorker(api, env, db)
+  await workerApplicaionHappyCase(api, env, db)
+  await workerApplicationRejectionCase(api, env, db)
+  await workerPayout(api, env, db)
+
+  // Note: disconnecting and then reconnecting to the chain in the same process
+  // doesn't seem to work!
+  api.close()
+}
+
+scenario()

+ 0 - 0
tests/network-tests/src/tap-parallel-not-ok


+ 0 - 64
tests/network-tests/src/tests/council/electingCouncilTest.ts

@@ -1,64 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import BN from 'bn.js'
-import tap from 'tap'
-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'
-import { PaidTermId } from '@joystream/types/members'
-
-tap.mocha.describe('Electing council scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 durationInBlocks = 25
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  const firstMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-    apiWrapper,
-    sudo,
-    m1KeyPairs,
-    paidTerms
-  )
-  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))
-
-  closeApi(apiWrapper)
-})

+ 0 - 57
tests/network-tests/src/tests/councilSetup.ts

@@ -1,57 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import tap from 'tap'
-import { PaidTermId } from '@joystream/types/members'
-import { DbService } from '../services/dbService'
-import { initConfig } from '../utils/config'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { Utils } from '../utils/utils'
-import { setTestTimeout } from '../utils/setTestTimeout'
-import { closeApi } from '../utils/closeApi'
-import { CouncilElectionHappyCaseFixture } from './fixtures/councilElectionHappyCase'
-
-tap.mocha.describe('Electing council scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const db: DbService = DbService.getInstance()
-  if (db.hasCouncil()) {
-    return
-  }
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 durationInBlocks = 25
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-    apiWrapper,
-    sudo,
-    m1KeyPairs,
-    m2KeyPairs,
-    paidTerms,
-    K,
-    greaterStake,
-    lesserStake
-  )
-  await councilElectionHappyCaseFixture.runner(false)
-
-  db.setMembers(m1KeyPairs)
-  db.setCouncil(m2KeyPairs)
-
-  closeApi(apiWrapper)
-})

+ 0 - 56
tests/network-tests/src/tests/membership/membershipCreationTest.ts

@@ -1,56 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { Keyring, WsProvider } from '@polkadot/api'
-import { initConfig } from '../../utils/config'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { closeApi } from '../../utils/closeApi'
-import { BuyMembershipHappyCaseFixture, BuyMembershipWithInsufficienFundsFixture } from '../fixtures/membershipModule'
-import { Utils } from '../../utils/utils'
-import { PaidTermId } from '@joystream/types/members'
-import BN from 'bn.js'
-
-tap.mocha.describe('Membership creation scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  const aKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+process.env.MEMBERSHIP_PAID_TERMS!))
-
-  const durationInBlocks = 7
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  const happyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-    apiWrapper,
-    sudo,
-    nKeyPairs,
-    paidTerms
-  )
-  tap.test('Buy membeship is accepted with sufficient funds', async () => happyCaseFixture.runner(false))
-
-  const insufficientFundsFixture: BuyMembershipWithInsufficienFundsFixture = new BuyMembershipWithInsufficienFundsFixture(
-    apiWrapper,
-    sudo,
-    aKeyPair[0],
-    paidTerms
-  )
-  tap.test('Account A can not buy the membership with insufficient funds', async () =>
-    insufficientFundsFixture.runner(false)
-  )
-
-  const buyMembershipAfterAccountTopUp = new BuyMembershipHappyCaseFixture(apiWrapper, sudo, aKeyPair, paidTerms)
-  tap.test('Account A was able to buy the membership with sufficient funds', async () =>
-    buyMembershipAfterAccountTopUp.runner(false)
-  )
-
-  closeApi(apiWrapper)
-})

+ 0 - 70
tests/network-tests/src/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts

@@ -1,70 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { ContentWorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
-import { Utils } from '../../utils/utils'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Validator count proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 mintingCapacityIncrement: BN = new BN(+process.env.MINTING_CAPACITY_INCREMENT!)
-
-  const durationInBlocks = 29
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const contentWorkingGroupMintCapacityProposalFixture: ContentWorkingGroupMintCapacityProposalFixture = new ContentWorkingGroupMintCapacityProposalFixture(
-    apiWrapper,
-    m1KeyPairs,
-    m2KeyPairs,
-    sudo,
-    mintingCapacityIncrement
-  )
-  tap.test(
-    'Content working group mint capacity test',
-    async () => await contentWorkingGroupMintCapacityProposalFixture.runner(false)
-  )
-
-  closeApi(apiWrapper)
-})

+ 0 - 65
tests/network-tests/src/tests/proposals/electionParametersProposalTest.ts

@@ -1,65 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { ElectionParametersProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Election parameters proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 durationInBlocks = 29
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const electionParametersProposalFixture: ElectionParametersProposalFixture = new ElectionParametersProposalFixture(
-    apiWrapper,
-    m1KeyPairs,
-    m2KeyPairs,
-    sudo
-  )
-  tap.test('Election parameters proposal test', async () => await electionParametersProposalFixture.runner(false))
-
-  closeApi(apiWrapper)
-})

+ 0 - 65
tests/network-tests/src/tests/proposals/setLeadProposalTest.ts

@@ -1,65 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { SetLeadProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Set lead proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 durationInBlocks = 29
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const setLeadProposalFixture: SetLeadProposalFixture = new SetLeadProposalFixture(
-    apiWrapper,
-    m1KeyPairs,
-    m2KeyPairs,
-    sudo
-  )
-  tap.test('Set lead proposal test', async () => await setLeadProposalFixture.runner(false))
-
-  closeApi(apiWrapper)
-})

+ 0 - 68
tests/network-tests/src/tests/proposals/spendingProposalTest.ts

@@ -1,68 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { SpendingProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Spending proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 spendingBalance: BN = new BN(+process.env.SPENDING_BALANCE!)
-  const mintCapacity: BN = new BN(+process.env.COUNCIL_MINTING_CAPACITY!)
-  const durationInBlocks = 29
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const spendingProposalFixture: SpendingProposalFixture = new SpendingProposalFixture(
-    apiWrapper,
-    m1KeyPairs,
-    m2KeyPairs,
-    sudo,
-    spendingBalance,
-    mintCapacity
-  )
-  tap.test('Spending proposal test', async () => await spendingProposalFixture.runner(false))
-
-  closeApi(apiWrapper)
-})

+ 0 - 59
tests/network-tests/src/tests/proposals/textProposalTest.ts

@@ -1,59 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { TextProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Text proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 durationInBlocks = 28
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const textProposalFixture: TextProposalFixture = new TextProposalFixture(apiWrapper, m1KeyPairs, m2KeyPairs, sudo)
-  tap.test('Text proposal test', async () => await textProposalFixture.runner(false))
-
-  closeApi(apiWrapper)
-})

+ 0 - 75
tests/network-tests/src/tests/proposals/updateRuntime.ts

@@ -1,75 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
-import { UpdateRuntimeFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Update runtime scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 runtimePath: string = process.env.RUNTIME_WASM_PATH!
-  const durationInBlocks = 54
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const updateRuntimeFixture: UpdateRuntimeFixture = new UpdateRuntimeFixture(
-    apiWrapper,
-    m1KeyPairs,
-    m2KeyPairs,
-    sudo,
-    runtimePath
-  )
-  tap.test('Upgrade runtime', async () => await updateRuntimeFixture.runner(false))
-
-  const thirdMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-    apiWrapper,
-    sudo,
-    Utils.createKeyPairs(keyring, N),
-    paidTerms
-  )
-  tap.test('Creating third set of members', async () => await thirdMemberSetFixture.runner(false))
-
-  closeApi(apiWrapper)
-})

+ 0 - 66
tests/network-tests/src/tests/proposals/validatorCountProposalTest.ts

@@ -1,66 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { ValidatorCountProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@joystream/types/members'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Validator count proposal scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 validatorCountIncrement: BN = new BN(+process.env.VALIDATOR_COUNT_INCREMENT!)
-  const durationInBlocks = 29
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const validatorCountProposalFixture: ValidatorCountProposalFixture = new ValidatorCountProposalFixture(
-    apiWrapper,
-    m1KeyPairs,
-    m2KeyPairs,
-    sudo,
-    validatorCountIncrement
-  )
-  tap.test('Validator count proposal', async () => await validatorCountProposalFixture.runner(false))
-
-  closeApi(apiWrapper)
-})

+ 0 - 87
tests/network-tests/src/tests/proposals/workingGroupMintCapacityProposalTest.ts

@@ -1,87 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { closeApi } from '../../utils/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { Utils } from '../../utils/utils'
-import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
-import { ExpectMintCapacityChangedFixture } from '../fixtures/workingGroupModule'
-import { PaidTermId } from '@joystream/types/members'
-import { ProposalId } from '@joystream/types/proposals'
-import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
-
-tap.mocha.describe('Set storage working group mint capacity scenario', async () => {
-  initConfig()
-
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const keyring = new Keyring({ type: 'sr25519' })
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const db: DbService = DbService.getInstance()
-
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  let m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+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 mintCapacityIncrement: BN = new BN(process.env.MINT_CAPACITY_INCREMENT!)
-  const durationInBlocks = 30
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-
-  if (db.hasCouncil()) {
-    m1KeyPairs = db.getMembers()
-    m2KeyPairs = db.getCouncil()
-  } else {
-    const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
-      sudo,
-      m1KeyPairs,
-      m2KeyPairs,
-      paidTerms,
-      K,
-      greaterStake,
-      lesserStake
-    )
-    await councilElectionHappyCaseFixture.runner(false)
-  }
-
-  const newMintCapacity: BN = (await apiWrapper.getWorkingGroupMintCapacity(WorkingGroups.StorageWorkingGroup)).add(
-    mintCapacityIncrement
-  )
-  const workingGroupMintCapacityProposalFixture: WorkingGroupMintCapacityProposalFixture = new WorkingGroupMintCapacityProposalFixture(
-    apiWrapper,
-    m1KeyPairs,
-    sudo,
-    newMintCapacity,
-    WorkingGroups.StorageWorkingGroup
-  )
-  tap.test('Propose mint capacity', async () => await workingGroupMintCapacityProposalFixture.runner(false))
-
-  let voteForProposalFixture: VoteForProposalFixture
-  const expectMintCapacityChanged: ExpectMintCapacityChangedFixture = new ExpectMintCapacityChangedFixture(
-    apiWrapper,
-    newMintCapacity
-  )
-  tap.test('Approve mint capacity', async () => {
-    voteForProposalFixture = new VoteForProposalFixture(
-      apiWrapper,
-      m2KeyPairs,
-      sudo,
-      workingGroupMintCapacityProposalFixture.getCreatedProposalId() as ProposalId
-    )
-    voteForProposalFixture.runner(false)
-    await expectMintCapacityChanged.runner(false)
-  })
-
-  closeApi(apiWrapper)
-})

+ 0 - 12
tests/network-tests/src/utils/apiWrapper.ts

@@ -989,12 +989,6 @@ export class ApiWrapper {
     })
   }
 
-  public async getContentWorkingGroupMintCapacity(): Promise<BN> {
-    const mintId: MintId = await this.api.query.contentWorkingGroup.mint<MintId>()
-    const mint: Mint = await this.api.query.minting.mints<Mint>(mintId)
-    return mint.capacity
-  }
-
   public async getWorkingGroupMintCapacity(module: WorkingGroups): Promise<BN> {
     const mintId: MintId = await this.api.query[module].mint<MintId>()
     const mint: Mint = await this.api.query.minting.mints<Mint>(mintId)
@@ -1005,12 +999,6 @@ export class ApiWrapper {
     return this.api.query.staking.validatorCount<u32>()
   }
 
-  public async getCurrentLeadAddress(): Promise<string> {
-    const leadId: Option<LeadId> = await this.api.query.contentWorkingGroup.currentLeadId<Option<LeadId>>()
-    const lead = await this.api.query.contentWorkingGroup.leadById<Lead>(leadId.unwrap())
-    return lead.role_account.toString()
-  }
-
   public async isStorageProvider(address: string): Promise<boolean> {
     const storageProviders: Vec<AccountId> = await this.api.query.actors.accountIdsByRole<Vec<AccountId>>(
       'StorageProvider'

+ 0 - 8
tests/network-tests/src/utils/closeApi.ts

@@ -1,8 +0,0 @@
-import { ApiWrapper } from './apiWrapper'
-import tap from 'tap'
-
-export function closeApi(apiWrapper: ApiWrapper) {
-  tap.teardown(() => {
-    apiWrapper.close()
-  })
-}

+ 1 - 2
tests/network-tests/src/utils/setTestTimeout.ts

@@ -1,7 +1,6 @@
-import tap from 'tap'
 import { ApiWrapper } from './apiWrapper'
 
 export function setTestTimeout(apiWrapper: ApiWrapper, durationInBlocks: number) {
   const durationInMillis = apiWrapper.getBlockDuration().muln(durationInBlocks).toNumber()
-  tap.setTimeout(durationInMillis)
+  // tap.setTimeout(durationInMillis)
 }

File diff suppressed because it is too large
+ 15 - 593
yarn.lock


Some files were not shown because too many files changed in this diff