Просмотр исходного кода

network-tests: more code refactoring

Mokhtar Naamani 4 лет назад
Родитель
Сommit
09161ea80c

+ 154 - 179
tests/network-tests/src/Api.ts

@@ -1,6 +1,6 @@
 import { ApiPromise, WsProvider } from '@polkadot/api'
 import { Bytes, Option, u32, Vec, StorageKey } from '@polkadot/types'
-import { Codec } from '@polkadot/types/types'
+import { Codec, ISubmittableResult } 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'
@@ -30,6 +30,7 @@ import {
 } from '@joystream/types/hiring'
 import { FillOpeningParameters, ProposalId } from '@joystream/types/proposals'
 import Debugger from 'debug'
+import { assert } from 'chai'
 const debug = Debugger('api')
 
 export enum WorkingGroups {
@@ -97,7 +98,7 @@ export class Api {
     paidTermsId: PaidTermId,
     name: string,
     expectFailure = false
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx.members.buyMembership(
         paidTermsId,
@@ -119,7 +120,7 @@ export class Api {
     return (await this.api.query.system.account<AccountInfo>(address)).data.free
   }
 
-  public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<void> {
+  public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<ISubmittableResult> {
     return this.sender.signAndSend(this.api.tx.balances.transfer(to, amount), from)
   }
 
@@ -209,43 +210,6 @@ export class Api {
     )
   }
 
-  public estimateProposeEvictStorageProviderFee(title: string, description: string, stake: BN, address: string): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createEvictStorageProviderProposal(stake, title, description, stake, address)
-    )
-  }
-
-  public estimateProposeStorageRoleParametersFee(
-    title: string,
-    description: string,
-    stake: BN,
-    minStake: BN,
-    minActors: BN,
-    maxActors: BN,
-    reward: BN,
-    rewardPeriod: BN,
-    bondingPeriod: BN,
-    unbondingPeriod: BN,
-    minServicePeriod: BN,
-    startupGracePeriod: BN,
-    entryRequestFee: BN
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetStorageRoleParametersProposal(stake, title, description, stake, [
-        minStake,
-        minActors,
-        maxActors,
-        reward,
-        rewardPeriod,
-        bondingPeriod,
-        unbondingPeriod,
-        minServicePeriod,
-        startupGracePeriod,
-        entryRequestFee,
-      ])
-    )
-  }
-
   public estimateProposeElectionParametersFee(
     title: string,
     description: string,
@@ -611,7 +575,7 @@ export class Api {
     )
   }
 
-  private applyForCouncilElection(account: KeyringPair, amount: BN): Promise<void> {
+  private applyForCouncilElection(account: KeyringPair, amount: BN): Promise<ISubmittableResult> {
     return this.sender.signAndSend(this.api.tx.councilElection.apply(amount), account, false)
   }
 
@@ -627,7 +591,12 @@ export class Api {
     return (((await this.api.query.councilElection.applicantStakes(address)) as unknown) as ElectionStake).new
   }
 
-  private voteForCouncilMember(account: KeyringPair, nominee: string, salt: string, stake: BN): Promise<void> {
+  private voteForCouncilMember(
+    account: KeyringPair,
+    nominee: string,
+    salt: string,
+    stake: BN
+  ): Promise<ISubmittableResult> {
     const hashedVote: string = Utils.hashVote(nominee, salt)
     return this.sender.signAndSend(this.api.tx.councilElection.vote(hashedVote, stake), account, false)
   }
@@ -645,7 +614,12 @@ export class Api {
     )
   }
 
-  private revealVote(account: KeyringPair, commitment: string, nominee: string, salt: string): Promise<void> {
+  private revealVote(
+    account: KeyringPair,
+    commitment: string,
+    nominee: string,
+    salt: string
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(this.api.tx.councilElection.reveal(commitment, nominee, salt), account, false)
   }
 
@@ -659,7 +633,7 @@ export class Api {
   }
 
   // TODO consider using configurable genesis instead
-  public sudoStartAnnouncingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
+  public sudoStartAnnouncingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageAnnouncing(endsAtBlock)),
       sudo,
@@ -667,7 +641,7 @@ export class Api {
     )
   }
 
-  public sudoStartVotingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
+  public sudoStartVotingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageVoting(endsAtBlock)),
       sudo,
@@ -675,7 +649,7 @@ export class Api {
     )
   }
 
-  public sudoStartRevealingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
+  public sudoStartRevealingPeriod(sudo: KeyringPair, endsAtBlock: BN): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageRevealing(endsAtBlock)),
       sudo,
@@ -683,7 +657,7 @@ export class Api {
     )
   }
 
-  public sudoSetCouncilMintCapacity(sudo: KeyringPair, capacity: BN): Promise<void> {
+  public sudoSetCouncilMintCapacity(sudo: KeyringPair, capacity: BN): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(this.api.tx.council.setCouncilMintCapacity(capacity)),
       sudo,
@@ -711,7 +685,7 @@ export class Api {
     name: string,
     description: string,
     runtime: Bytes | string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createRuntimeUpgradeProposal(
@@ -732,7 +706,7 @@ export class Api {
     name: string,
     description: string,
     text: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createTextProposal(
@@ -754,7 +728,7 @@ export class Api {
     stake: BN,
     balance: BN,
     destination: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createSpendingProposal(
@@ -776,7 +750,7 @@ export class Api {
     description: string,
     stake: BN,
     validatorCount: BN
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createSetValidatorCountProposal(
@@ -797,7 +771,7 @@ export class Api {
     description: string,
     stake: BN,
     leadAccount: KeyringPair
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     const leadMemberId: MemberId = (await this.getMemberIds(leadAccount.address))[0]
     const addressString: string = leadAccount.address
@@ -824,7 +798,7 @@ export class Api {
     newTermDuration: BN,
     minCouncilStake: BN,
     minVotingStake: BN
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createSetElectionParametersProposal(memberId, title, description, stake, [
@@ -849,7 +823,7 @@ export class Api {
     stake: BN,
     openingId: OpeningId,
     workingGroup: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createBeginReviewWorkingGroupLeaderApplicationsProposal(
@@ -865,7 +839,7 @@ export class Api {
     )
   }
 
-  public approveProposal(account: KeyringPair, memberId: MemberId, proposal: ProposalId): Promise<void> {
+  public approveProposal(account: KeyringPair, memberId: MemberId, proposal: ProposalId): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx.proposalsEngine.vote(memberId, proposal, 'Approve') as unknown) as SubmittableExtrinsic<'promise'>,
       account,
@@ -890,63 +864,63 @@ export class Api {
     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) => {
-        events.forEach((record) => {
-          if (record.event.method && record.event.method.toString() === 'ProposalCreated') {
-            unsubscribe()
-            resolve(record.event.data[1] as ProposalId)
-          }
-        })
-      })
-    })
+  public expectProposalCreatedEvent(events: EventRecord[]): ProposalId {
+    const record = events.find((record) => record.event.method && record.event.method.toString() === 'ProposalCreated')
+    if (!record) {
+      throw new Error('Expected Event Not Found')
+    }
+    return record.event.data[1] as ProposalId
   }
 
-  public expectRuntimeUpgraded(): Promise<void> {
-    return new Promise(async (resolve) => {
-      const unsubscribe = await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method.toString() === 'RuntimeUpdated') {
-            unsubscribe()
-            resolve()
-          }
-        })
-      })
-    })
+  public expectOpeningAddedEvent(events: EventRecord[]): OpeningId {
+    const record = events.find((record) => record.event.method && record.event.method.toString() === 'OpeningAdded')
+    if (!record) {
+      throw new Error('Expected Event Not Found')
+    }
+    return record.event.data[0] as OpeningId
+  }
+
+  public async expectRuntimeUpgraded(): Promise<void> {
+    await this.expectSystemEvent('RuntimeUpdated')
   }
 
-  public expectProposalFinalized(): Promise<void> {
+  public waitForProposalToFinalize(id: ProposalId): Promise<void> {
     return new Promise(async (resolve) => {
       const unsubscribe = await this.api.query.system.events<Vec<EventRecord>>((events) => {
         events.forEach((record) => {
           if (
             record.event.method &&
             record.event.method.toString() === 'ProposalStatusUpdated' &&
+            record.event.data[0].eq(id) &&
             record.event.data[1].toString().includes('Executed')
           ) {
             unsubscribe()
             resolve()
+          } else if (
+            record.event.method &&
+            record.event.method.toString() === 'ProposalStatusUpdated' &&
+            record.event.data[0].eq(id) &&
+            record.event.data[1].toString().includes('ExecutionFailed')
+          ) {
+            unsubscribe()
+            resolve()
           }
         })
       })
     })
   }
 
-  public expectOpeningFilled(): Promise<ApplicationIdToWorkerIdMap> {
-    return new Promise(async (resolve) => {
-      const unsubscribe = await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method && record.event.method.toString() === 'OpeningFilled') {
-            unsubscribe()
-            resolve((record.event.data[1] as unknown) as ApplicationIdToWorkerIdMap)
-          }
-        })
-      })
-    })
+  public expectOpeningFilledEvent(events: EventRecord[]): ApplicationIdToWorkerIdMap {
+    const record = events.find((record) => record.event.method && record.event.method.toString() === 'OpeningFilled')
+    if (!record) {
+      throw new Error('Expected Event Not Found')
+    }
+    return (record.event.data[1] as unknown) as ApplicationIdToWorkerIdMap
   }
 
-  public expectEvent(eventName: string): Promise<Event> {
+  // Looks for the first occurance of an expected event, and resolves.
+  // Use this when the event we are expecting is not particular to a specific extrinsic
+  public expectSystemEvent(eventName: string): Promise<Event> {
     return new Promise(async (resolve) => {
       const unsubscribe = await this.api.query.system.events<Vec<EventRecord>>((events) => {
         events.forEach((record) => {
@@ -959,17 +933,14 @@ export class Api {
     })
   }
 
-  public expectApplicationReviewBegan(): Promise<ApplicationId> {
-    return new Promise(async (resolve) => {
-      const unsubscribe = await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method && record.event.method.toString() === 'BeganApplicationReview') {
-            unsubscribe()
-            resolve((record.event.data as unknown) as ApplicationId)
-          }
-        })
-      })
-    })
+  public expectApplicationReviewBeganEvent(events: EventRecord[]): ApplicationId {
+    const record = events.find(
+      (record) => record.event.method && record.event.method.toString() === 'BeganApplicationReview'
+    )
+    if (!record) {
+      throw new Error('Expected Event Not Found')
+    }
+    return (record.event.data as unknown) as ApplicationId
   }
 
   public async getWorkingGroupMintCapacity(module: WorkingGroups): Promise<BN> {
@@ -982,11 +953,6 @@ export class Api {
     return this.api.query.staking.validatorCount<u32>()
   }
 
-  public async isStorageProvider(address: string): Promise<boolean> {
-    const accountWorkers: WorkerId = await this.getWorkerIdByRoleAccount(address, WorkingGroups.StorageWorkingGroup)
-    return accountWorkers !== undefined
-  }
-
   public async addOpening(openingParameters: {
     leader: KeyringPair
     activationDelay: BN
@@ -1011,7 +977,7 @@ export class Api {
     type: string
     module: WorkingGroups
     expectFailure: boolean
-  }): Promise<void> {
+  }): Promise<ISubmittableResult> {
     const activateAt: ActivateOpeningAt = this.api.createType(
       'ActivateOpeningAt',
       openingParameters.activationDelay.eqn(0)
@@ -1109,7 +1075,7 @@ export class Api {
     text: string
     type: string
     module: WorkingGroups
-  }): Promise<void> {
+  }): Promise<ISubmittableResult> {
     const activateAt: ActivateOpeningAt = this.api.createType(
       'ActivateOpeningAt',
       openingParameters.activationDelay.eqn(0)
@@ -1211,7 +1177,7 @@ export class Api {
     exitRoleStakeUnstakingPeriod: BN
     text: string
     workingGroup: string
-  }): Promise<void> {
+  }): Promise<ISubmittableResult> {
     const commitment: WorkingGroupOpeningPolicyCommitment = this.api.createType('WorkingGroupOpeningPolicyCommitment', {
       application_rationing_policy: this.api.createType('Option<ApplicationRationingPolicy>', {
         max_active_applicants: leaderOpening.maxActiveApplicants as u32,
@@ -1296,7 +1262,7 @@ export class Api {
     nextPaymentAtBlock: BN
     payoutInterval: BN
     workingGroup: string
-  }): Promise<void> {
+  }): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(fillOpening.account.address))[0]
 
     const fillOpeningParameters: FillOpeningParameters = this.api.createType('FillOpeningParameters', {
@@ -1332,7 +1298,7 @@ export class Api {
     rationale: string,
     slash: boolean,
     workingGroup: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
@@ -1360,7 +1326,7 @@ export class Api {
     workerId: WorkerId,
     rewardAmount: BN,
     workingGroup: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createSetWorkingGroupLeaderRewardProposal(
@@ -1385,7 +1351,7 @@ export class Api {
     workerId: WorkerId,
     rewardAmount: BN,
     workingGroup: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createDecreaseWorkingGroupLeaderStakeProposal(
@@ -1410,7 +1376,7 @@ export class Api {
     workerId: WorkerId,
     rewardAmount: BN,
     workingGroup: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createSlashWorkingGroupLeaderStakeProposal(
@@ -1434,7 +1400,7 @@ export class Api {
     proposalStake: BN,
     mintCapacity: BN,
     workingGroup: string
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx.proposalsCodex.createSetWorkingGroupMintCapacityProposal(
@@ -1462,7 +1428,11 @@ export class Api {
     >
   }
 
-  public async acceptApplications(leader: KeyringPair, openingId: OpeningId, module: WorkingGroups): Promise<void> {
+  public async acceptApplications(
+    leader: KeyringPair,
+    openingId: OpeningId,
+    module: WorkingGroups
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].acceptApplications(openingId) as unknown) as SubmittableExtrinsic<'promise'>,
       leader,
@@ -1470,7 +1440,11 @@ export class Api {
     )
   }
 
-  public async beginApplicantReview(leader: KeyringPair, openingId: OpeningId, module: WorkingGroups): Promise<void> {
+  public async beginApplicantReview(
+    leader: KeyringPair,
+    openingId: OpeningId,
+    module: WorkingGroups
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].beginApplicantReview(openingId) as unknown) as SubmittableExtrinsic<'promise'>,
       leader,
@@ -1478,7 +1452,11 @@ export class Api {
     )
   }
 
-  public async sudoBeginApplicantReview(sudo: KeyringPair, openingId: OpeningId, module: WorkingGroups): Promise<void> {
+  public async sudoBeginApplicantReview(
+    sudo: KeyringPair,
+    openingId: OpeningId,
+    module: WorkingGroups
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx.sudo.sudo(this.api.tx[module].beginApplicantReview(openingId)) as unknown) as SubmittableExtrinsic<
         'promise'
@@ -1497,7 +1475,7 @@ export class Api {
     text: string,
     expectFailure: boolean,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const memberId: MemberId = (await this.getMemberIds(account.address))[0]
     return this.sender.signAndSend(
       (this.api.tx[module].applyOnOpening(
@@ -1546,7 +1524,7 @@ export class Api {
     nextPaymentBlock: BN,
     payoutInterval: BN,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].fillOpening(openingId, applicationId, {
         'amount_per_payout': amountPerPayout,
@@ -1566,7 +1544,7 @@ export class Api {
     nextPaymentBlock: BN,
     payoutInterval: BN,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       this.api.tx.sudo.sudo(
         this.api.tx[module].fillOpening(openingId, applicationId, {
@@ -1580,7 +1558,12 @@ export class Api {
     )
   }
 
-  public async increaseStake(worker: KeyringPair, workerId: WorkerId, stake: BN, module: WorkingGroups): Promise<void> {
+  public async increaseStake(
+    worker: KeyringPair,
+    workerId: WorkerId,
+    stake: BN,
+    module: WorkingGroups
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].increaseStake(workerId, stake) as unknown) as SubmittableExtrinsic<'promise'>,
       worker,
@@ -1594,7 +1577,7 @@ export class Api {
     stake: BN,
     module: WorkingGroups,
     expectFailure: boolean
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].decreaseStake(workerId, stake) as unknown) as SubmittableExtrinsic<'promise'>,
       leader,
@@ -1608,7 +1591,7 @@ export class Api {
     stake: BN,
     module: WorkingGroups,
     expectFailure: boolean
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].slashStake(workerId, stake) as unknown) as SubmittableExtrinsic<'promise'>,
       leader,
@@ -1621,7 +1604,7 @@ export class Api {
     workerId: WorkerId,
     newRoleAccount: string,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].updateRoleAccount(workerId, newRoleAccount) as unknown) as SubmittableExtrinsic<'promise'>,
       worker,
@@ -1634,7 +1617,7 @@ export class Api {
     workerId: WorkerId,
     newRewardAccount: string,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].updateRewardAccount(workerId, newRewardAccount) as unknown) as SubmittableExtrinsic<
         'promise'
@@ -1648,7 +1631,7 @@ export class Api {
     account: KeyringPair,
     applicationId: ApplicationId,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].withdrawApplication(applicationId) as unknown) as SubmittableExtrinsic<'promise'>,
       account,
@@ -1656,23 +1639,23 @@ export class Api {
     )
   }
 
-  public async batchWithdrawApplication(accounts: KeyringPair[], module: WorkingGroups): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair) => {
-        const applicationIds: ApplicationId[] = await this.getActiveApplicationsIdsByRoleAccount(
-          keyPair.address,
-          module
-        )
-        await this.withdrawApplication(keyPair, applicationIds[0], module)
-      })
-    )
-  }
+  // public async batchWithdrawApplication(accounts: KeyringPair[], module: WorkingGroups): Promise<void[]> {
+  //   return Promise.all(
+  //     accounts.map(async (keyPair) => {
+  //       const applicationIds: ApplicationId[] = await this.getActiveApplicationsIdsByRoleAccount(
+  //         keyPair.address,
+  //         module
+  //       )
+  //       await this.withdrawApplication(keyPair, applicationIds[0], module)
+  //     })
+  //   )
+  // }
 
   public async terminateApplication(
     leader: KeyringPair,
     applicationId: ApplicationId,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].terminateApplication(applicationId) as unknown) as SubmittableExtrinsic<'promise'>,
       leader,
@@ -1682,18 +1665,10 @@ export class Api {
 
   public async batchTerminateApplication(
     leader: KeyringPair,
-    roleAccounts: KeyringPair[],
+    applicationIds: ApplicationId[],
     module: WorkingGroups
-  ): Promise<void[]> {
-    return Promise.all(
-      roleAccounts.map(async (keyPair) => {
-        const applicationIds: ApplicationId[] = await this.getActiveApplicationsIdsByRoleAccount(
-          keyPair.address,
-          module
-        )
-        await this.terminateApplication(leader, applicationIds[0], module)
-      })
-    )
+  ): Promise<ISubmittableResult[]> {
+    return Promise.all(applicationIds.map((id) => this.terminateApplication(leader, id, module)))
   }
 
   public async terminateRole(
@@ -1702,7 +1677,7 @@ export class Api {
     text: string,
     module: WorkingGroups,
     expectFailure: boolean
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     return this.sender.signAndSend(
       (this.api.tx[module].terminateRole(applicationId, text, false) as unknown) as SubmittableExtrinsic<'promise'>,
       leader,
@@ -1715,7 +1690,7 @@ export class Api {
     text: string,
     expectFailure: boolean,
     module: WorkingGroups
-  ): Promise<void> {
+  ): Promise<ISubmittableResult> {
     const workerId: WorkerId = await this.getWorkerIdByRoleAccount(account.address, module)
     return this.sender.signAndSend(
       (this.api.tx[module].leaveRole(workerId, text) as unknown) as SubmittableExtrinsic<'promise'>,
@@ -1785,13 +1760,13 @@ export class Api {
     return await this.api.query[module].workerById<Worker>(id)
   }
 
-  public async getWorkerIdByRoleAccount(address: string, module: WorkingGroups): Promise<WorkerId> {
-    const workersAndIds: [StorageKey, Worker][] = await this.api.query[module].workerById.entries<Worker>()
-    const index: number = workersAndIds.findIndex(
-      (workersAndId) => workersAndId[1].role_account_id.toString() === address
-    )
-    return workersAndIds[index][0].args[0] as WorkerId
-  }
+  // public async getWorkerIdByRoleAccount(address: string, module: WorkingGroups): Promise<WorkerId> {
+  //   const workersAndIds: [StorageKey, Worker][] = await this.api.query[module].workerById.entries<Worker>()
+  //   const index: number = workersAndIds.findIndex(
+  //     (workersAndId) => workersAndId[1].role_account_id.toString() === address
+  //   )
+  //   return workersAndIds[index][0].args[0] as WorkerId
+  // }
 
   public async isWorker(address: string, module: WorkingGroups): Promise<boolean> {
     const workersAndIds: [StorageKey, Worker][] = await this.api.query[module].workerById.entries<Worker>()
@@ -1823,26 +1798,26 @@ export class Api {
     return this.api.query[module].applicationById<Application>(id)
   }
 
-  public async getActiveApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
-    const applicationsAndIds: [StorageKey, Application][] = await this.api.query[module].applicationById.entries<
-      Application
-    >()
-    return (
-      await Promise.all(
-        applicationsAndIds.map(async (applicationWithId) => {
-          const application: Application = applicationWithId[1]
-          if (
-            application.role_account_id.toString() === address &&
-            (await this.getHiringApplicationById(application.application_id)).stage.type === 'Active'
-          ) {
-            return applicationWithId[0].args[0] as ApplicationId
-          } else {
-            return undefined
-          }
-        })
-      )
-    ).filter((index) => index !== undefined) as ApplicationId[]
-  }
+  // public async getActiveApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<ApplicationId[]> {
+  //   const applicationsAndIds: [StorageKey, Application][] = await this.api.query[module].applicationById.entries<
+  //     Application
+  //   >()
+  //   return (
+  //     await Promise.all(
+  //       applicationsAndIds.map(async (applicationWithId) => {
+  //         const application: Application = applicationWithId[1]
+  //         if (
+  //           application.role_account_id.toString() === address &&
+  //           (await this.getHiringApplicationById(application.application_id)).stage.type === 'Active'
+  //         ) {
+  //           return applicationWithId[0].args[0] as ApplicationId
+  //         } else {
+  //           return undefined
+  //         }
+  //       })
+  //     )
+  //   ).filter((index) => index !== undefined) as ApplicationId[]
+  // }
 
   public async getStake(id: StakeId): Promise<Stake> {
     return this.api.query.stake.stakes<Stake>(id)

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

@@ -52,12 +52,8 @@ export class ElectCouncilFixture implements Fixture {
     const revealVoteFee: BN = this.api.estimateRevealVoteFee(this.sudo.address, salt[0])
 
     // Topping the balances
-    await this.api.transferBalanceToAccounts(
-      this.sudo,
-      this.applicantKeyPairs,
-      applyForCouncilFee.add(this.greaterStake)
-    )
-    await this.api.transferBalanceToAccounts(
+    this.api.transferBalanceToAccounts(this.sudo, this.applicantKeyPairs, applyForCouncilFee.add(this.greaterStake))
+    this.api.transferBalanceToAccounts(
       this.sudo,
       this.voterKeyPairs,
       voteForCouncilFee.add(revealVoteFee).add(this.greaterStake)

+ 70 - 66
tests/network-tests/src/fixtures/proposalsModule.ts

@@ -50,8 +50,7 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeCreateWorkingGroupLeaderOpening({
+    const result = await this.api.proposeCreateWorkingGroupLeaderOpening({
       account: this.membersKeyPairs[0],
       title: proposalTitle,
       description: description,
@@ -77,7 +76,9 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
       text: uuid().substring(0, 8),
       workingGroup: this.workingGroup,
     })
-    this.result = await proposalPromise
+
+    this.result = this.api.expectProposalCreatedEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -122,8 +123,7 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeBeginWorkingGroupLeaderApplicationReview(
+    const result = await this.api.proposeBeginWorkingGroupLeaderApplicationReview(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -131,7 +131,8 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
       this.openingId,
       this.workingGroup
     )
-    this.result = await proposalPromise
+    this.result = this.api.expectProposalCreatedEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -141,7 +142,7 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
 export class FillLeaderOpeningProposalFixture implements Fixture {
   private api: Api
   private membersKeyPairs: KeyringPair[]
-  private applicantRoleAccountAddress: string
+  private applicationId: ApplicationId
   private treasury: KeyringPair
   private firstRewardInterval: BN
   private rewardInterval: BN
@@ -154,7 +155,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
   constructor(
     api: Api,
     membersKeyPairs: KeyringPair[],
-    applicantRoleAccountAddress: string,
+    applicationId: ApplicationId,
     treasury: KeyringPair,
     firstRewardInterval: BN,
     rewardInterval: BN,
@@ -164,7 +165,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
   ) {
     this.api = api
     this.membersKeyPairs = membersKeyPairs
-    this.applicantRoleAccountAddress = applicantRoleAccountAddress
+    this.applicationId = applicationId
     this.treasury = treasury
     this.firstRewardInterval = firstRewardInterval
     this.rewardInterval = rewardInterval
@@ -188,26 +189,24 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
     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.api.getActiveApplicationsIdsByRoleAccount(this.applicantRoleAccountAddress, this.workingGroup)
-    )[0]
     const now: BN = await this.api.getBestBlock()
 
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeFillLeaderOpening({
+    // Proposal creation
+    const result = await this.api.proposeFillLeaderOpening({
       account: this.membersKeyPairs[0],
       title: proposalTitle,
       description: description,
       proposalStake: proposalStake,
       openingId: this.openingId,
-      successfulApplicationId: applicationId,
+      successfulApplicationId: this.applicationId,
       amountPerPayout: this.payoutAmount,
       nextPaymentAtBlock: now.add(this.firstRewardInterval),
       payoutInterval: this.rewardInterval,
       workingGroup: workingGroupString,
     })
-    this.result = await proposalPromise
+
+    this.result = this.api.expectProposalCreatedEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -250,7 +249,8 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
     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.api.getWorkingGroupString(this.workingGroup)
-    const workerId: WorkerId = await this.api.getWorkerIdByRoleAccount(this.leaderRoleAccountAddress, this.workingGroup)
+    // assert worker exists
+    const workerId: WorkerId = (await this.api.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(100000)
@@ -258,8 +258,7 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeTerminateLeaderRole(
+    const result = await this.api.proposeTerminateLeaderRole(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -269,7 +268,8 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
       this.slash,
       workingGroupString
     )
-    this.result = await proposalPromise
+    this.result = this.api.expectProposalCreatedEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -308,6 +308,7 @@ export class SetLeaderRewardProposalFixture implements Fixture {
     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.api.getWorkingGroupString(this.workingGroup)
+    // assert worker exists?
     const workerId: WorkerId = (await this.api.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
@@ -316,8 +317,7 @@ export class SetLeaderRewardProposalFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeLeaderReward(
+    const result = await this.api.proposeLeaderReward(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -326,7 +326,9 @@ export class SetLeaderRewardProposalFixture implements Fixture {
       this.payoutAmount,
       workingGroupString
     )
-    this.result = await proposalPromise
+
+    this.result = this.api.expectProposalCreatedEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -365,6 +367,7 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
     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.api.getWorkingGroupString(this.workingGroup)
+    // assert worker exists ?
     const workerId: WorkerId = (await this.api.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
@@ -373,8 +376,7 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeDecreaseLeaderStake(
+    const result = await this.api.proposeDecreaseLeaderStake(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -383,7 +385,9 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
       this.stakeDecrement,
       workingGroupString
     )
-    this.result = await proposalPromise
+
+    this.result = this.api.expectProposalCreatedEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -430,8 +434,7 @@ export class SlashLeaderProposalFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeSlashLeaderStake(
+    const result = await this.api.proposeSlashLeaderStake(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -440,7 +443,7 @@ export class SlashLeaderProposalFixture implements Fixture {
       this.slashAmount,
       workingGroupString
     )
-    this.result = await proposalPromise
+    this.result = this.api.expectProposalCreatedEvent(result.events)
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -486,8 +489,7 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeWorkingGroupMintCapacity(
+    const result = await this.api.proposeWorkingGroupMintCapacity(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -495,7 +497,7 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
       this.mintCapacity,
       workingGroupString
     )
-    this.result = await proposalPromise
+    this.result = this.api.expectProposalCreatedEvent(result.events)
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -556,8 +558,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.api.expectProposalCreated()
-    await this.api.proposeElectionParameters(
+
+    const proposalCreationResult = await this.api.proposeElectionParameters(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
@@ -571,12 +573,11 @@ export class ElectionParametersProposalFixture implements Fixture {
       proposedMinCouncilStake,
       proposedMinVotingStake
     )
-    const proposalNumber: ProposalId = await proposalPromise
+    const proposalNumber = this.api.expectProposalCreatedEvent(proposalCreationResult.events)
 
     // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.api.expectProposalFinalized()
-    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
-    await proposalExecutionPromise
+    this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    await this.api.waitForProposalToFinalize(proposalNumber)
 
     // Assertions
     const newAnnouncingPeriod: BN = await this.api.getAnnouncingPeriod()
@@ -668,8 +669,7 @@ export class SpendingProposalFixture implements Fixture {
     await this.api.sudoSetCouncilMintCapacity(this.sudo, this.mintCapacity)
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeSpending(
+    const result = await this.api.proposeSpending(
       this.membersKeyPairs[0],
       'testing spending' + uuid().substring(0, 8),
       'spending to test proposal functionality' + uuid().substring(0, 8),
@@ -677,13 +677,13 @@ export class SpendingProposalFixture implements Fixture {
       this.spendingBalance,
       this.sudo.address
     )
-    const proposalNumber: ProposalId = await proposalPromise
+    const proposalNumber: ProposalId = this.api.expectProposalCreatedEvent(result.events)
 
     // Approving spending proposal
     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
+    this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    await this.api.waitForProposalToFinalize(proposalNumber)
+
     const balanceAfterMinting: BN = await this.api.getBalance(this.sudo.address)
     assert(
       balanceAfterMinting.sub(balanceBeforeMinting).eq(this.spendingBalance),
@@ -733,14 +733,20 @@ export class TextProposalFixture implements Fixture {
     )
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeText(this.membersKeyPairs[0], proposalStake, proposalTitle, description, proposalText)
-    const proposalNumber: ProposalId = await proposalPromise
+
+    const result = await this.api.proposeText(
+      this.membersKeyPairs[0],
+      proposalStake,
+      proposalTitle,
+      description,
+      proposalText
+    )
+    const proposalNumber: ProposalId = this.api.expectProposalCreatedEvent(result.events)
 
     // Approving text proposal
-    const textProposalPromise: Promise<void> = this.api.expectProposalFinalized()
-    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
-    await textProposalPromise
+    this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    await this.api.waitForProposalToFinalize(proposalNumber)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -783,20 +789,19 @@ export class ValidatorCountProposalFixture implements Fixture {
 
     // Proposal creation
     const proposedValidatorCount: BN = validatorCount.add(this.validatorCountIncrement)
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeValidatorCount(
+    const result = await this.api.proposeValidatorCount(
       this.membersKeyPairs[0],
       proposalTitle,
       description,
       proposalStake,
       proposedValidatorCount
     )
-    const proposalNumber: ProposalId = await proposalPromise
+    const proposalNumber: ProposalId = this.api.expectProposalCreatedEvent(result.events)
 
     // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.api.expectProposalFinalized()
-    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
-    await proposalExecutionPromise
+    this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    await this.api.waitForProposalToFinalize(proposalNumber)
+
     const newValidatorCount: BN = await this.api.getValidatorCount()
     assert(
       proposedValidatorCount.eq(newValidatorCount),
@@ -851,20 +856,19 @@ export class UpdateRuntimeFixture implements Fixture {
     await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, runtimeVoteFee)
 
     // Proposal creation
-    const proposalPromise: Promise<ProposalId> = this.api.expectProposalCreated()
-    await this.api.proposeRuntime(
+    const result = await this.api.proposeRuntime(
       this.membersKeyPairs[0],
       proposalStake,
       'testing runtime' + uuid().substring(0, 8),
       'runtime to test proposal functionality' + uuid().substring(0, 8),
       runtime
     )
-    const proposalNumber: ProposalId = await proposalPromise
+    const proposalNumber: ProposalId = this.api.expectProposalCreatedEvent(result.events)
 
     // Approving runtime update proposal
-    const runtimePromise: Promise<void> = this.api.expectProposalFinalized()
-    await this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
-    await runtimePromise
+    this.api.batchApproveProposal(this.councilKeyPairs, proposalNumber)
+    await this.api.waitForProposalToFinalize(proposalNumber)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -889,9 +893,9 @@ export class VoteForProposalFixture implements Fixture {
     await this.api.transferBalanceToAccounts(this.treasury, this.councilKeyPairs, proposalVoteFee)
 
     // Approving the proposal
-    const proposalExecutionPromise: Promise<void> = this.api.expectProposalFinalized()
-    await this.api.batchApproveProposal(this.councilKeyPairs, this.proposalNumber)
-    await proposalExecutionPromise
+    this.api.batchApproveProposal(this.councilKeyPairs, this.proposalNumber)
+    await this.api.waitForProposalToFinalize(this.proposalNumber)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }

+ 70 - 85
tests/network-tests/src/fixtures/workingGroupModule.ts

@@ -2,7 +2,7 @@ import BN from 'bn.js'
 import { assert } from 'chai'
 import { Api, WorkingGroups } from '../Api'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { Event } from '@polkadot/types/interfaces'
+// import { Event } from '@polkadot/types/interfaces'
 import { Keyring } from '@polkadot/api'
 import { v4 as uuid } from 'uuid'
 import { RewardRelationship } from '@joystream/types/recurring-rewards'
@@ -56,8 +56,7 @@ export class AddWorkerOpeningFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.lead.address, addOpeningFee)
 
     // Worker opening creation
-    const addOpeningPromise: Promise<Event> = this.api.expectEvent('OpeningAdded')
-    await this.api.addOpening({
+    const result = await this.api.addOpening({
       leader: this.lead,
       activationDelay: this.activationDelay,
       maxActiveApplicants: new BN(this.membersKeyPairs.length),
@@ -82,9 +81,11 @@ export class AddWorkerOpeningFixture implements Fixture {
       module: this.module,
       expectFailure: expectFailure,
     })
-    if (!expectFailure) {
-      const openingId: OpeningId = (await addOpeningPromise).data[0] as OpeningId
-      this.result = openingId
+
+    if (expectFailure) {
+      throw new Error('Successful fixture run while expecting failure')
+    } else {
+      this.result = this.api.expectOpeningAddedEvent(result.events)
     }
   }
 }
@@ -123,8 +124,7 @@ export class AddLeaderOpeningFixture implements Fixture {
   }
 
   public async runner(expectFailure: boolean): Promise<void> {
-    const addOpeningPromise: Promise<Event> = this.api.expectEvent('OpeningAdded')
-    await this.api.sudoAddOpening({
+    const result = await this.api.sudoAddOpening({
       sudo: this.sudo,
       activationDelay: this.activationDelay,
       maxActiveApplicants: new BN(this.membersKeyPairs.length),
@@ -148,9 +148,11 @@ export class AddLeaderOpeningFixture implements Fixture {
       type: 'Leader',
       module: this.module,
     })
-    this.result = (await addOpeningPromise).data[0] as OpeningId
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
+    } else {
+      this.result = this.api.expectOpeningAddedEvent(result.events)
     }
   }
 }
@@ -237,13 +239,13 @@ export class ApplyForOpeningFixture implements Fixture {
 
 export class WithdrawApplicationFixture implements Fixture {
   private api: Api
-  private membersKeyPairs: KeyringPair[]
+  private applicationIds: ApplicationId[]
   private treasury: KeyringPair
   private module: WorkingGroups
 
-  constructor(api: Api, membersKeyPairs: KeyringPair[], treasury: KeyringPair, module: WorkingGroups) {
+  constructor(api: Api, applicationIds: ApplicationId[], treasury: KeyringPair, module: WorkingGroups) {
     this.api = api
-    this.membersKeyPairs = membersKeyPairs
+    this.applicationIds = applicationIds
     this.treasury = treasury
     this.module = module
   }
@@ -251,19 +253,22 @@ export class WithdrawApplicationFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
     const withdrawApplicaitonFee: BN = this.api.estimateWithdrawApplicationFee(this.module)
-    await this.api.transferBalanceToAccounts(this.treasury, this.membersKeyPairs, withdrawApplicaitonFee)
+    // FIXME
+    // get role accounts of applicants
+    // const roleAccountAddress = this.api.getRoleAccountsOfApplicants(this.module)
+    // await this.api.transferBalanceToAccounts(this.treasury, this.membersKeyPairs, withdrawApplicaitonFee)
 
     // Application withdrawal
-    await this.api.batchWithdrawApplication(this.membersKeyPairs, this.module)
-
-    // Assertions
-    this.membersKeyPairs.forEach(async (keyPair) => {
-      const activeApplications: ApplicationId[] = await this.api.getActiveApplicationsIdsByRoleAccount(
-        keyPair.address,
-        this.module
-      )
-      assert(activeApplications.length === 0, `Unexpected active application found for ${keyPair.address}`)
-    })
+    // await this.api.batchWithdrawApplication(this.membersKeyPairs, this.module)
+
+    // // Assertions
+    // this.membersKeyPairs.forEach(async (keyPair) => {
+    //   const activeApplications: ApplicationId[] = await this.api.getActiveApplicationsIdsByRoleAccount(
+    //     keyPair.address,
+    //     this.module
+    //   )
+    //   assert(activeApplications.length === 0, `Unexpected active application found for ${keyPair.address}`)
+    // })
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -291,9 +296,11 @@ export class BeginApplicationReviewFixture implements Fixture {
     await this.api.transferBalance(this.treasury, this.lead.address, beginReviewFee)
 
     // Begin application review
-    const beginApplicantReviewPromise: Promise<ApplicationId> = this.api.expectApplicationReviewBegan()
-    await this.api.beginApplicantReview(this.lead, this.openingId, this.module)
-    await beginApplicantReviewPromise
+    // const beginApplicantReviewPromise: Promise<ApplicationId> = this.api.expectApplicationReviewBegan()
+    const result = await this.api.beginApplicantReview(this.lead, this.openingId, this.module)
+
+    this.api.expectApplicationReviewBeganEvent(result.events)
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -324,7 +331,7 @@ export class BeginLeaderApplicationReviewFixture implements Fixture {
 
 export class FillOpeningFixture implements Fixture {
   private api: Api
-  private membersKeyPairs: KeyringPair[]
+  private applicationIds: ApplicationId[]
   private lead: KeyringPair
   private treasury: KeyringPair
   private openingId: OpeningId
@@ -335,7 +342,7 @@ export class FillOpeningFixture implements Fixture {
 
   constructor(
     api: Api,
-    membersKeyPairs: KeyringPair[],
+    applicationIds: ApplicationId[],
     lead: KeyringPair,
     treasury: KeyringPair,
     openingId: OpeningId,
@@ -345,7 +352,7 @@ export class FillOpeningFixture implements Fixture {
     module: WorkingGroups
   ) {
     this.api = api
-    this.membersKeyPairs = membersKeyPairs
+    this.applicationIds = applicationIds
     this.lead = lead
     this.treasury = treasury
     this.openingId = openingId
@@ -359,36 +366,30 @@ export class FillOpeningFixture implements Fixture {
     // Fee estimation and transfer
     const beginReviewFee: BN = this.api.estimateFillOpeningFee(this.module)
     await this.api.transferBalance(this.treasury, this.lead.address, beginReviewFee)
-    const applicationIds: ApplicationId[] = (
-      await Promise.all(
-        this.membersKeyPairs.map(async (keypair) =>
-          this.api.getActiveApplicationsIdsByRoleAccount(keypair.address, this.module)
-        )
-      )
-    ).flat()
+
     // Assert max number of workers is not exceeded
     const activeWorkersCount: BN = await this.api.getActiveWorkersCount(this.module)
     const maxWorkersCount: BN = this.api.getMaxWorkersCount(this.module)
     assert(
-      activeWorkersCount.addn(applicationIds.length).lte(maxWorkersCount),
+      activeWorkersCount.addn(this.applicationIds.length).lte(maxWorkersCount),
       `The number of workers ${activeWorkersCount.addn(
-        applicationIds.length
+        this.applicationIds.length
       )} will exceed max workers count ${maxWorkersCount}`
     )
 
     // Fill worker opening
     const now: BN = await this.api.getBestBlock()
-    const fillOpeningPromise: Promise<ApplicationIdToWorkerIdMap> = this.api.expectOpeningFilled()
-    await this.api.fillOpening(
+
+    const result = await this.api.fillOpening(
       this.lead,
       this.openingId,
-      applicationIds,
+      this.applicationIds,
       this.amountPerPayout,
       now.add(this.firstPayoutInterval),
       this.payoutInterval,
       this.module
     )
-    const applicationIdToWorkerIdMap: ApplicationIdToWorkerIdMap = await fillOpeningPromise
+    const applicationIdToWorkerIdMap: ApplicationIdToWorkerIdMap = this.api.expectOpeningFilledEvent(result.events)
 
     // Assertions
     applicationIdToWorkerIdMap.forEach(async (workerId, applicationId) => {
@@ -399,12 +400,7 @@ export class FillOpeningFixture implements Fixture {
         `Role account ids does not match, worker account: ${worker.role_account_id}, application account ${application.role_account_id}`
       )
     })
-    const openingWorkersAccounts: string[] = (await this.api.getWorkers(this.module)).map((worker) =>
-      worker.role_account_id.toString()
-    )
-    this.membersKeyPairs.forEach((keyPair) =>
-      assert(openingWorkersAccounts.includes(keyPair.address), `Account ${keyPair.address} is not worker`)
-    )
+
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -442,21 +438,20 @@ export class FillLeaderOpeningFixture implements Fixture {
   }
 
   public async runner(expectFailure: boolean): Promise<void> {
-    const applicationIds: ApplicationId[] = (
-      await Promise.all(
-        this.membersKeyPairs.map(async (keypair) =>
-          this.api.getActiveApplicationsIdsByRoleAccount(keypair.address, this.module)
-        )
-      )
-    ).flat()
+    // const applicationIds: ApplicationId[] = (
+    //   await Promise.all(
+    //     this.membersKeyPairs.map(async (keypair) =>
+    //       this.api.getActiveApplicationsIdsByRoleAccount(keypair.address, this.module)
+    //     )
+    //   )
+    // ).flat()
 
     // Fill leader opening
     const now: BN = await this.api.getBestBlock()
-    const fillOpeningPromise: Promise<ApplicationIdToWorkerIdMap> = this.api.expectOpeningFilled()
-    await this.api.sudoFillOpening(
+    const result = await this.api.sudoFillOpening(
       this.sudo,
       this.openingId,
-      applicationIds,
+      [], // applicationIds, // FIXME
       this.amountPerPayout,
       now.add(this.firstPayoutInterval),
       this.payoutInterval,
@@ -464,7 +459,7 @@ export class FillLeaderOpeningFixture implements Fixture {
     )
 
     // Assertions
-    const applicationIdToWorkerIdMap: ApplicationIdToWorkerIdMap = await fillOpeningPromise
+    const applicationIdToWorkerIdMap = this.api.expectOpeningFilledEvent(result.events)
     applicationIdToWorkerIdMap.forEach(async (workerId, applicationId) => {
       const worker: Worker = await this.api.getWorkerById(workerId, this.module)
       const application: Application = await this.api.getApplicationById(applicationId, this.module)
@@ -489,13 +484,13 @@ export class FillLeaderOpeningFixture implements Fixture {
 
 export class IncreaseStakeFixture implements Fixture {
   private api: Api
-  private membersKeyPairs: KeyringPair[]
+  private workerId: WorkerId
   private treasury: KeyringPair
   private module: WorkingGroups
 
-  constructor(api: Api, membersKeyPairs: KeyringPair[], treasury: KeyringPair, module: WorkingGroups) {
+  constructor(api: Api, workerId: WorkerId, treasury: KeyringPair, module: WorkingGroups) {
     this.api = api
-    this.membersKeyPairs = membersKeyPairs
+    this.workerId = workerId
     this.treasury = treasury
     this.module = module
   }
@@ -564,20 +559,14 @@ export class UpdateRewardAccountFixture implements Fixture {
 
 export class UpdateRoleAccountFixture implements Fixture {
   private api: Api
-  private membersKeyPairs: KeyringPair[]
+  private workerId: WorkerId
   private keyring: Keyring
   private treasury: KeyringPair
   private module: WorkingGroups
 
-  constructor(
-    api: Api,
-    membersKeyPairs: KeyringPair[],
-    keyring: Keyring,
-    treasury: KeyringPair,
-    module: WorkingGroups
-  ) {
+  constructor(api: Api, workerId: WorkerId, keyring: Keyring, treasury: KeyringPair, module: WorkingGroups) {
     this.api = api
-    this.membersKeyPairs = membersKeyPairs
+    this.workerId = workerId
     this.keyring = keyring
     this.treasury = treasury
     this.module = module
@@ -586,19 +575,19 @@ export class UpdateRoleAccountFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
     const updateRoleAccountFee: BN = this.api.estimateUpdateRoleAccountFee(this.treasury.address, this.module)
-    await this.api.transferBalance(this.treasury, this.membersKeyPairs[0].address, updateRoleAccountFee)
-    const workerId: WorkerId = await this.api.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const worker = await this.api.getWorkerById(this.workerId, this.module)
+    await this.api.transferBalance(this.treasury, worker.role_account_id.toString(), updateRoleAccountFee)
+    const workerKey = this.keyring.getPair(worker.role_account_id.toString())
 
     // Update role account
     const createdAccount: KeyringPair = this.keyring.addFromUri(uuid().substring(0, 8))
-    await this.api.updateRoleAccount(this.membersKeyPairs[0], workerId, createdAccount.address, this.module)
-    const newRoleAccount: string = (await this.api.getWorkerById(workerId, this.module)).role_account_id.toString()
+    await this.api.updateRoleAccount(workerKey, this.workerId, createdAccount.address, this.module)
+    const newRoleAccount: string = (await this.api.getWorkerById(this.workerId, this.module)).role_account_id.toString()
     assert(
       newRoleAccount === createdAccount.address,
       `Unexpected role account ${newRoleAccount}, expected ${createdAccount.address}`
     )
 
-    this.membersKeyPairs[0] = createdAccount
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -607,20 +596,14 @@ export class UpdateRoleAccountFixture implements Fixture {
 
 export class TerminateApplicationsFixture implements Fixture {
   private api: Api
-  private membersKeyPairs: KeyringPair[]
+  private workerIds: WorkerId[]
   private lead: KeyringPair
   private treasury: KeyringPair
   private module: WorkingGroups
 
-  constructor(
-    api: Api,
-    membersKeyPairs: KeyringPair[],
-    lead: KeyringPair,
-    treasury: KeyringPair,
-    module: WorkingGroups
-  ) {
+  constructor(api: Api, workerIds: WorkerId[], lead: KeyringPair, treasury: KeyringPair, module: WorkingGroups) {
     this.api = api
-    this.membersKeyPairs = membersKeyPairs
+    this.workerIds = workerIds
     this.lead = lead
     this.treasury = treasury
     this.module = module
@@ -845,6 +828,7 @@ export class AwaitPayoutFixture implements Fixture {
   }
 }
 
+/*
 export class ExpectLeadOpeningAddedFixture implements Fixture {
   private api: Api
 
@@ -1101,3 +1085,4 @@ export class ExpectMintCapacityChangedFixture implements Fixture {
     }
   }
 }
+*/

+ 49 - 51
tests/network-tests/src/scenarios/full.ts

@@ -6,19 +6,19 @@ import Debugger from 'debug'
 
 import creatingMemberships from '../flows/membership/creatingMemberships'
 import councilSetup from '../flows/councilSetup'
-import leaderSetup from '../flows/leaderSetup'
+// import leaderSetup from '../flows/leaderSetup'
 import electionParametersProposal from '../flows/proposals/electionParametersProposal'
-import manageLeaderRole from '../flows/proposals/manageLeaderRole'
+// import manageLeaderRole from '../flows/proposals/manageLeaderRole'
 import spendingProposal from '../flows/proposals/spendingProposal'
 import textProposal from '../flows/proposals/textProposal'
 import validatorCountProposal from '../flows/proposals/validatorCountProposal'
-import workingGroupMintCapacityProposal from '../flows/proposals/workingGroupMintCapacityProposal'
-import atLeastValueBug from '../flows/workingGroup/atLeastValueBug'
-import manageWorkerAsLead from '../flows/workingGroup/manageWorkerAsLead'
-import manageWorkerAsWorker from '../flows/workingGroup/manageWorkerAsWorker'
-import workerApplicaionHappyCase from '../flows/workingGroup/workerApplicationHappyCase'
-import workerApplicationRejectionCase from '../flows/workingGroup/workerApplicationRejectionCase'
-import workerPayout from '../flows/workingGroup/workerPayout'
+// import workingGroupMintCapacityProposal from '../flows/proposals/workingGroupMintCapacityProposal'
+// import atLeastValueBug from '../flows/workingGroup/atLeastValueBug'
+// import manageWorkerAsLead from '../flows/workingGroup/manageWorkerAsLead'
+// import manageWorkerAsWorker from '../flows/workingGroup/manageWorkerAsWorker'
+// import workerApplicaionHappyCase from '../flows/workingGroup/workerApplicationHappyCase'
+// import workerApplicationRejectionCase from '../flows/workingGroup/workerApplicationRejectionCase'
+// import workerPayout from '../flows/workingGroup/workerPayout'
 
 const scenario = async () => {
   const debug = Debugger('scenario:full')
@@ -43,54 +43,52 @@ const scenario = async () => {
   debug('Council')
   await councilSetup(api, env, db)
 
-  // Proposals...
-  debug('Election Parameters')
-  await electionParametersProposal(api, env, db)
-
-  debug('Spending Proposal')
-  await spendingProposal(api, env, db)
-
-  debug('Text Proposal')
-  await textProposal(api, env, db)
-
-  debug('Validator Count Proposal')
-  await validatorCountProposal(api, env, db)
-
-  debug('Working Group (Storage) Mint Capacity Proposal')
-  await workingGroupMintCapacityProposal(api, env, db, WorkingGroups.StorageWorkingGroup)
-
-  debug('Working Group (Content) Mint Capacity Proposal')
-  await workingGroupMintCapacityProposal(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  debug('Basic Proposals')
+  await Promise.all([
+    electionParametersProposal(api, env, db),
+    spendingProposal(api, env, db),
+    textProposal(api, env, db),
+    validatorCountProposal(api, env, db),
+    // workingGroupMintCapacityProposal(api, env, db, WorkingGroups.StorageWorkingGroup),
+    // workingGroupMintCapacityProposal(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup),
+  ])
 
   // Test hiring and firing leads by the council throuh proposals
   // Leads are fired at the end of the flows
-  debug('Lead Role (Storage) Proposals')
-  await manageLeaderRole(api, env, db, WorkingGroups.StorageWorkingGroup)
-  debug('Lead Role (Content) Proposals')
-  await manageLeaderRole(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  debug('Lead Hiring through council proposals')
+  await Promise.all([
+    // manageLeaderRole(api, env, db, WorkingGroups.StorageWorkingGroup),
+    // manageLeaderRole(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup),
+  ])
 
   /* workers tests */
 
-  debug('Sudo Hiring Lead (Storage)')
-  await leaderSetup(api, env, db, WorkingGroups.StorageWorkingGroup)
-  await atLeastValueBug(api, env, db)
-
-  debug('Storage Worker Tests')
-  await manageWorkerAsLead(api, env, db, WorkingGroups.StorageWorkingGroup)
-  await manageWorkerAsWorker(api, env, db, WorkingGroups.StorageWorkingGroup)
-  await workerApplicaionHappyCase(api, env, db, WorkingGroups.StorageWorkingGroup)
-  await workerApplicationRejectionCase(api, env, db, WorkingGroups.StorageWorkingGroup)
-  await workerPayout(api, env, db, WorkingGroups.StorageWorkingGroup)
-
-  debug('Sudo Hiring Lead (Content)')
-  await leaderSetup(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
-
-  debug('Content Worker Tests')
-  await manageWorkerAsLead(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
-  await manageWorkerAsWorker(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
-  await workerApplicaionHappyCase(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
-  await workerApplicationRejectionCase(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
-  await workerPayout(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  debug('Sudo Hiring Leads')
+  await Promise.all([
+    // leaderSetup(api, env, db, WorkingGroups.StorageWorkingGroup),
+    // leaderSetup(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup),
+  ])
+
+  // Test bug only on one instance of working group is sufficient
+  // await atLeastValueBug(api, env, db)
+
+  // debug('Worker Tests')
+  // Promise.all([
+  //   async () => {
+  //     await manageWorkerAsLead(api, env, db, WorkingGroups.StorageWorkingGroup)
+  //     await manageWorkerAsWorker(api, env, db, WorkingGroups.StorageWorkingGroup)
+  //     await workerApplicaionHappyCase(api, env, db, WorkingGroups.StorageWorkingGroup)
+  //     await workerApplicationRejectionCase(api, env, db, WorkingGroups.StorageWorkingGroup)
+  //     await workerPayout(api, env, db, WorkingGroups.StorageWorkingGroup)
+  //   },
+  //   async () => {
+  //     await manageWorkerAsLead(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  //     await manageWorkerAsWorker(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  //     await workerApplicaionHappyCase(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  //     await workerApplicationRejectionCase(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  //     await workerPayout(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
+  //   },
+  // ])
 
   // Note: disconnecting and then reconnecting to the chain in the same process
   // doesn't seem to work!

+ 17 - 14
tests/network-tests/src/sender.ts

@@ -1,6 +1,7 @@
-import { ApiPromise } from '@polkadot/api'
+import { ApiPromise, Keyring } from '@polkadot/api'
 import { SubmittableExtrinsic } from '@polkadot/api/types'
 import { ISubmittableResult } from '@polkadot/types/types/'
+import { AccountId } from '@polkadot/types/interfaces'
 import { KeyringPair } from '@polkadot/keyring/types'
 import Debugger from 'debug'
 import AsyncLock from 'async-lock'
@@ -10,12 +11,12 @@ const debug = Debugger('sender')
 export class Sender {
   private readonly api: ApiPromise
   private readonly asyncLock: AsyncLock
+  private readonly keyring: Keyring
 
-  // TODO: add a keyring that is shared here so no need to pass around keys
-
-  constructor(api: ApiPromise) {
+  constructor(api: ApiPromise, keyring: Keyring) {
     this.api = api
     this.asyncLock = new AsyncLock()
+    this.keyring = keyring
   }
 
   // Synchronize all sending of transactions into mempool, so we can always safely read
@@ -24,12 +25,14 @@ export class Sender {
   // Returns a promise that resolves or rejects only after the extrinsic is finalized into a block.
   public async signAndSend(
     tx: SubmittableExtrinsic<'promise'>,
-    account: KeyringPair,
+    account: AccountId | string,
     shouldFail = false
-  ): Promise<any> {
-    let finalizedResolve: { (): void; (value?: any): void }
-    let finalizedReject: { (arg0: Error): void; (reason?: any): void }
-    const finalized = new Promise(async (resolve, reject) => {
+  ): Promise<ISubmittableResult> {
+    const senderKeyPair = this.keyring.getPair(account)
+
+    let finalizedResolve: { (result: ISubmittableResult): void }
+    let finalizedReject: { (err: Error): void }
+    const finalized: Promise<ISubmittableResult> = new Promise(async (resolve, reject) => {
       finalizedResolve = resolve
       finalizedReject = reject
     })
@@ -39,13 +42,13 @@ export class Sender {
         result.events.forEach((event) => {
           if (event.event.method === 'ExtrinsicFailed') {
             if (shouldFail) {
-              finalizedResolve()
+              finalizedResolve(result)
             } else {
               finalizedReject(new Error('Extrinsic failed unexpectedly'))
             }
           }
         })
-        finalizedResolve()
+        finalizedResolve(result)
       }
 
       if (result.status.isFuture) {
@@ -56,9 +59,9 @@ export class Sender {
       }
     }
 
-    await this.asyncLock.acquire(`${account.address}`, async () => {
-      const nonce = await this.api.rpc.system.accountNextIndex(account.address)
-      const signedTx = tx.sign(account, { nonce })
+    await this.asyncLock.acquire(`${senderKeyPair.address}`, async () => {
+      const nonce = await this.api.rpc.system.accountNextIndex(senderKeyPair.address)
+      const signedTx = tx.sign(senderKeyPair, { nonce })
       await signedTx.send(handleEvents)
     })
 

+ 2 - 1
tests/network-tests/tsconfig.json

@@ -11,7 +11,8 @@
     "baseUrl": ".",
     "resolveJsonModule": true,
     "paths": {
-      "@polkadot/types/augment": ["../../types/augment-codec/augment-types.ts"]
+      "@polkadot/types/augment": ["../../types/augment-codec/augment-types.ts"],
+      // "@polkadot/api/augment": [ "../../types/augment-codec/augment-api.ts"]
     }
   }
 }

+ 2 - 7
yarn.lock

@@ -3076,7 +3076,7 @@
     is-ipfs "^0.6.0"
     recursive-fs "^1.1.2"
 
-"@polkadot/api-contract@^1.26.1":
+"@polkadot/api-contract@1.26.1", "@polkadot/api-contract@^1.26.1":
   version "1.26.1"
   resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.26.1.tgz#a8b52ef469ab8bbddb83191f8d451e31ffd76142"
   integrity sha512-zLGA/MHUJf12vanUEUBBRqpHVAONHWztoHS0JTIWUUS2+3GEXk6hGw+7PPtBDfDsLj0LgU/Qna1bLalC/zyl5w==
@@ -6702,12 +6702,7 @@ bluebird@^3.1.1, bluebird@^3.3.5, bluebird@^3.5.1, bluebird@^3.5.3, bluebird@^3.
   resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
   integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
 
-bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.11.8, bn.js@^4.4.0:
-  version "4.11.9"
-  resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828"
-  integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==
-
-bn.js@^5.1.2:
+bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.11.8, bn.js@^4.4.0, bn.js@^5.1.2:
   version "5.1.2"
   resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.2.tgz#c9686902d3c9a27729f43ab10f9d79c2004da7b0"
   integrity sha512-40rZaf3bUNKTVYu9sIeeEGOg7g14Yvnj9kH7b50EiwX0Q7A6umbvfI5tvHaOERH0XigqKkfLkFQxzb4e6CIXnA==