Browse Source

network-test: refactoring/renaming

Mokhtar Naamani 4 years ago
parent
commit
f886545270
30 changed files with 626 additions and 799 deletions
  1. 10 45
      tests/network-tests/src/Api.ts
  2. 0 0
      tests/network-tests/src/DbService.ts
  3. 0 0
      tests/network-tests/src/IFixture.ts
  4. 8 8
      tests/network-tests/src/fixtures/councilElectionHappyCase.ts
  5. 27 31
      tests/network-tests/src/fixtures/councilElectionModule.ts
  6. 11 11
      tests/network-tests/src/fixtures/leaderHiringHappyCase.ts
  7. 20 24
      tests/network-tests/src/fixtures/membershipModule.ts
  8. 150 212
      tests/network-tests/src/fixtures/proposalsModule.ts
  9. 171 215
      tests/network-tests/src/fixtures/workingGroupModule.ts
  10. 7 7
      tests/network-tests/src/flows/councilSetup.ts
  11. 9 9
      tests/network-tests/src/flows/leaderSetup.ts
  12. 11 15
      tests/network-tests/src/flows/membership/creatingMemberships.ts
  13. 8 12
      tests/network-tests/src/flows/proposals/electionParametersProposal.ts
  14. 31 32
      tests/network-tests/src/flows/proposals/manageLeaderRole.ts
  15. 8 8
      tests/network-tests/src/flows/proposals/spendingProposal.ts
  16. 8 8
      tests/network-tests/src/flows/proposals/textProposal.ts
  17. 9 9
      tests/network-tests/src/flows/proposals/updateRuntime.ts
  18. 8 8
      tests/network-tests/src/flows/proposals/validatorCountProposal.ts
  19. 11 11
      tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts
  20. 13 13
      tests/network-tests/src/flows/workingGroup/atLeastValueBug.ts
  21. 24 24
      tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts
  22. 18 18
      tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts
  23. 17 17
      tests/network-tests/src/flows/workingGroup/workerApplicationHappyCase.ts
  24. 17 21
      tests/network-tests/src/flows/workingGroup/workerApplicationRejectionCase.ts
  25. 21 21
      tests/network-tests/src/flows/workingGroup/workerPayout.ts
  26. 8 8
      tests/network-tests/src/scenarios/full.ts
  27. 1 1
      tests/network-tests/src/sender.ts
  28. 0 0
      tests/network-tests/src/utils.ts
  29. 0 5
      tests/network-tests/src/utils/config.ts
  30. 0 6
      tests/network-tests/src/utils/setTestTimeout.ts

+ 10 - 45
tests/network-tests/src/utils/apiWrapper.ts → tests/network-tests/src/Api.ts

@@ -4,7 +4,6 @@ import { Codec } from '@polkadot/types/types'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { MemberId, PaidMembershipTerms, PaidTermId } from '@joystream/types/members'
 import { Mint, MintId } from '@joystream/types/mint'
-import { Lead, LeadId } from '@joystream/types/content-working-group'
 import {
   Application,
   ApplicationIdToWorkerIdMap,
@@ -34,11 +33,11 @@ export enum WorkingGroups {
   StorageWorkingGroup = 'storageWorkingGroup',
 }
 
-export class ApiWrapper {
+export class Api {
   private readonly api: ApiPromise
   private readonly sender: Sender
 
-  public static async create(provider: WsProvider): Promise<ApiWrapper> {
+  public static async create(provider: WsProvider): Promise<Api> {
     const api = await ApiPromise.create({ provider, types })
 
     // Wait for api to be connected and ready
@@ -50,7 +49,7 @@ export class ApiWrapper {
       setTimeout(resolve, 5000)
     })
 
-    return new ApiWrapper(api)
+    return new Api(api)
   }
 
   constructor(api: ApiPromise) {
@@ -180,23 +179,6 @@ export class ApiWrapper {
     )
   }
 
-  public estimateProposeContentWorkingGroupMintCapacityFee(
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        stake,
-        title,
-        description,
-        stake,
-        balance
-      )
-    )
-  }
-
   public estimateProposeValidatorCountFee(title: string, description: string, stake: BN): BN {
     return this.estimateTxFee(
       this.api.tx.proposalsCodex.createSetValidatorCountProposal(stake, title, description, stake, stake)
@@ -659,7 +641,7 @@ export class ApiWrapper {
   }
 
   // TODO consider using configurable genesis instead
-  public sudoStartAnnouncingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
+  public sudoStartAnnouncingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageAnnouncing(endsAtBlock)),
       sudo,
@@ -667,7 +649,7 @@ export class ApiWrapper {
     )
   }
 
-  public sudoStartVotingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
+  public sudoStartVotingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageVoting(endsAtBlock)),
       sudo,
@@ -675,7 +657,7 @@ export class ApiWrapper {
     )
   }
 
-  public sudoStartRevealingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
+  public sudoStartRevealingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageRevealing(endsAtBlock)),
       sudo,
@@ -770,27 +752,6 @@ export class ApiWrapper {
     )
   }
 
-  public async proposeContentWorkingGroupMintCapacity(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN
-  ): Promise<void> {
-    const memberId: MemberId = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      (this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        balance
-      ) as unknown) as SubmittableExtrinsic<'promise'>,
-      account,
-      false
-    )
-  }
-
   public async proposeValidatorCount(
     account: KeyringPair,
     title: string,
@@ -907,6 +868,10 @@ export class ApiWrapper {
     return this.api.createType('Moment', this.api.consts.babe.expectedBlockTime)
   }
 
+  public durationInMsFromBlocks(durationInBlocks: number) {
+    return this.getBlockDuration().muln(durationInBlocks).toNumber()
+  }
+
   public expectProposalCreated(): Promise<ProposalId> {
     return new Promise(async (resolve) => {
       const unsubscribe = await this.api.query.system.events<Vec<EventRecord>>((events) => {

+ 0 - 0
tests/network-tests/src/services/dbService.ts → tests/network-tests/src/DbService.ts


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


+ 8 - 8
tests/network-tests/src/fixtures/councilElectionHappyCase.ts

@@ -1,13 +1,13 @@
-import { Fixture } from './interfaces/fixture'
+import { Fixture } from '../IFixture'
 import { BuyMembershipHappyCaseFixture } from './membershipModule'
 import { ElectCouncilFixture } from './councilElectionModule'
-import { ApiWrapper } from '../utils/apiWrapper'
+import { Api } from '../Api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 
 export class CouncilElectionHappyCaseFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private sudo: KeyringPair
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
@@ -17,7 +17,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
   private lesserStake: BN
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     sudo: KeyringPair,
     membersKeyPairs: KeyringPair[],
     councilKeyPairs: KeyringPair[],
@@ -26,7 +26,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
     greaterStake: BN,
     lesserStake: BN
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.sudo = sudo
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
@@ -38,7 +38,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     const firstMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-      this.apiWrapper,
+      this.api,
       this.sudo,
       this.membersKeyPairs,
       this.paidTerms
@@ -46,7 +46,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
     await firstMemberSetFixture.runner(false)
 
     const secondMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-      this.apiWrapper,
+      this.api,
       this.sudo,
       this.councilKeyPairs,
       this.paidTerms
@@ -54,7 +54,7 @@ export class CouncilElectionHappyCaseFixture implements Fixture {
     await secondMemberSetFixture.runner(false)
 
     const electCouncilFixture: ElectCouncilFixture = new ElectCouncilFixture(
-      this.apiWrapper,
+      this.api,
       this.membersKeyPairs,
       this.councilKeyPairs,
       this.k,

+ 27 - 31
tests/network-tests/src/fixtures/councilElectionModule.ts

@@ -1,14 +1,14 @@
-import { ApiWrapper } from '../utils/apiWrapper'
+import { Api } from '../Api'
 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 { Fixture } from './interfaces/fixture'
+import { Utils } from '../utils'
+import { Fixture } from '../IFixture'
 
 export class ElectCouncilFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
   private k: number
@@ -17,7 +17,7 @@ export class ElectCouncilFixture implements Fixture {
   private lesserStake: BN
 
   public constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     councilKeyPairs: KeyringPair[],
     k: number,
@@ -25,7 +25,7 @@ export class ElectCouncilFixture implements Fixture {
     greaterStake: BN,
     lesserStake: BN
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
     this.k = k
@@ -35,9 +35,9 @@ export class ElectCouncilFixture implements Fixture {
   }
 
   public async runner(expectFailure: boolean): Promise<void> {
-    let now = await this.apiWrapper.getBestBlock()
-    const applyForCouncilFee: BN = this.apiWrapper.estimateApplyForCouncilFee(this.greaterStake)
-    const voteForCouncilFee: BN = this.apiWrapper.estimateVoteForCouncilFee(
+    let now = await this.api.getBestBlock()
+    const applyForCouncilFee: BN = this.api.estimateApplyForCouncilFee(this.greaterStake)
+    const voteForCouncilFee: BN = this.api.estimateVoteForCouncilFee(
       this.sudo.address,
       this.sudo.address,
       this.greaterStake
@@ -46,25 +46,21 @@ export class ElectCouncilFixture implements Fixture {
     this.membersKeyPairs.forEach(() => {
       salt.push(''.concat(uuid().replace(/-/g, '')))
     })
-    const revealVoteFee: BN = this.apiWrapper.estimateRevealVoteFee(this.sudo.address, salt[0])
+    const revealVoteFee: BN = this.api.estimateRevealVoteFee(this.sudo.address, salt[0])
 
     // Topping the balances
-    await this.apiWrapper.transferBalanceToAccounts(
-      this.sudo,
-      this.councilKeyPairs,
-      applyForCouncilFee.add(this.greaterStake)
-    )
-    await this.apiWrapper.transferBalanceToAccounts(
+    await this.api.transferBalanceToAccounts(this.sudo, this.councilKeyPairs, applyForCouncilFee.add(this.greaterStake))
+    await this.api.transferBalanceToAccounts(
       this.sudo,
       this.membersKeyPairs,
       voteForCouncilFee.add(revealVoteFee).add(this.greaterStake)
     )
 
     // First K members stake more
-    await this.apiWrapper.sudoStartAnnouncingPerion(this.sudo, now.addn(100))
-    await this.apiWrapper.batchApplyForCouncilElection(this.councilKeyPairs.slice(0, this.k), this.greaterStake)
+    await this.api.sudoStartAnnouncingPeriod(this.sudo, now.addn(100))
+    await this.api.batchApplyForCouncilElection(this.councilKeyPairs.slice(0, this.k), this.greaterStake)
     this.councilKeyPairs.slice(0, this.k).forEach((keyPair) =>
-      this.apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
+      this.api.getCouncilElectionStake(keyPair.address).then((stake) => {
         assert(
           stake.eq(this.greaterStake),
           `${keyPair.address} not applied correctly for council election with stake ${stake} versus expected ${this.greaterStake}`
@@ -73,9 +69,9 @@ export class ElectCouncilFixture implements Fixture {
     )
 
     // Last members stake less
-    await this.apiWrapper.batchApplyForCouncilElection(this.councilKeyPairs.slice(this.k), this.lesserStake)
+    await this.api.batchApplyForCouncilElection(this.councilKeyPairs.slice(this.k), this.lesserStake)
     this.councilKeyPairs.slice(this.k).forEach((keyPair) =>
-      this.apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
+      this.api.getCouncilElectionStake(keyPair.address).then((stake) => {
         assert(
           stake.eq(this.lesserStake),
           `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${this.lesserStake}`
@@ -84,14 +80,14 @@ export class ElectCouncilFixture implements Fixture {
     )
 
     // Voting
-    await this.apiWrapper.sudoStartVotingPerion(this.sudo, now.addn(100))
-    await this.apiWrapper.batchVoteForCouncilMember(
+    await this.api.sudoStartVotingPeriod(this.sudo, now.addn(100))
+    await this.api.batchVoteForCouncilMember(
       this.membersKeyPairs.slice(0, this.k),
       this.councilKeyPairs.slice(0, this.k),
       salt.slice(0, this.k),
       this.lesserStake
     )
-    await this.apiWrapper.batchVoteForCouncilMember(
+    await this.api.batchVoteForCouncilMember(
       this.membersKeyPairs.slice(this.k),
       this.councilKeyPairs.slice(this.k),
       salt.slice(this.k),
@@ -99,24 +95,24 @@ export class ElectCouncilFixture implements Fixture {
     )
 
     // Revealing
-    await this.apiWrapper.sudoStartRevealingPerion(this.sudo, now.addn(100))
-    await this.apiWrapper.batchRevealVote(
+    await this.api.sudoStartRevealingPeriod(this.sudo, now.addn(100))
+    await this.api.batchRevealVote(
       this.membersKeyPairs.slice(0, this.k),
       this.councilKeyPairs.slice(0, this.k),
       salt.slice(0, this.k)
     )
-    await this.apiWrapper.batchRevealVote(
+    await this.api.batchRevealVote(
       this.membersKeyPairs.slice(this.k),
       this.councilKeyPairs.slice(this.k),
       salt.slice(this.k)
     )
-    now = await this.apiWrapper.getBestBlock()
+    now = await this.api.getBestBlock()
 
     // Resolving election
     // 3 is to ensure the revealing block is in future
-    await this.apiWrapper.sudoStartRevealingPerion(this.sudo, now.addn(3))
-    await Utils.wait(this.apiWrapper.getBlockDuration().muln(2.5).toNumber())
-    const seats: Seat[] = await this.apiWrapper.getCouncil()
+    await this.api.sudoStartRevealingPeriod(this.sudo, now.addn(3))
+    await Utils.wait(this.api.getBlockDuration().muln(2.5).toNumber())
+    const seats: Seat[] = await this.api.getCouncil()
 
     // Preparing collections to increase assertion readability
     const councilAddresses: string[] = this.councilKeyPairs.map((keyPair) => keyPair.address)

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

@@ -1,4 +1,4 @@
-import { Fixture } from './interfaces/fixture'
+import { Fixture } from '../IFixture'
 import {
   AddLeaderOpeningFixture,
   ApplyForOpeningFixture,
@@ -6,14 +6,14 @@ import {
   FillLeaderOpeningFixture,
 } from './workingGroupModule'
 import { BuyMembershipHappyCaseFixture } from './membershipModule'
-import { ApiWrapper, WorkingGroups } from '../utils/apiWrapper'
+import { Api, WorkingGroups } from '../Api'
 import { OpeningId } from '@joystream/types/hiring'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 
 export class LeaderHiringHappyCaseFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private sudo: KeyringPair
   private nKeyPairs: KeyringPair[]
   private leadKeyPair: KeyringPair[]
@@ -27,7 +27,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
   private workingGroup: WorkingGroups
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     sudo: KeyringPair,
     nKeyPairs: KeyringPair[],
     leadKeyPair: KeyringPair[],
@@ -40,7 +40,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
     payoutAmount: BN,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.sudo = sudo
     this.nKeyPairs = nKeyPairs
     this.leadKeyPair = leadKeyPair
@@ -56,7 +56,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     const happyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-      this.apiWrapper,
+      this.api,
       this.sudo,
       this.nKeyPairs,
       this.paidTerms
@@ -65,7 +65,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
     await happyCaseFixture.runner(false)
 
     const leaderHappyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-      this.apiWrapper,
+      this.api,
       this.sudo,
       this.leadKeyPair,
       this.paidTerms
@@ -74,7 +74,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
     await leaderHappyCaseFixture.runner(false)
 
     const addLeaderOpeningFixture: AddLeaderOpeningFixture = new AddLeaderOpeningFixture(
-      this.apiWrapper,
+      this.api,
       this.nKeyPairs,
       this.sudo,
       this.applicationStake,
@@ -89,7 +89,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
     // Apply for lead opening
     await (async () => {
       applyForLeaderOpeningFixture = new ApplyForOpeningFixture(
-        this.apiWrapper,
+        this.api,
         this.leadKeyPair,
         this.sudo,
         this.applicationStake,
@@ -104,7 +104,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
     // Begin lead application review
     await (async () => {
       beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
-        this.apiWrapper,
+        this.api,
         this.sudo,
         addLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
         this.workingGroup
@@ -116,7 +116,7 @@ export class LeaderHiringHappyCaseFixture implements Fixture {
     // Fill lead opening
     await (async () => {
       fillLeaderOpeningFixture = new FillLeaderOpeningFixture(
-        this.apiWrapper,
+        this.api,
         this.leadKeyPair,
         this.sudo,
         addLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,

+ 20 - 24
tests/network-tests/src/fixtures/membershipModule.ts

@@ -1,18 +1,18 @@
-import { ApiWrapper } from '../utils/apiWrapper'
+import { Api } from '../Api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'
-import { Fixture } from './interfaces/fixture'
+import { Fixture } from '../IFixture'
 import { PaidTermId } from '@joystream/types/members'
 
 export class BuyMembershipHappyCaseFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private treasury: KeyringPair
   private keyPairs: KeyringPair[]
   private paidTerms: PaidTermId
 
-  public constructor(apiWrapper: ApiWrapper, treasury: KeyringPair, keyPairs: KeyringPair[], paidTerms: PaidTermId) {
-    this.apiWrapper = apiWrapper
+  public constructor(api: Api, treasury: KeyringPair, keyPairs: KeyringPair[], paidTerms: PaidTermId) {
+    this.api = api
     this.treasury = treasury
     this.keyPairs = keyPairs
     this.paidTerms = paidTerms
@@ -20,13 +20,13 @@ export class BuyMembershipHappyCaseFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const membershipFee: BN = await this.apiWrapper.getMembershipFee(this.paidTerms)
-    const membershipTransactionFee: BN = this.apiWrapper.estimateBuyMembershipFee(
+    const membershipFee: BN = await this.api.getMembershipFee(this.paidTerms)
+    const membershipTransactionFee: BN = this.api.estimateBuyMembershipFee(
       this.treasury,
       this.paidTerms,
       'member_name_which_is_longer_than_expected'
     )
-    await this.apiWrapper.transferBalanceToAccounts(
+    await this.api.transferBalanceToAccounts(
       this.treasury,
       this.keyPairs,
       membershipTransactionFee.add(new BN(membershipFee))
@@ -35,17 +35,13 @@ export class BuyMembershipHappyCaseFixture implements Fixture {
     // Buying membership
     await Promise.all(
       this.keyPairs.map(async (keyPair, index) => {
-        await this.apiWrapper.buyMembership(
-          keyPair,
-          this.paidTerms,
-          `new_member_${index}${keyPair.address.substring(0, 8)}`
-        )
+        await this.api.buyMembership(keyPair, this.paidTerms, `new_member_${index}${keyPair.address.substring(0, 8)}`)
       })
     )
 
     // Assertions
     this.keyPairs.forEach((keyPair) =>
-      this.apiWrapper
+      this.api
         .getMemberIds(keyPair.address)
         .then((membership) => assert(membership.length > 0, `Account ${keyPair.address} is not a member`))
     )
@@ -56,13 +52,13 @@ export class BuyMembershipHappyCaseFixture implements Fixture {
 }
 
 export class BuyMembershipWithInsufficienFundsFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private treasury: KeyringPair
   private aKeyPair: KeyringPair
   private paidTerms: PaidTermId
 
-  public constructor(apiWrapper: ApiWrapper, treasury: KeyringPair, aKeyPair: KeyringPair, paidTerms: PaidTermId) {
-    this.apiWrapper = apiWrapper
+  public constructor(api: Api, treasury: KeyringPair, aKeyPair: KeyringPair, paidTerms: PaidTermId) {
+    this.api = api
     this.treasury = treasury
     this.aKeyPair = aKeyPair
     this.paidTerms = paidTerms
@@ -70,21 +66,21 @@ export class BuyMembershipWithInsufficienFundsFixture implements Fixture {
 
   public async runner(expectFailure: boolean) {
     // Assertions
-    this.apiWrapper
+    this.api
       .getMemberIds(this.aKeyPair.address)
       .then((membership) => assert(membership.length === 0, 'Account A is a member'))
 
     // Fee estimation and transfer
-    const membershipFee: BN = await this.apiWrapper.getMembershipFee(this.paidTerms)
-    const membershipTransactionFee: BN = this.apiWrapper.estimateBuyMembershipFee(
+    const membershipFee: BN = await this.api.getMembershipFee(this.paidTerms)
+    const membershipTransactionFee: BN = this.api.estimateBuyMembershipFee(
       this.treasury,
       this.paidTerms,
       'member_name_which_is_longer_than_expected'
     )
-    await this.apiWrapper.transferBalance(this.treasury, this.aKeyPair.address, membershipTransactionFee)
+    await this.api.transferBalance(this.treasury, this.aKeyPair.address, membershipTransactionFee)
 
     // Balance assertion
-    await this.apiWrapper
+    await this.api
       .getBalance(this.aKeyPair.address)
       .then((balance) =>
         assert(
@@ -94,7 +90,7 @@ export class BuyMembershipWithInsufficienFundsFixture implements Fixture {
       )
 
     // Buying memebership
-    await this.apiWrapper.buyMembership(
+    await this.api.buyMembership(
       this.aKeyPair,
       this.paidTerms,
       `late_member_${this.aKeyPair.address.substring(0, 8)}`,
@@ -102,7 +98,7 @@ export class BuyMembershipWithInsufficienFundsFixture implements Fixture {
     )
 
     // Assertions
-    this.apiWrapper
+    this.api
       .getMemberIds(this.aKeyPair.address)
       .then((membership) => assert(membership.length === 0, 'Account A is a member'))
     if (expectFailure) {

+ 150 - 212
tests/network-tests/src/fixtures/proposalsModule.ts

@@ -1,16 +1,16 @@
 import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper, WorkingGroups } from '../utils/apiWrapper'
+import { Api, WorkingGroups } from '../Api'
 import { v4 as uuid } from 'uuid'
 import BN from 'bn.js'
 import { ProposalId } from '@joystream/types/proposals'
-import { Fixture } from './interfaces/fixture'
+import { Fixture } from '../IFixture'
 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'
 
 export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private applicationStake: BN
@@ -20,14 +20,14 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     applicationStake: BN,
     roleStake: BN,
     workingGroup: string
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.treasury = treasury
     this.applicationStake = applicationStake
@@ -46,16 +46,12 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(100000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeCreateWorkingGroupLeaderOpeningFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeCreateWorkingGroupLeaderOpeningFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeCreateWorkingGroupLeaderOpening({
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeCreateWorkingGroupLeaderOpening({
       account: this.membersKeyPairs[0],
       title: proposalTitle,
       description: description,
@@ -89,7 +85,7 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
 }
 
 export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private openingId: OpeningId
@@ -98,13 +94,13 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     openingId: OpeningId,
     workingGroup: string
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.treasury = treasury
     this.openingId = openingId
@@ -122,16 +118,12 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(25000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeBeginWorkingGroupLeaderApplicationReviewFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeBeginWorkingGroupLeaderApplicationReviewFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeBeginWorkingGroupLeaderApplicationReview(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeBeginWorkingGroupLeaderApplicationReview(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -147,7 +139,7 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
 }
 
 export class FillLeaderOpeningProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private applicantRoleAccountAddress: string
   private treasury: KeyringPair
@@ -160,7 +152,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     applicantRoleAccountAddress: string,
     treasury: KeyringPair,
@@ -170,7 +162,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
     openingId: OpeningId,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.applicantRoleAccountAddress = applicantRoleAccountAddress
     this.treasury = treasury
@@ -189,25 +181,21 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
     // Setup
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing fill opening proposal ' + uuid().substring(0, 8)
-    const workingGroupString: string = this.apiWrapper.getWorkingGroupString(this.workingGroup)
+    const workingGroupString: string = this.api.getWorkingGroupString(this.workingGroup)
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeFillLeaderOpeningFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeFillLeaderOpeningFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
     const applicationId: ApplicationId = (
-      await this.apiWrapper.getActiveApplicationsIdsByRoleAccount(this.applicantRoleAccountAddress, this.workingGroup)
+      await this.api.getActiveApplicationsIdsByRoleAccount(this.applicantRoleAccountAddress, this.workingGroup)
     )[0]
-    const now: BN = await this.apiWrapper.getBestBlock()
+    const now: BN = await this.api.getBestBlock()
 
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeFillLeaderOpening({
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeFillLeaderOpening({
       account: this.membersKeyPairs[0],
       title: proposalTitle,
       description: description,
@@ -227,7 +215,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
 }
 
 export class TerminateLeaderRoleProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private leaderRoleAccountAddress: string
   private treasury: KeyringPair
@@ -237,14 +225,14 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     leaderRoleAccountAddress: string,
     treasury: KeyringPair,
     slash: boolean,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.leaderRoleAccountAddress = leaderRoleAccountAddress
     this.treasury = treasury
@@ -261,24 +249,17 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing begin working group lead application review proposal ' + uuid().substring(0, 8)
     const rationale: string = 'Testing leader termination ' + uuid().substring(0, 8)
-    const workingGroupString: string = this.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
-      this.leaderRoleAccountAddress,
-      this.workingGroup
-    )
+    const workingGroupString: string = this.api.getWorkingGroupString(this.workingGroup)
+    const workerId: WorkerId = await this.api.getWorkerIdByRoleAccount(this.leaderRoleAccountAddress, this.workingGroup)
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(100000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeTerminateLeaderRoleFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeTerminateLeaderRoleFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeTerminateLeaderRole(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeTerminateLeaderRole(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -296,7 +277,7 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
 }
 
 export class SetLeaderRewardProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private payoutAmount: BN
@@ -305,13 +286,13 @@ export class SetLeaderRewardProposalFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     payoutAmount: BN,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.treasury = treasury
     this.payoutAmount = payoutAmount
@@ -326,21 +307,17 @@ export class SetLeaderRewardProposalFixture implements Fixture {
     // Setup
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing set leader reward proposal ' + uuid().substring(0, 8)
-    const workingGroupString: string = this.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
+    const workingGroupString: string = this.api.getWorkingGroupString(this.workingGroup)
+    const workerId: WorkerId = (await this.api.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeLeaderRewardFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeLeaderRewardFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeLeaderReward(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeLeaderReward(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -357,7 +334,7 @@ export class SetLeaderRewardProposalFixture implements Fixture {
 }
 
 export class DecreaseLeaderStakeProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private stakeDecrement: BN
@@ -366,13 +343,13 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     stakeDecrement: BN,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.treasury = treasury
     this.stakeDecrement = stakeDecrement
@@ -387,21 +364,17 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
     // Setup
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing decrease leader stake proposal ' + uuid().substring(0, 8)
-    const workingGroupString: string = this.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
+    const workingGroupString: string = this.api.getWorkingGroupString(this.workingGroup)
+    const workerId: WorkerId = (await this.api.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeDecreaseLeaderStakeFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeDecreaseLeaderStakeFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeDecreaseLeaderStake(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeDecreaseLeaderStake(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -418,7 +391,7 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
 }
 
 export class SlashLeaderProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private slashAmount: BN
@@ -427,13 +400,13 @@ export class SlashLeaderProposalFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     slashAmount: BN,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.treasury = treasury
     this.slashAmount = slashAmount
@@ -448,21 +421,17 @@ export class SlashLeaderProposalFixture implements Fixture {
     // Setup
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing slash leader stake proposal ' + uuid().substring(0, 8)
-    const workingGroupString: string = this.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
+    const workingGroupString: string = this.api.getWorkingGroupString(this.workingGroup)
+    const workerId: WorkerId = (await this.api.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeSlashLeaderStakeFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeSlashLeaderStakeFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeSlashLeaderStake(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeSlashLeaderStake(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -479,7 +448,7 @@ export class SlashLeaderProposalFixture implements Fixture {
 }
 
 export class WorkingGroupMintCapacityProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private mintCapacity: BN
@@ -488,13 +457,13 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
   private result: ProposalId | undefined
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     mintCapacity: BN,
     workingGroup: WorkingGroups
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.treasury = treasury
     this.mintCapacity = mintCapacity
@@ -509,20 +478,16 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
     // Setup
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing working group mint capacity proposal ' + uuid().substring(0, 8)
-    const workingGroupString: string = this.apiWrapper.getWorkingGroupString(this.workingGroup)
+    const workingGroupString: string = this.api.getWorkingGroupString(this.workingGroup)
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeWorkingGroupMintCapacityFee()
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    const proposalFee: BN = this.api.estimateProposeWorkingGroupMintCapacityFee()
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeWorkingGroupMintCapacity(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeWorkingGroupMintCapacity(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -538,18 +503,13 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
 }
 
 export class ElectionParametersProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
   private treasury: KeyringPair
 
-  constructor(
-    apiWrapper: ApiWrapper,
-    membersKeyPairs: KeyringPair[],
-    councilKeyPairs: KeyringPair[],
-    treasury: KeyringPair
-  ) {
-    this.apiWrapper = apiWrapper
+  constructor(api: Api, membersKeyPairs: KeyringPair[], councilKeyPairs: KeyringPair[], treasury: KeyringPair) {
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
     this.treasury = treasury
@@ -559,20 +519,20 @@ export class ElectionParametersProposalFixture implements Fixture {
     // 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)
+    const runtimeVoteFee: BN = this.api.estimateVoteForProposalFee()
+    await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
     const announcingPeriod: BN = new BN(28800)
     const votingPeriod: BN = new BN(14400)
     const revealingPeriod: BN = new BN(14400)
-    const councilSize: BN = await this.apiWrapper.getCouncilSize()
-    const candidacyLimit: BN = await this.apiWrapper.getCandidacyLimit()
+    const councilSize: BN = await this.api.getCouncilSize()
+    const candidacyLimit: BN = await this.api.getCandidacyLimit()
     const newTermDuration: BN = new BN(144000)
-    const minCouncilStake: BN = await this.apiWrapper.getMinCouncilStake()
-    const minVotingStake: BN = await this.apiWrapper.getMinVotingStake()
+    const minCouncilStake: BN = await this.api.getMinCouncilStake()
+    const minVotingStake: BN = await this.api.getMinVotingStake()
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(200000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeElectionParametersFee(
+    const proposalFee: BN = this.api.estimateProposeElectionParametersFee(
       description,
       description,
       proposalStake,
@@ -585,11 +545,7 @@ export class ElectionParametersProposalFixture implements Fixture {
       minCouncilStake,
       minVotingStake
     )
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
     const proposedAnnouncingPeriod: BN = announcingPeriod.subn(1)
@@ -600,8 +556,8 @@ export class ElectionParametersProposalFixture implements Fixture {
     const proposedNewTermDuration: BN = newTermDuration.addn(1)
     const proposedMinCouncilStake: BN = minCouncilStake.addn(1)
     const proposedMinVotingStake: BN = minVotingStake.addn(1)
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeElectionParameters(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeElectionParameters(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -618,19 +574,19 @@ export class ElectionParametersProposalFixture implements Fixture {
     const proposalNumber: ProposalId = await proposalPromise
 
     // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    const proposalExecutionPromise: Promise<void> = this.api.expectProposalFinalized()
+    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
     await proposalExecutionPromise
 
     // Assertions
-    const newAnnouncingPeriod: BN = await this.apiWrapper.getAnnouncingPeriod()
-    const newVotingPeriod: BN = await this.apiWrapper.getVotingPeriod()
-    const newRevealingPeriod: BN = await this.apiWrapper.getRevealingPeriod()
-    const newCouncilSize: BN = await this.apiWrapper.getCouncilSize()
-    const newCandidacyLimit: BN = await this.apiWrapper.getCandidacyLimit()
-    const newNewTermDuration: BN = await this.apiWrapper.getNewTermDuration()
-    const newMinCouncilStake: BN = await this.apiWrapper.getMinCouncilStake()
-    const newMinVotingStake: BN = await this.apiWrapper.getMinVotingStake()
+    const newAnnouncingPeriod: BN = await this.api.getAnnouncingPeriod()
+    const newVotingPeriod: BN = await this.api.getVotingPeriod()
+    const newRevealingPeriod: BN = await this.api.getRevealingPeriod()
+    const newCouncilSize: BN = await this.api.getCouncilSize()
+    const newCandidacyLimit: BN = await this.api.getCandidacyLimit()
+    const newNewTermDuration: BN = await this.api.getNewTermDuration()
+    const newMinCouncilStake: BN = await this.api.getMinCouncilStake()
+    const newMinVotingStake: BN = await this.api.getMinVotingStake()
     assert(
       proposedAnnouncingPeriod.eq(newAnnouncingPeriod),
       `Announcing period has unexpected value ${newAnnouncingPeriod}, expected ${proposedAnnouncingPeriod}`
@@ -670,7 +626,7 @@ export class ElectionParametersProposalFixture implements Fixture {
 }
 
 export class SpendingProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
   private sudo: KeyringPair
@@ -678,14 +634,14 @@ export class SpendingProposalFixture implements Fixture {
   private mintCapacity: BN
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     councilKeyPairs: KeyringPair[],
     sudo: KeyringPair,
     spendingBalance: BN,
     mintCapacity: BN
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
     this.sudo = sudo
@@ -696,28 +652,24 @@ export class SpendingProposalFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     // Setup
     const description = 'spending proposal which is used for API network testing with some mock data'
-    const runtimeVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()
+    const runtimeVoteFee: BN = this.api.estimateVoteForProposalFee()
 
     // Topping the balances
     const proposalStake: BN = new BN(25000)
-    const runtimeProposalFee: BN = this.apiWrapper.estimateProposeSpendingFee(
+    const runtimeProposalFee: BN = this.api.estimateProposeSpendingFee(
       description,
       description,
       proposalStake,
       this.spendingBalance,
       this.sudo.address
     )
-    await this.apiWrapper.transferBalance(
-      this.sudo,
-      this.membersKeyPairs[0].address,
-      runtimeProposalFee.add(proposalStake)
-    )
-    await this.apiWrapper.transferBalanceToAccounts(this.sudo, this.councilKeyPairs, runtimeVoteFee)
-    await this.apiWrapper.sudoSetCouncilMintCapacity(this.sudo, this.mintCapacity)
+    await this.api.transferBalance(this.sudo, this.membersKeyPairs[0].address, runtimeProposalFee.add(proposalStake))
+    await this.api.transferBalanceToAccounts(this.sudo, this.councilKeyPairs, runtimeVoteFee)
+    await this.api.sudoSetCouncilMintCapacity(this.sudo, this.mintCapacity)
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeSpending(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeSpending(
       this.membersKeyPairs[0],
       'testing spending' + uuid().substring(0, 8),
       'spending to test proposal functionality' + uuid().substring(0, 8),
@@ -728,11 +680,11 @@ export class SpendingProposalFixture implements Fixture {
     const proposalNumber: ProposalId = await proposalPromise
 
     // Approving spending proposal
-    const balanceBeforeMinting: BN = await this.apiWrapper.getBalance(this.sudo.address)
-    const spendingPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    const balanceBeforeMinting: BN = await this.api.getBalance(this.sudo.address)
+    const spendingPromise: Promise<void> = this.api.expectProposalFinalized()
+    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
     await spendingPromise
-    const balanceAfterMinting: BN = await this.apiWrapper.getBalance(this.sudo.address)
+    const balanceAfterMinting: BN = await this.api.getBalance(this.sudo.address)
     assert(
       balanceAfterMinting.sub(balanceBeforeMinting).eq(this.spendingBalance),
       `member ${
@@ -746,18 +698,13 @@ export class SpendingProposalFixture implements Fixture {
 }
 
 export class TextProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
   private treasury: KeyringPair
 
-  constructor(
-    apiWrapper: ApiWrapper,
-    membersKeyPairs: KeyringPair[],
-    councilKeyPairs: KeyringPair[],
-    treasury: KeyringPair
-  ) {
-    this.apiWrapper = apiWrapper
+  constructor(api: Api, membersKeyPairs: KeyringPair[], councilKeyPairs: KeyringPair[], treasury: KeyringPair) {
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
     this.treasury = treasury
@@ -768,31 +715,31 @@ export class TextProposalFixture implements Fixture {
     const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
     const description: string = 'Testing text proposal ' + uuid().substring(0, 8)
     const proposalText: string = 'Text of the testing proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()
-    await this.apiWrapper.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
+    const runtimeVoteFee: BN = this.api.estimateVoteForProposalFee()
+    await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(25000)
-    const runtimeProposalFee: BN = this.apiWrapper.estimateProposeTextFee(
+    const runtimeProposalFee: BN = this.api.estimateProposeTextFee(
       proposalStake,
       description,
       description,
       proposalText
     )
-    await this.apiWrapper.transferBalance(
+    await this.api.transferBalance(
       this.treasury,
       this.membersKeyPairs[0].address,
       runtimeProposalFee.add(proposalStake)
     )
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeText(this.membersKeyPairs[0], proposalStake, proposalTitle, description, proposalText)
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeText(this.membersKeyPairs[0], proposalStake, proposalTitle, description, proposalText)
     const proposalNumber: ProposalId = await proposalPromise
 
     // Approving text proposal
-    const textProposalPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    const textProposalPromise: Promise<void> = this.api.expectProposalFinalized()
+    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
     await textProposalPromise
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
@@ -801,20 +748,20 @@ export class TextProposalFixture implements Fixture {
 }
 
 export class ValidatorCountProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private validatorCountIncrement: BN
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     councilKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     validatorCountIncrement: BN
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
     this.treasury = treasury
@@ -825,23 +772,19 @@ export class ValidatorCountProposalFixture implements Fixture {
     // 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)
+    const runtimeVoteFee: BN = this.api.estimateVoteForProposalFee()
+    await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(100000)
-    const proposalFee: BN = this.apiWrapper.estimateProposeValidatorCountFee(description, description, proposalStake)
-    await this.apiWrapper.transferBalance(
-      this.treasury,
-      this.membersKeyPairs[0].address,
-      proposalFee.add(proposalStake)
-    )
-    const validatorCount: BN = await this.apiWrapper.getValidatorCount()
+    const proposalFee: BN = this.api.estimateProposeValidatorCountFee(description, description, proposalStake)
+    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
+    const validatorCount: BN = await this.api.getValidatorCount()
 
     // Proposal creation
     const proposedValidatorCount: BN = validatorCount.add(this.validatorCountIncrement)
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeValidatorCount(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeValidatorCount(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -851,10 +794,10 @@ export class ValidatorCountProposalFixture implements Fixture {
     const proposalNumber: ProposalId = await proposalPromise
 
     // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    const proposalExecutionPromise: Promise<void> = this.api.expectProposalFinalized()
+    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
     await proposalExecutionPromise
-    const newValidatorCount: BN = await this.apiWrapper.getValidatorCount()
+    const newValidatorCount: BN = await this.api.getValidatorCount()
     assert(
       proposedValidatorCount.eq(newValidatorCount),
       `Validator count has unexpeccted value ${newValidatorCount}, expected ${proposedValidatorCount}`
@@ -866,20 +809,20 @@ export class ValidatorCountProposalFixture implements Fixture {
 }
 
 export class UpdateRuntimeFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private membersKeyPairs: KeyringPair[]
   private councilKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private runtimePath: string
 
   constructor(
-    apiWrapper: ApiWrapper,
+    api: Api,
     membersKeyPairs: KeyringPair[],
     councilKeyPairs: KeyringPair[],
     treasury: KeyringPair,
     runtimePath: string
   ) {
-    this.apiWrapper = apiWrapper
+    this.api = api
     this.membersKeyPairs = membersKeyPairs
     this.councilKeyPairs = councilKeyPairs
     this.treasury = treasury
@@ -890,26 +833,26 @@ export class UpdateRuntimeFixture implements Fixture {
     // Setup
     const runtime: string = Utils.readRuntimeFromFile(this.runtimePath)
     const description = 'runtime upgrade proposal which is used for API network testing'
-    const runtimeVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()
+    const runtimeVoteFee: BN = this.api.estimateVoteForProposalFee()
 
     // Topping the balances
     const proposalStake: BN = new BN(1000000)
-    const runtimeProposalFee: BN = this.apiWrapper.estimateProposeRuntimeUpgradeFee(
+    const runtimeProposalFee: BN = this.api.estimateProposeRuntimeUpgradeFee(
       proposalStake,
       description,
       description,
       runtime
     )
-    await this.apiWrapper.transferBalance(
+    await this.api.transferBalance(
       this.treasury,
       this.membersKeyPairs[0].address,
       runtimeProposalFee.add(proposalStake)
     )
-    await this.apiWrapper.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
+    await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
-    await this.apiWrapper.proposeRuntime(
+    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
+    await this.api.proposeRuntime(
       this.membersKeyPairs[0],
       proposalStake,
       'testing runtime' + uuid().substring(0, 8),
@@ -919,8 +862,8 @@ export class UpdateRuntimeFixture implements Fixture {
     const proposalNumber: ProposalId = await proposalPromise
 
     // Approving runtime update proposal
-    const runtimePromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    const runtimePromise: Promise<void> = this.api.expectProposalFinalized()
+    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
     await runtimePromise
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
@@ -929,30 +872,25 @@ export class UpdateRuntimeFixture implements Fixture {
 }
 
 export class VoteForProposalFixture implements Fixture {
-  private apiWrapper: ApiWrapper
+  private api: Api
   private councilKeyPairs: KeyringPair[]
   private treasury: KeyringPair
   private proposalNumber: ProposalId
 
-  constructor(
-    apiWrapper: ApiWrapper,
-    councilKeyPairs: KeyringPair[],
-    treasury: KeyringPair,
-    proposalNumber: ProposalId
-  ) {
-    this.apiWrapper = apiWrapper
+  constructor(api: Api, councilKeyPairs: KeyringPair[], treasury: KeyringPair, proposalNumber: ProposalId) {
+    this.api = api
     this.councilKeyPairs = councilKeyPairs
     this.treasury = treasury
     this.proposalNumber = proposalNumber
   }
 
   public async runner(expectFailure: boolean): Promise<void> {
-    const proposalVoteFee: BN = this.apiWrapper.estimateVoteForProposalFee()
-    await this.apiWrapper.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, proposalVoteFee)
+    const proposalVoteFee: BN = this.api.estimateVoteForProposalFee()
+    await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, proposalVoteFee)
 
     // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
-    await this.apiWrapper.batchApproveProposal(this.councilKeyPairs, this.proposalNumber)
+    const proposalExecutionPromise: Promise<void> = this.api.expectProposalFinalized()
+    await this.api.batchApproveProposal(this.councilKeyPairs, this.proposalNumber)
     await proposalExecutionPromise
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')

File diff suppressed because it is too large
+ 171 - 215
tests/network-tests/src/fixtures/workingGroupModule.ts


+ 7 - 7
tests/network-tests/src/flows/councilSetup.ts

@@ -2,14 +2,14 @@ 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 { DbService } from '../DbService'
 
-import { ApiWrapper } from '../utils/apiWrapper'
-import { Utils } from '../utils/utils'
+import { Api } from '../Api'
+import { Utils } from '../utils'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 
 // Electing council scenario
-export default async function councilSetup(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function councilSetup(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   if (db.hasCouncil()) {
@@ -21,16 +21,16 @@ export default async function councilSetup(apiWrapper: ApiWrapper, env: NodeJS.P
   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 paidTerms: PaidTermId = api.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)
+  // setTestTimeout(api, durationInBlocks)
 
   const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-    apiWrapper,
+    api,
     sudo,
     m1KeyPairs,
     m2KeyPairs,

+ 9 - 9
tests/network-tests/src/flows/leaderSetup.ts

@@ -1,17 +1,17 @@
-import { ApiWrapper, WorkingGroups } from '../utils/apiWrapper'
+import { Api, WorkingGroups } from '../Api'
 import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
-import { Utils } from '../utils/utils'
+import { Utils } from '../utils'
 import { PaidTermId } from '@joystream/types/members'
-import { DbService } from '../services/dbService'
+import { DbService } from '../DbService'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 
 // Worker application happy case scenario
-export default async function leaderSetup(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function leaderSetup(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     return
   }
 
@@ -20,7 +20,7 @@ export default async function leaderSetup(apiWrapper: ApiWrapper, env: NodeJS.Pr
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -29,10 +29,10 @@ export default async function leaderSetup(apiWrapper: ApiWrapper, env: NodeJS.Pr
   const openingActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 48
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
   const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-    apiWrapper,
+    api,
     sudo,
     nKeyPairs,
     leadKeyPair,
@@ -48,5 +48,5 @@ export default async function leaderSetup(apiWrapper: ApiWrapper, env: NodeJS.Pr
   await leaderHiringHappyCaseFixture.runner(false)
 
   db.setMembers(nKeyPairs)
-  db.setLeader(leadKeyPair[0], apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+  db.setLeader(leadKeyPair[0], api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
 }

+ 11 - 15
tests/network-tests/src/flows/membership/creatingMemberships.ts

@@ -1,16 +1,19 @@
 import { KeyringPair } from '@polkadot/keyring/types'
 import { Keyring } from '@polkadot/api'
-import { ApiWrapper } from '../../utils/apiWrapper'
+import { Api } from '../../Api'
 import {
   BuyMembershipHappyCaseFixture,
   BuyMembershipWithInsufficienFundsFixture,
 } from '../../fixtures/membershipModule'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
+import Debugger from 'debug'
+
+const debug = Debugger('flow:memberships')
 
 // Membership creation scenario
-export default async function memberShipCreation(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv) {
+export default async function memberShipCreation(api: Api, env: NodeJS.ProcessEnv) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -18,22 +21,15 @@ export default async function memberShipCreation(apiWrapper: ApiWrapper, env: No
   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 paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
 
-  const happyCaseFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-    apiWrapper,
-    sudo,
-    nKeyPairs,
-    paidTerms
-  )
+  debug(`creating ${N} new members`)
+  const happyCaseFixture = new BuyMembershipHappyCaseFixture(api, sudo, nKeyPairs, paidTerms)
   // Buy membeship is accepted with sufficient funds
   await happyCaseFixture.runner(false)
 
   const insufficientFundsFixture: BuyMembershipWithInsufficienFundsFixture = new BuyMembershipWithInsufficienFundsFixture(
-    apiWrapper,
+    api,
     sudo,
     aKeyPair[0],
     paidTerms
@@ -41,7 +37,7 @@ export default async function memberShipCreation(apiWrapper: ApiWrapper, env: No
   // Account A can not buy the membership with insufficient funds
   await insufficientFundsFixture.runner(false)
 
-  const buyMembershipAfterAccountTopUp = new BuyMembershipHappyCaseFixture(apiWrapper, sudo, aKeyPair, paidTerms)
+  const buyMembershipAfterAccountTopUp = new BuyMembershipHappyCaseFixture(api, sudo, aKeyPair, paidTerms)
   // Account A was able to buy the membership with sufficient funds
   await buyMembershipAfterAccountTopUp.runner(false)
 }

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

@@ -1,19 +1,15 @@
 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 { Api } from '../../Api'
+import { Utils } from '../../utils'
 import { ElectionParametersProposalFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 
 // Election parameters proposal scenario
-export default async function electionParametersProposal(
-  apiWrapper: ApiWrapper,
-  env: NodeJS.ProcessEnv,
-  db: DbService
-) {
+export default async function electionParametersProposal(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -22,20 +18,20 @@ export default async function electionParametersProposal(
   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 paidTerms: PaidTermId = api.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)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -48,7 +44,7 @@ export default async function electionParametersProposal(
   }
 
   const electionParametersProposalFixture: ElectionParametersProposalFixture = new ElectionParametersProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     m2KeyPairs,
     sudo

+ 31 - 32
tests/network-tests/src/flows/proposals/manageLeaderRole.ts

@@ -1,8 +1,7 @@
 import { KeyringPair } from '@polkadot/keyring/types'
 import { Keyring } from '@polkadot/api'
 import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import {
   BeginWorkingGroupLeaderApplicationReviewFixture,
@@ -24,14 +23,14 @@ import {
   ExpectLeaderStakeDecreasedFixture,
   ExpectLeadOpeningAddedFixture,
 } from '../../fixtures/workingGroupModule'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../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 { DbService } from '../../DbService'
 import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
 
-export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -41,7 +40,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   let m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -53,16 +52,16 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   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)
+  // const durationInBlocks = 70
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -75,7 +74,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   }
 
   const leaderMembershipFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-    apiWrapper,
+    api,
     sudo,
     leadKeyPair,
     paidTerms
@@ -84,7 +83,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await leaderMembershipFixture.runner(false)
 
   const createWorkingGroupLeaderOpeningFixture: CreateWorkingGroupLeaderOpeningFixture = new CreateWorkingGroupLeaderOpeningFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     applicationStake,
@@ -95,11 +94,11 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await createWorkingGroupLeaderOpeningFixture.runner(false)
 
   let voteForCreateOpeningProposalFixture: VoteForProposalFixture
-  const expectLeadOpeningAddedFixture: ExpectLeadOpeningAddedFixture = new ExpectLeadOpeningAddedFixture(apiWrapper)
+  const expectLeadOpeningAddedFixture: ExpectLeadOpeningAddedFixture = new ExpectLeadOpeningAddedFixture(api)
   // Approve add opening proposal
   await (async () => {
     voteForCreateOpeningProposalFixture = new VoteForProposalFixture(
-      apiWrapper,
+      api,
       m2KeyPairs,
       sudo,
       createWorkingGroupLeaderOpeningFixture.getCreatedProposalId() as OpeningId
@@ -112,7 +111,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   // Apply for lead opening
   await (async () => {
     applyForLeaderOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       applicationStake,
@@ -124,7 +123,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   })()
 
   const beginWorkingGroupLeaderApplicationReviewFixture: BeginWorkingGroupLeaderApplicationReviewFixture = new BeginWorkingGroupLeaderApplicationReviewFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     expectLeadOpeningAddedFixture.getCreatedOpeningId() as OpeningId,
@@ -136,12 +135,12 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
 
   let voteForBeginReviewProposal: VoteForProposalFixture
   const expectBeganApplicationReviewFixture: ExpectBeganApplicationReviewFixture = new ExpectBeganApplicationReviewFixture(
-    apiWrapper
+    api
   )
   // Approve begin application review
   await (async () => {
     voteForBeginReviewProposal = new VoteForProposalFixture(
-      apiWrapper,
+      api,
       m2KeyPairs,
       sudo,
       beginWorkingGroupLeaderApplicationReviewFixture.getCreatedProposalId() as ProposalId
@@ -151,7 +150,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   })()
 
   const fillLeaderOpeningProposalFixture: FillLeaderOpeningProposalFixture = new FillLeaderOpeningProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     leadKeyPair[0].address,
     sudo,
@@ -165,13 +164,13 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await fillLeaderOpeningProposalFixture.runner(false)
 
   const voteForFillLeaderProposalFixture: VoteForProposalFixture = new VoteForProposalFixture(
-    apiWrapper,
+    api,
     m2KeyPairs,
     sudo,
     fillLeaderOpeningProposalFixture.getCreatedProposalId() as ProposalId
   )
   const expectLeaderSetFixture: ExpectLeaderSetFixture = new ExpectLeaderSetFixture(
-    apiWrapper,
+    api,
     leadKeyPair[0].address,
     WorkingGroups.StorageWorkingGroup
   )
@@ -180,7 +179,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await expectLeaderSetFixture.runner(false)
 
   const setLeaderRewardProposalFixture: SetLeaderRewardProposalFixture = new SetLeaderRewardProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     alteredPayoutAmount,
@@ -190,13 +189,13 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await setLeaderRewardProposalFixture.runner(false)
 
   const voteForeLeaderRewardFixture: VoteForProposalFixture = new VoteForProposalFixture(
-    apiWrapper,
+    api,
     m2KeyPairs,
     sudo,
     setLeaderRewardProposalFixture.getCreatedProposalId() as ProposalId
   )
   const expectLeaderRewardAmountUpdatedFixture: ExpectLeaderRewardAmountUpdatedFixture = new ExpectLeaderRewardAmountUpdatedFixture(
-    apiWrapper,
+    api,
     alteredPayoutAmount,
     WorkingGroups.StorageWorkingGroup
   )
@@ -205,7 +204,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await expectLeaderRewardAmountUpdatedFixture.runner(false)
 
   const decreaseLeaderStakeProposalFixture: DecreaseLeaderStakeProposalFixture = new DecreaseLeaderStakeProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     stakeDecrement,
@@ -221,14 +220,14 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   // Approve decreased leader stake
   await (async () => {
     voteForDecreaseStakeProposal = new VoteForProposalFixture(
-      apiWrapper,
+      api,
       m2KeyPairs,
       sudo,
       decreaseLeaderStakeProposalFixture.getCreatedProposalId() as ProposalId
     )
     voteForDecreaseStakeProposal.runner(false)
     expectLeaderStakeDecreasedFixture = new ExpectLeaderStakeDecreasedFixture(
-      apiWrapper,
+      api,
       newStake,
       WorkingGroups.StorageWorkingGroup
     )
@@ -236,7 +235,7 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   })()
 
   const slashLeaderProposalFixture: SlashLeaderProposalFixture = new SlashLeaderProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     slashAmount,
@@ -251,18 +250,18 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
   await (async () => {
     newStake = newStake.sub(slashAmount)
     voteForSlashProposalFixture = new VoteForProposalFixture(
-      apiWrapper,
+      api,
       m2KeyPairs,
       sudo,
       slashLeaderProposalFixture.getCreatedProposalId() as ProposalId
     )
     voteForSlashProposalFixture.runner(false)
-    expectLeaderSlashedFixture = new ExpectLeaderSlashedFixture(apiWrapper, newStake, WorkingGroups.StorageWorkingGroup)
+    expectLeaderSlashedFixture = new ExpectLeaderSlashedFixture(api, newStake, WorkingGroups.StorageWorkingGroup)
     await expectLeaderSlashedFixture.runner(false)
   })()
 
   const terminateLeaderRoleProposalFixture: TerminateLeaderRoleProposalFixture = new TerminateLeaderRoleProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     leadKeyPair[0].address,
     sudo,
@@ -274,13 +273,13 @@ export default async function manageLeaderRole(apiWrapper: ApiWrapper, env: Node
 
   let voteForLeaderRoleTerminationFixture: VoteForProposalFixture
   const expectLeaderRoleTerminatedFixture: ExpectLeaderRoleTerminatedFixture = new ExpectLeaderRoleTerminatedFixture(
-    apiWrapper,
+    api,
     WorkingGroups.StorageWorkingGroup
   )
   // Approve leader role termination
   await (async () => {
     voteForLeaderRoleTerminationFixture = new VoteForProposalFixture(
-      apiWrapper,
+      api,
       m2KeyPairs,
       sudo,
       terminateLeaderRoleProposalFixture.getCreatedProposalId() as ProposalId

+ 8 - 8
tests/network-tests/src/flows/proposals/spendingProposal.ts

@@ -1,14 +1,14 @@
 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 { Api } from '../../Api'
+import { Utils } from '../../utils'
 import { SpendingProposalFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 
-export default async function spendingProposal(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function spendingProposal(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -17,7 +17,7 @@ export default async function spendingProposal(apiWrapper: ApiWrapper, env: Node
   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 paidTerms: PaidTermId = api.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!)
@@ -25,14 +25,14 @@ export default async function spendingProposal(apiWrapper: ApiWrapper, env: Node
   const mintCapacity: BN = new BN(+env.COUNCIL_MINTING_CAPACITY!)
 
   // const durationInBlocks = 29
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -45,7 +45,7 @@ export default async function spendingProposal(apiWrapper: ApiWrapper, env: Node
   }
 
   const spendingProposalFixture: SpendingProposalFixture = new SpendingProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     m2KeyPairs,
     sudo,

+ 8 - 8
tests/network-tests/src/flows/proposals/textProposal.ts

@@ -1,14 +1,14 @@
 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 { Api } from '../../Api'
+import { Utils } from '../../utils'
 import { TextProposalFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 
-export default async function textProposal(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function textProposal(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -17,20 +17,20 @@ export default async function textProposal(apiWrapper: ApiWrapper, env: NodeJS.P
   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 paidTerms: PaidTermId = api.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)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -42,6 +42,6 @@ export default async function textProposal(apiWrapper: ApiWrapper, env: NodeJS.P
     await councilElectionHappyCaseFixture.runner(false)
   }
 
-  const textProposalFixture: TextProposalFixture = new TextProposalFixture(apiWrapper, m1KeyPairs, m2KeyPairs, sudo)
+  const textProposalFixture: TextProposalFixture = new TextProposalFixture(api, m1KeyPairs, m2KeyPairs, sudo)
   await textProposalFixture.runner(false)
 }

+ 9 - 9
tests/network-tests/src/flows/proposals/updateRuntime.ts

@@ -1,15 +1,15 @@
 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 { Api } from '../../Api'
+import { Utils } from '../../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'
+import { DbService } from '../../DbService'
 
-export default async function updateRuntime(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function updateRuntime(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -18,21 +18,21 @@ export default async function updateRuntime(apiWrapper: ApiWrapper, env: NodeJS.
   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 paidTerms: PaidTermId = api.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)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -45,7 +45,7 @@ export default async function updateRuntime(apiWrapper: ApiWrapper, env: NodeJS.
   }
 
   const updateRuntimeFixture: UpdateRuntimeFixture = new UpdateRuntimeFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     m2KeyPairs,
     sudo,
@@ -54,7 +54,7 @@ export default async function updateRuntime(apiWrapper: ApiWrapper, env: NodeJS.
   await updateRuntimeFixture.runner(false)
 
   const thirdMemberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-    apiWrapper,
+    api,
     sudo,
     Utils.createKeyPairs(keyring, N),
     paidTerms

+ 8 - 8
tests/network-tests/src/flows/proposals/validatorCountProposal.ts

@@ -1,14 +1,14 @@
 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 { Api } from '../../Api'
+import { Utils } from '../../utils'
 import { ValidatorCountProposalFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 
-export default async function validatorCount(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function validatorCount(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -17,21 +17,21 @@ export default async function validatorCount(apiWrapper: ApiWrapper, env: NodeJS
   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 paidTerms: PaidTermId = api.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)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -44,7 +44,7 @@ export default async function validatorCount(apiWrapper: ApiWrapper, env: NodeJS
   }
 
   const validatorCountProposalFixture: ValidatorCountProposalFixture = new ValidatorCountProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     m2KeyPairs,
     sudo,

+ 11 - 11
tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts

@@ -1,16 +1,16 @@
 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 { Api, WorkingGroups } from '../../Api'
+import { Utils } from '../../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'
+import { DbService } from '../../DbService'
 
-export default async function workingGroupMintCapactiy(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function workingGroupMintCapactiy(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -19,21 +19,21 @@ export default async function workingGroupMintCapactiy(apiWrapper: ApiWrapper, e
   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 paidTerms: PaidTermId = api.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)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     m1KeyPairs = db.getMembers()
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -45,11 +45,11 @@ export default async function workingGroupMintCapactiy(apiWrapper: ApiWrapper, e
     await councilElectionHappyCaseFixture.runner(false)
   }
 
-  const newMintCapacity: BN = (await apiWrapper.getWorkingGroupMintCapacity(WorkingGroups.StorageWorkingGroup)).add(
+  const newMintCapacity: BN = (await api.getWorkingGroupMintCapacity(WorkingGroups.StorageWorkingGroup)).add(
     mintCapacityIncrement
   )
   const workingGroupMintCapacityProposalFixture: WorkingGroupMintCapacityProposalFixture = new WorkingGroupMintCapacityProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     newMintCapacity,
@@ -59,12 +59,12 @@ export default async function workingGroupMintCapactiy(apiWrapper: ApiWrapper, e
   await workingGroupMintCapacityProposalFixture.runner(false)
 
   const voteForProposalFixture: VoteForProposalFixture = new VoteForProposalFixture(
-    apiWrapper,
+    api,
     m2KeyPairs,
     sudo,
     workingGroupMintCapacityProposalFixture.getCreatedProposalId() as ProposalId
   )
-  const expectMintCapacityChanged = new ExpectMintCapacityChangedFixture(apiWrapper, newMintCapacity)
+  const expectMintCapacityChanged = new ExpectMintCapacityChangedFixture(api, newMintCapacity)
   // Approve mint capacity
   voteForProposalFixture.runner(false)
   await expectMintCapacityChanged.runner(false)

+ 13 - 13
tests/network-tests/src/flows/workingGroup/atLeastValueBug.ts

@@ -1,15 +1,15 @@
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { Keyring } from '@polkadot/api'
 import { AddWorkerOpeningFixture, LeaveRoleFixture } from '../../fixtures/workingGroupModule'
 import BN from 'bn.js'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 import { PaidTermId } from '@joystream/types/members'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
 // Zero at least value bug scenario
-export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function zeroAtLeastValueBug(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -18,7 +18,7 @@ export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: N
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -28,14 +28,14 @@ export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: N
   const openingActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 48
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
-    leadKeyPair[0] = db.getLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       nKeyPairs,
       leadKeyPair,
@@ -52,7 +52,7 @@ export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: N
   }
 
   const addWorkerOpeningWithoutStakeFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -66,7 +66,7 @@ export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: N
   await addWorkerOpeningWithoutStakeFixture.runner(true)
 
   const addWorkerOpeningWithoutUnstakingPeriodFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -79,9 +79,9 @@ export default async function zeroAtLeastValueBug(apiWrapper: ApiWrapper, env: N
   // Add worker opening with 0 unstaking period, expect failure
   await addWorkerOpeningWithoutUnstakingPeriodFixture.runner(true)
 
-  if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       WorkingGroups.StorageWorkingGroup

+ 24 - 24
tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts

@@ -1,4 +1,4 @@
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import {
@@ -14,15 +14,15 @@ import {
   SlashFixture,
   TerminateRoleFixture,
 } from '../../fixtures/workingGroupModule'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 import BN from 'bn.js'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
 // Manage worker as lead scenario
-export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -31,7 +31,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -41,14 +41,14 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   const openingActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 60
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
-    leadKeyPair[0] = db.getLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       nKeyPairs,
       leadKeyPair,
@@ -65,7 +65,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   }
 
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -82,7 +82,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // First apply for worker opening
   await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       sudo,
       applicationStake,
@@ -97,7 +97,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // Begin application review
   await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
-      apiWrapper,
+      api,
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
@@ -110,7 +110,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // Fill worker opening
   await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       leadKeyPair[0],
       sudo,
@@ -124,7 +124,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   })()
 
   const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-    apiWrapper,
+    api,
     leadKeyPair,
     sudo,
     WorkingGroups.StorageWorkingGroup
@@ -133,7 +133,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   await leaveRoleFixture.runner(false)
 
   const decreaseStakeFailureFixture: DecreaseStakeFixture = new DecreaseStakeFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -143,7 +143,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   await decreaseStakeFailureFixture.runner(true)
 
   const addNewLeaderOpeningFixture: AddLeaderOpeningFixture = new AddLeaderOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     sudo,
     applicationStake,
@@ -158,7 +158,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // Apply for lead opening
   await (async () => {
     applyForNewLeaderOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       applicationStake,
@@ -173,7 +173,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // Begin lead application review
   await (async () => {
     beginNewLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
-      apiWrapper,
+      api,
       sudo,
       addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
       WorkingGroups.StorageWorkingGroup
@@ -185,7 +185,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // Fill lead opening
   await (async () => {
     fillNewLeaderOpeningFixture = new FillLeaderOpeningFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
@@ -198,7 +198,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   })()
 
   const decreaseStakeFixture: DecreaseStakeFixture = new DecreaseStakeFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -208,7 +208,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   await decreaseStakeFixture.runner(false)
 
   const slashFixture: SlashFixture = new SlashFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -218,7 +218,7 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   await slashFixture.runner(false)
 
   const terminateRoleFixture: TerminateRoleFixture = new TerminateRoleFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -227,9 +227,9 @@ export default async function manageWorker(apiWrapper: ApiWrapper, env: NodeJS.P
   // Terminate worker role
   await terminateRoleFixture.runner(false)
 
-  if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       WorkingGroups.StorageWorkingGroup

+ 18 - 18
tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts

@@ -1,4 +1,4 @@
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import {
@@ -10,15 +10,15 @@ import {
   LeaveRoleFixture,
   UpdateRewardAccountFixture,
 } from '../../fixtures/workingGroupModule'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 import BN from 'bn.js'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
 // Manage worker as worker
-export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function manageWorkerAsWorker(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -27,7 +27,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -37,14 +37,14 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   const openingActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 38
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
-    leadKeyPair[0] = db.getLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       nKeyPairs,
       leadKeyPair,
@@ -61,7 +61,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   }
 
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -78,7 +78,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   // First apply for worker opening
   await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       sudo,
       applicationStake,
@@ -93,7 +93,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   // Begin application review
   await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
-      apiWrapper,
+      api,
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
@@ -106,7 +106,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   // Fill worker opening
   await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       leadKeyPair[0],
       sudo,
@@ -120,7 +120,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   })()
 
   const increaseStakeFixture: IncreaseStakeFixture = new IncreaseStakeFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     sudo,
     WorkingGroups.StorageWorkingGroup
@@ -129,7 +129,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   await increaseStakeFixture.runner(false)
 
   const updateRewardAccountFixture: UpdateRewardAccountFixture = new UpdateRewardAccountFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     keyring,
     sudo,
@@ -139,7 +139,7 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   await updateRewardAccountFixture.runner(false)
 
   const updateRoleAccountFixture: UpdateRewardAccountFixture = new UpdateRewardAccountFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     keyring,
     sudo,
@@ -148,9 +148,9 @@ export default async function manageWorkerAsWorker(apiWrapper: ApiWrapper, env:
   // Update role account
   await updateRoleAccountFixture.runner(false)
 
-  if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       WorkingGroups.StorageWorkingGroup

+ 17 - 17
tests/network-tests/src/flows/workingGroup/workerApplicationHappyCase.ts

@@ -1,8 +1,8 @@
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 import {
   AddWorkerOpeningFixture,
   ApplyForOpeningFixture,
@@ -13,11 +13,11 @@ import {
 } from '../../fixtures/workingGroupModule'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
 // Worker application happy case scenario
-export default async function workerApplication(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function workerApplication(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -26,7 +26,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   let nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -36,14 +36,14 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   const openingActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 48
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
-    leadKeyPair[0] = db.getLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       nKeyPairs,
       leadKeyPair,
@@ -60,7 +60,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   }
 
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -77,7 +77,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   // First apply for worker opening
   await (async () => {
     firstApplyForWorkerOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       sudo,
       applicationStake,
@@ -89,7 +89,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   })()
 
   const withdrawApplicationFixture: WithdrawApplicationFixture = new WithdrawApplicationFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     sudo,
     WorkingGroups.StorageWorkingGroup
@@ -101,7 +101,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   // Second apply for worker opening
   await (async () => {
     secondApplyForWorkerOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       sudo,
       applicationStake,
@@ -116,7 +116,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   // Begin application review
   await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
-      apiWrapper,
+      api,
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
@@ -129,7 +129,7 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
   // Fill worker opening
   await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       leadKeyPair[0],
       sudo,
@@ -142,9 +142,9 @@ export default async function workerApplication(apiWrapper: ApiWrapper, env: Nod
     await fillOpeningFixture.runner(false)
   })()
 
-  if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       WorkingGroups.StorageWorkingGroup

+ 17 - 21
tests/network-tests/src/flows/workingGroup/workerApplicationRejectionCase.ts

@@ -1,8 +1,8 @@
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 import {
   AcceptApplicationsFixture,
   AddWorkerOpeningFixture,
@@ -12,15 +12,11 @@ import {
 } from '../../fixtures/workingGroupModule'
 import { PaidTermId } from '@joystream/types/members'
 import { OpeningId } from '@joystream/types/hiring'
-import { DbService } from '../../services/dbService'
+import { DbService } from '../../DbService'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
 // Worker application rejection case scenario
-export default async function workerApplicationRejection(
-  apiWrapper: ApiWrapper,
-  env: NodeJS.ProcessEnv,
-  db: DbService
-) {
+export default async function workerApplicationRejection(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -30,7 +26,7 @@ export default async function workerApplicationRejection(
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
   const nonMemberKeyPairs = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -41,14 +37,14 @@ export default async function workerApplicationRejection(
   const leadOpeningActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 38
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     nKeyPairs = db.getMembers()
-    leadKeyPair[0] = db.getLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       nKeyPairs,
       leadKeyPair,
@@ -65,7 +61,7 @@ export default async function workerApplicationRejection(
   }
 
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -82,7 +78,7 @@ export default async function workerApplicationRejection(
   // Apply for worker opening, expect failure
   await (async () => {
     applyForWorkerOpeningBeforeAcceptanceFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       sudo,
       applicationStake,
@@ -97,7 +93,7 @@ export default async function workerApplicationRejection(
   // Begin accepting worker applications
   await (async () => {
     acceptApplicationsFixture = new AcceptApplicationsFixture(
-      apiWrapper,
+      api,
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
@@ -110,7 +106,7 @@ export default async function workerApplicationRejection(
   // Apply for worker opening as non-member, expect failure
   await (async () => {
     applyForWorkerOpeningAsNonMemberFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nonMemberKeyPairs,
       sudo,
       applicationStake,
@@ -125,7 +121,7 @@ export default async function workerApplicationRejection(
   // Apply for worker opening
   await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       nKeyPairs,
       sudo,
       applicationStake,
@@ -137,7 +133,7 @@ export default async function workerApplicationRejection(
   })()
 
   const terminateApplicationsFixture: TerminateApplicationsFixture = new TerminateApplicationsFixture(
-    apiWrapper,
+    api,
     nKeyPairs,
     leadKeyPair[0],
     sudo,
@@ -146,9 +142,9 @@ export default async function workerApplicationRejection(
   // Terminate worker applicaitons
   await terminateApplicationsFixture.runner(false)
 
-  if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       WorkingGroups.StorageWorkingGroup

+ 21 - 21
tests/network-tests/src/flows/workingGroup/workerPayout.ts

@@ -1,4 +1,4 @@
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
+import { Api, WorkingGroups } from '../../Api'
 import { Keyring } from '@polkadot/api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import {
@@ -11,18 +11,18 @@ import {
   LeaveRoleFixture,
 } from '../../fixtures/workingGroupModule'
 import BN from 'bn.js'
-import { Utils } from '../../utils/utils'
+import { Utils } from '../../utils'
 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 { DbService } from '../../DbService'
 import { CouncilElectionHappyCaseFixture } from '../../fixtures/councilElectionHappyCase'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 
 // Worker payout scenario
-export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function workerPayouts(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -33,7 +33,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   const m3KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: PaidTermId = apiWrapper.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
+  const paidTerms: PaidTermId = api.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!)
@@ -49,11 +49,11 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   const openingActivationDelay: BN = new BN(0)
 
   // const durationInBlocks = 58
-  // setTestTimeout(apiWrapper, durationInBlocks)
+  // setTestTimeout(api, durationInBlocks)
 
   if (db.hasCouncil()) {
     const memberSetFixture: BuyMembershipHappyCaseFixture = new BuyMembershipHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       paidTerms
@@ -63,7 +63,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
     m2KeyPairs = db.getCouncil()
   } else {
     const councilElectionHappyCaseFixture = new CouncilElectionHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m1KeyPairs,
       m2KeyPairs,
@@ -75,11 +75,11 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
     await councilElectionHappyCaseFixture.runner(false)
   }
 
-  if (db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
-    leadKeyPair[0] = db.getLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
-      apiWrapper,
+      api,
       sudo,
       m3KeyPairs,
       leadKeyPair,
@@ -96,7 +96,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   }
 
   const workingGroupMintCapacityProposalFixture: WorkingGroupMintCapacityProposalFixture = new WorkingGroupMintCapacityProposalFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     sudo,
     mintCapacity,
@@ -107,13 +107,13 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
 
   let voteForProposalFixture: VoteForProposalFixture
   const expectMintCapacityChanged: ExpectMintCapacityChangedFixture = new ExpectMintCapacityChangedFixture(
-    apiWrapper,
+    api,
     mintCapacity
   )
   // Approve mint capacity
   await (async () => {
     voteForProposalFixture = new VoteForProposalFixture(
-      apiWrapper,
+      api,
       m2KeyPairs,
       sudo,
       workingGroupMintCapacityProposalFixture.getCreatedProposalId() as ProposalId
@@ -123,7 +123,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   })()
 
   const addWorkerOpeningFixture: AddWorkerOpeningFixture = new AddWorkerOpeningFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     leadKeyPair[0],
     sudo,
@@ -140,7 +140,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   // First apply for worker opening
   await (async () => {
     applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
-      apiWrapper,
+      api,
       m1KeyPairs,
       sudo,
       applicationStake,
@@ -155,7 +155,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   // Begin application review
   await (async () => {
     beginApplicationReviewFixture = new BeginApplicationReviewFixture(
-      apiWrapper,
+      api,
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
@@ -168,7 +168,7 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   // Fill worker opening
   await (async () => {
     fillOpeningFixture = new FillOpeningFixture(
-      apiWrapper,
+      api,
       m1KeyPairs,
       leadKeyPair[0],
       sudo,
@@ -182,16 +182,16 @@ export default async function workerPayouts(apiWrapper: ApiWrapper, env: NodeJS.
   })()
 
   const awaitPayoutFixture: AwaitPayoutFixture = new AwaitPayoutFixture(
-    apiWrapper,
+    api,
     m1KeyPairs,
     WorkingGroups.StorageWorkingGroup
   )
   // Await worker payout
   await awaitPayoutFixture.runner(false)
 
-  if (!db.hasLeader(apiWrapper.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
     const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      apiWrapper,
+      api,
       leadKeyPair,
       sudo,
       WorkingGroups.StorageWorkingGroup

+ 8 - 8
tests/network-tests/src/scenarios/full.ts

@@ -1,7 +1,8 @@
 import { WsProvider } from '@polkadot/api'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { initConfig } from '../utils/config'
-import { DbService } from '../services/dbService'
+import { Api } from '../Api'
+import { DbService } from '../DbService'
+import { config } from 'dotenv'
+import Debugger from 'debug'
 
 import creatingMemberships from '../flows/membership/creatingMemberships'
 import councilSetup from '../flows/councilSetup'
@@ -19,18 +20,17 @@ import workerApplicaionHappyCase from '../flows/workingGroup/workerApplicationHa
 import workerApplicationRejectionCase from '../flows/workingGroup/workerApplicationRejectionCase'
 import workerPayout from '../flows/workingGroup/workerPayout'
 
-import createDebug from 'debug'
-const debug = createDebug('scenario:full')
-
 const scenario = async () => {
+  const debug = Debugger('scenario:full')
+
   // Load env variables
-  initConfig()
+  config()
   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)
+  const api: Api = await Api.create(provider)
 
   // Create shared state instance
   const db: DbService = DbService.getInstance()

+ 1 - 1
tests/network-tests/src/utils/sender.ts → tests/network-tests/src/sender.ts

@@ -3,7 +3,7 @@ import { ApiPromise } from '@polkadot/api'
 import { SubmittableExtrinsic } from '@polkadot/api/types'
 import { AccountInfo } from '@polkadot/types/interfaces'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { DbService } from '../services/dbService'
+import { DbService } from './DbService'
 
 export class Sender {
   private readonly api: ApiPromise

+ 0 - 0
tests/network-tests/src/utils/utils.ts → tests/network-tests/src/utils.ts


+ 0 - 5
tests/network-tests/src/utils/config.ts

@@ -1,5 +0,0 @@
-import { config } from 'dotenv'
-
-export function initConfig() {
-  config()
-}

+ 0 - 6
tests/network-tests/src/utils/setTestTimeout.ts

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

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