瀏覽代碼

Merge pull request #1125 from gleb-urvanov/feature/alexandria-refactoring-types

Network testing: explicit id types refactoring
Mokhtar Naamani 4 年之前
父節點
當前提交
32ec371a84
共有 22 個文件被更改,包括 694 次插入850 次删除
  1. 2 1
      tests/network-tests/src/iznik/tests/council/electingCouncilTest.ts
  2. 5 4
      tests/network-tests/src/iznik/tests/fixtures/membershipModule.ts
  3. 60 61
      tests/network-tests/src/iznik/tests/fixtures/proposalsModule.ts
  4. 97 68
      tests/network-tests/src/iznik/tests/fixtures/workingGroupModule.ts
  5. 2 1
      tests/network-tests/src/iznik/tests/membership/membershipCreationTest.ts
  6. 2 1
      tests/network-tests/src/iznik/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts
  7. 2 1
      tests/network-tests/src/iznik/tests/proposals/electionParametersProposalTest.ts
  8. 14 11
      tests/network-tests/src/iznik/tests/proposals/manageLeaderRoleTest.ts
  9. 2 1
      tests/network-tests/src/iznik/tests/proposals/setLeadProposalTest.ts
  10. 2 1
      tests/network-tests/src/iznik/tests/proposals/spendingProposalTest.ts
  11. 2 1
      tests/network-tests/src/iznik/tests/proposals/textProposalTest.ts
  12. 2 1
      tests/network-tests/src/iznik/tests/proposals/updateRuntime.ts
  13. 2 1
      tests/network-tests/src/iznik/tests/proposals/validatorCountProposalTest.ts
  14. 4 2
      tests/network-tests/src/iznik/tests/proposals/workingGroupMintCapacityProposalTest.ts
  15. 6 4
      tests/network-tests/src/iznik/tests/workingGroup/atLeastValueBugTest.ts
  16. 12 11
      tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsLeadTest.ts
  17. 9 7
      tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsWorkerTest.ts
  18. 10 8
      tests/network-tests/src/iznik/tests/workingGroup/workerApplicationHappyCaseTest.ts
  19. 10 8
      tests/network-tests/src/iznik/tests/workingGroup/workerApplicationRejectionCaseTest.ts
  20. 11 8
      tests/network-tests/src/iznik/tests/workingGroup/workerPayoutTest.ts
  21. 232 228
      tests/network-tests/src/iznik/utils/apiWrapper.ts
  22. 206 421
      yarn.lock

+ 2 - 1
tests/network-tests/src/iznik/tests/council/electingCouncilTest.ts

@@ -10,6 +10,7 @@ import { closeApi } from '../../utils/closeApi'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { Utils } from '../../utils/utils'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Electing council scenario', async () => {
   initConfig()
@@ -25,7 +26,7 @@ tap.mocha.describe('Electing council scenario', async () => {
   const N: number = +process.env.MEMBERSHIP_CREATION_N!
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 5 - 4
tests/network-tests/src/iznik/tests/fixtures/membershipModule.ts

@@ -3,14 +3,15 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'
 import { Fixture } from './interfaces/fixture'
+import { PaidTermId } from '@nicaea/types/members'
 
 export class BuyMembershipHappyCaseFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private sudo: KeyringPair
   private keyPairs: KeyringPair[]
-  private paidTerms: number
+  private paidTerms: PaidTermId
 
-  public constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, keyPairs: KeyringPair[], paidTerms: number) {
+  public constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, keyPairs: KeyringPair[], paidTerms: PaidTermId) {
     this.apiWrapper = apiWrapper
     this.sudo = sudo
     this.keyPairs = keyPairs
@@ -58,9 +59,9 @@ export class BuyMembershipWithInsufficienFundsFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private sudo: KeyringPair
   private aKeyPair: KeyringPair
-  private paidTerms: number
+  private paidTerms: PaidTermId
 
-  public constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, aKeyPair: KeyringPair, paidTerms: number) {
+  public constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, aKeyPair: KeyringPair, paidTerms: PaidTermId) {
     this.apiWrapper = apiWrapper
     this.sudo = sudo
     this.aKeyPair = aKeyPair

+ 60 - 61
tests/network-tests/src/iznik/tests/fixtures/proposalsModule.ts

@@ -2,7 +2,7 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { v4 as uuid } from 'uuid'
 import BN from 'bn.js'
-import { FillOpeningParameters } from '@alexandria/types/proposals'
+import { FillOpeningParameters, ProposalId } from '@alexandria/types/proposals'
 import { Fixture } from './interfaces/fixture'
 import { Bytes, Option, u32 } from '@polkadot/types'
 import { Balance, BlockNumber } from '@polkadot/types/interfaces'
@@ -14,7 +14,7 @@ import {
   OpeningId,
   StakingPolicy,
 } from '@alexandria/types/hiring'
-import { RewardPolicy, SlashingTerms, WorkingGroupOpeningPolicyCommitment } from '@alexandria/types/working-group'
+import { RewardPolicy, SlashingTerms, WorkerId, WorkingGroupOpeningPolicyCommitment } from '@alexandria/types/working-group'
 import { WorkingGroup } from '@alexandria/types/common'
 
 export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
@@ -25,7 +25,7 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
   private roleStake: BN
   private workingGroup: string
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -43,7 +43,7 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -92,7 +92,7 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
     })
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeCreateWorkingGroupLeaderOpening(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -103,8 +103,7 @@ export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {
       uuid().substring(0, 8),
       this.workingGroup
     )
-    const proposalNumber: BN = await proposalPromise
-    this.result = proposalNumber
+    this.result = await proposalPromise
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -115,16 +114,16 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
   private apiWrapper: ApiWrapper
   private m1KeyPairs: KeyringPair[]
   private sudo: KeyringPair
-  private openingId: BN
+  private openingId: OpeningId
   private workingGroup: string
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
     m1KeyPairs: KeyringPair[],
     sudo: KeyringPair,
-    openingId: BN,
+    openingId: OpeningId,
     workingGroup: string
   ) {
     this.apiWrapper = apiWrapper
@@ -134,7 +133,7 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -149,7 +148,7 @@ export class BeginWorkingGroupLeaderApplicationReviewFixture implements Fixture
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeBeginWorkingGroupLeaderApplicationReview(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -173,10 +172,10 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
   private firstRewardInterval: BN
   private rewardInterval: BN
   private payoutAmount: BN
-  private openingId: BN
+  private openingId: OpeningId
   private workingGroup: WorkingGroups
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -186,7 +185,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
     firstRewardInterval: BN,
     rewardInterval: BN,
     payoutAmount: BN,
-    openingId: BN,
+    openingId: OpeningId,
     workingGroup: WorkingGroups
   ) {
     this.apiWrapper = apiWrapper
@@ -200,7 +199,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -219,7 +218,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
     const applicationId: BN = (
       await this.apiWrapper.getActiveApplicationsIdsByRoleAccount(this.applicantRoleAccountAddress, this.workingGroup)
     )[0]
-    const now = await this.apiWrapper.getBestBlock()
+    const now: BN = await this.apiWrapper.getBestBlock()
 
     const fillOpeningParameters: FillOpeningParameters = new FillOpeningParameters({
       opening_id: this.openingId as OpeningId,
@@ -235,7 +234,7 @@ export class FillLeaderOpeningProposalFixture implements Fixture {
       working_group: new WorkingGroup(workingGroupString),
     })
 
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeFillLeaderOpening(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -258,7 +257,7 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
   private slash: boolean
   private workingGroup: WorkingGroups
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -276,7 +275,7 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -286,7 +285,7 @@ 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.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
       this.leaderRoleAccountAddress,
       this.workingGroup
     )
@@ -297,7 +296,7 @@ export class TerminateLeaderRoleProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeTerminateLeaderRole(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -322,7 +321,7 @@ export class SetLeaderRewardProposalFixture implements Fixture {
   private payoutAmount: BN
   private workingGroup: WorkingGroups
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -338,7 +337,7 @@ export class SetLeaderRewardProposalFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -347,7 +346,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.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: BN = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
+    const workerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
@@ -355,7 +354,7 @@ export class SetLeaderRewardProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeLeaderReward(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -379,7 +378,7 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
   private stakeDecrement: BN
   private workingGroup: WorkingGroups
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -395,7 +394,7 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -404,7 +403,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.apiWrapper.getWorkingGroupString(this.workingGroup)
-    const workerId: BN = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
+    const workerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
@@ -412,7 +411,7 @@ export class DecreaseLeaderStakeProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeDecreaseLeaderStake(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -436,7 +435,7 @@ export class SlashLeaderProposalFixture implements Fixture {
   private slashAmount: BN
   private workingGroup: WorkingGroups
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -452,7 +451,7 @@ export class SlashLeaderProposalFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -461,7 +460,7 @@ export class SlashLeaderProposalFixture implements Fixture {
     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: BN = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
+    const workerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.workingGroup))!
 
     // Proposal stake calculation
     const proposalStake: BN = new BN(50000)
@@ -469,7 +468,7 @@ export class SlashLeaderProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeSlashLeaderStake(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -493,7 +492,7 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
   private mintCapacity: BN
   private workingGroup: WorkingGroups
 
-  private result: BN | undefined
+  private result: ProposalId | undefined
 
   constructor(
     apiWrapper: ApiWrapper,
@@ -509,7 +508,7 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
     this.workingGroup = workingGroup
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ProposalId | undefined {
     return this.result
   }
 
@@ -525,7 +524,7 @@ export class WorkingGroupMintCapacityProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeWorkingGroupMintCapacity(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -595,7 +594,7 @@ 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 = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeElectionParameters(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -610,10 +609,10 @@ export class ElectionParametersProposalFixture implements Fixture {
       proposedMinCouncilStake,
       proposedMinVotingStake
     )
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving the proposal
-    const proposalExecutionPromise = this.apiWrapper.expectProposalFinalized()
+    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await proposalExecutionPromise
 
@@ -695,12 +694,12 @@ export class SetLeadProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, proposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeLead(this.m1KeyPairs[0], proposalTitle, description, proposalStake, this.m1KeyPairs[1])
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving the proposal
-    const proposalExecutionPromise = this.apiWrapper.expectProposalFinalized()
+    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await proposalExecutionPromise
     const newLead: string = await this.apiWrapper.getCurrentLeadAddress()
@@ -757,7 +756,7 @@ export class SpendingProposalFixture implements Fixture {
     await this.apiWrapper.sudoSetCouncilMintCapacity(this.sudo, this.mintCapacity)
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeSpending(
       this.m1KeyPairs[0],
       'testing spending' + uuid().substring(0, 8),
@@ -766,11 +765,11 @@ export class SpendingProposalFixture implements Fixture {
       this.spendingBalance,
       this.sudo.address
     )
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving spending proposal
     const balanceBeforeMinting: BN = await this.apiWrapper.getBalance(this.sudo.address)
-    const spendingPromise = this.apiWrapper.expectProposalFinalized()
+    const spendingPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await spendingPromise
     const balanceAfterMinting: BN = await this.apiWrapper.getBalance(this.sudo.address)
@@ -818,12 +817,12 @@ export class TextProposalFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeText(this.m1KeyPairs[0], proposalStake, proposalTitle, description, proposalText)
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving text proposal
-    const textProposalPromise = this.apiWrapper.expectProposalFinalized()
+    const textProposalPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await textProposalPromise
     if (expectFailure) {
@@ -868,7 +867,7 @@ export class ValidatorCountProposalFixture implements Fixture {
 
     // Proposal creation
     const proposedValidatorCount: BN = validatorCount.add(this.validatorCountIncrement)
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeValidatorCount(
       this.m1KeyPairs[0],
       proposalTitle,
@@ -876,10 +875,10 @@ export class ValidatorCountProposalFixture implements Fixture {
       proposalStake,
       proposedValidatorCount
     )
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving the proposal
-    const proposalExecutionPromise = this.apiWrapper.expectProposalFinalized()
+    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await proposalExecutionPromise
     const newValidatorCount: BN = await this.apiWrapper.getValidatorCount()
@@ -933,7 +932,7 @@ export class ContentWorkingGroupMintCapacityProposalFixture implements Fixture {
 
     // Proposal creation
     const proposedMintingCapacity: BN = initialMintingCapacity.add(this.mintingCapacityIncrement)
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeContentWorkingGroupMintCapacity(
       this.m1KeyPairs[0],
       'testing mint capacity' + uuid().substring(0, 8),
@@ -941,10 +940,10 @@ export class ContentWorkingGroupMintCapacityProposalFixture implements Fixture {
       proposalStake,
       proposedMintingCapacity
     )
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving mint capacity proposal
-    const mintCapacityPromise = this.apiWrapper.expectProposalFinalized()
+    const mintCapacityPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await mintCapacityPromise
     const newMintingCapacity: BN = await this.apiWrapper.getContentWorkingGroupMintCapacity()
@@ -989,7 +988,7 @@ export class UpdateRuntimeFixture implements Fixture {
     await this.apiWrapper.transferBalanceToAccounts(this.sudo, this.m2KeyPairs, runtimeVoteFee)
 
     // Proposal creation
-    const proposalPromise = this.apiWrapper.expectProposalCreated()
+    const proposalPromise: Promise<ProposalId> = this.apiWrapper.expectProposalCreated()
     await this.apiWrapper.proposeRuntime(
       this.m1KeyPairs[0],
       proposalStake,
@@ -997,10 +996,10 @@ export class UpdateRuntimeFixture implements Fixture {
       'runtime to test proposal functionality' + uuid().substring(0, 8),
       runtime
     )
-    const proposalNumber = await proposalPromise
+    const proposalNumber: ProposalId = await proposalPromise
 
     // Approving runtime update proposal
-    const runtimePromise = this.apiWrapper.expectProposalFinalized()
+    const runtimePromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, proposalNumber)
     await runtimePromise
     if (expectFailure) {
@@ -1013,9 +1012,9 @@ export class VoteForProposalFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private m2KeyPairs: KeyringPair[]
   private sudo: KeyringPair
-  private proposalNumber: BN
+  private proposalNumber: ProposalId
 
-  constructor(apiWrapper: ApiWrapper, m2KeyPairs: KeyringPair[], sudo: KeyringPair, proposalNumber: BN) {
+  constructor(apiWrapper: ApiWrapper, m2KeyPairs: KeyringPair[], sudo: KeyringPair, proposalNumber: ProposalId) {
     this.apiWrapper = apiWrapper
     this.m2KeyPairs = m2KeyPairs
     this.sudo = sudo
@@ -1027,7 +1026,7 @@ export class VoteForProposalFixture implements Fixture {
     await this.apiWrapper.transferBalanceToAccounts(this.sudo, this.m2KeyPairs, proposalVoteFee)
 
     // Approving the proposal
-    const proposalExecutionPromise = this.apiWrapper.expectProposalFinalized()
+    const proposalExecutionPromise: Promise<void> = this.apiWrapper.expectProposalFinalized()
     await this.apiWrapper.batchApproveProposal(this.m2KeyPairs, this.proposalNumber)
     await proposalExecutionPromise
     if (expectFailure) {

+ 97 - 68
tests/network-tests/src/iznik/tests/fixtures/workingGroupModule.ts

@@ -12,13 +12,16 @@ import {
   ApplicationIdToWorkerIdMap,
   SlashingTerms,
   Worker,
+  WorkerId,
   WorkingGroupOpeningPolicyCommitment,
 } from '@alexandria/types/working-group'
 import { Utils } from '../../utils/utils'
 import {
   ActivateOpeningAt,
+  ApplicationId,
   ApplicationRationingPolicy,
   Opening as HiringOpening,
+  OpeningId,
   StakingPolicy,
 } from '@alexandria/types/hiring'
 import { Fixture } from './interfaces/fixture'
@@ -34,9 +37,9 @@ export class AddWorkerOpeningFixture implements Fixture {
   private unstakingPeriod: BN
   private module: WorkingGroups
 
-  private result: BN | undefined
+  private result: OpeningId | undefined
 
-  public getResult(): BN | undefined {
+  public getResult(): OpeningId | undefined {
     return this.result
   }
 
@@ -123,8 +126,7 @@ export class AddWorkerOpeningFixture implements Fixture {
       expectFailure
     )
     if (!expectFailure) {
-      const openingId: BN = ((await addOpeningPromise).data[0] as unknown) as BN
-      console.log('received opening id ' + openingId)
+      const openingId: OpeningId = (await addOpeningPromise).data[0] as OpeningId
       this.result = openingId
     }
   }
@@ -139,9 +141,9 @@ export class AddLeaderOpeningFixture implements Fixture {
   private activationDelay: BN
   private module: WorkingGroups
 
-  private result: BN | undefined
+  private result: OpeningId | undefined
 
-  public getResult(): BN | undefined {
+  public getResult(): OpeningId | undefined {
     return this.result
   }
 
@@ -211,8 +213,7 @@ export class AddLeaderOpeningFixture implements Fixture {
       'Leader',
       this.module
     )
-    const openingId: BN = ((await addOpeningPromise).data[0] as unknown) as BN
-    this.result = openingId
+    this.result = (await addOpeningPromise).data[0] as OpeningId
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -223,14 +224,14 @@ export class AcceptApplicationsFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private lead: KeyringPair
   private sudo: KeyringPair
-  private openingId: BN
+  private openingId: OpeningId
   private module: WorkingGroups
 
   public constructor(
     apiWrapper: ApiWrapper,
     lead: KeyringPair,
     sudo: KeyringPair,
-    openingId: BN,
+    openingId: OpeningId,
     module: WorkingGroups
   ) {
     this.apiWrapper = apiWrapper
@@ -242,7 +243,7 @@ export class AcceptApplicationsFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const acceptApplicationsFee = this.apiWrapper.estimateAcceptApplicationsFee(this.module)
+    const acceptApplicationsFee: BN = this.apiWrapper.estimateAcceptApplicationsFee(this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.lead.address, acceptApplicationsFee)
 
     // Begin accepting applications
@@ -262,7 +263,7 @@ export class ApplyForOpeningFixture implements Fixture {
   private sudo: KeyringPair
   private applicationStake: BN
   private roleStake: BN
-  private openingId: BN
+  private openingId: OpeningId
   private module: WorkingGroups
 
   public constructor(
@@ -271,7 +272,7 @@ export class ApplyForOpeningFixture implements Fixture {
     sudo: KeyringPair,
     applicationStake: BN,
     roleStake: BN,
-    openingId: BN,
+    openingId: OpeningId,
     module: WorkingGroups
   ) {
     this.apiWrapper = apiWrapper
@@ -327,7 +328,7 @@ export class WithdrawApplicationFixture implements Fixture {
 
     // Assertions
     this.membersKeyPairs.forEach(async (keyPair) => {
-      const activeApplications: BN[] = await this.apiWrapper.getActiveApplicationsIdsByRoleAccount(
+      const activeApplications: ApplicationId[] = await this.apiWrapper.getActiveApplicationsIdsByRoleAccount(
         keyPair.address,
         this.module
       )
@@ -343,10 +344,16 @@ export class BeginApplicationReviewFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private lead: KeyringPair
   private sudo: KeyringPair
-  private openingId: BN
+  private openingId: OpeningId
   private module: WorkingGroups
 
-  constructor(apiWrapper: ApiWrapper, lead: KeyringPair, sudo: KeyringPair, openingId: BN, module: WorkingGroups) {
+  constructor(
+    apiWrapper: ApiWrapper,
+    lead: KeyringPair,
+    sudo: KeyringPair,
+    openingId: OpeningId,
+    module: WorkingGroups
+  ) {
     this.apiWrapper = apiWrapper
     this.lead = lead
     this.sudo = sudo
@@ -360,7 +367,7 @@ export class BeginApplicationReviewFixture implements Fixture {
     await this.apiWrapper.transferBalance(this.sudo, this.lead.address, beginReviewFee)
 
     // Begin application review
-    const beginApplicantReviewPromise: Promise<BN> = this.apiWrapper.expectApplicationReviewBegan()
+    const beginApplicantReviewPromise: Promise<ApplicationId> = this.apiWrapper.expectApplicationReviewBegan()
     await this.apiWrapper.beginApplicantReview(this.lead, this.openingId, this.module)
     await beginApplicantReviewPromise
     if (expectFailure) {
@@ -372,10 +379,10 @@ export class BeginApplicationReviewFixture implements Fixture {
 export class BeginLeaderApplicationReviewFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private sudo: KeyringPair
-  private openingId: BN
+  private openingId: OpeningId
   private module: WorkingGroups
 
-  constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, openingId: BN, module: WorkingGroups) {
+  constructor(apiWrapper: ApiWrapper, sudo: KeyringPair, openingId: OpeningId, module: WorkingGroups) {
     this.apiWrapper = apiWrapper
     this.sudo = sudo
     this.openingId = openingId
@@ -396,7 +403,7 @@ export class FillOpeningFixture implements Fixture {
   private membersKeyPairs: KeyringPair[]
   private lead: KeyringPair
   private sudo: KeyringPair
-  private openingId: BN
+  private openingId: OpeningId
   private firstPayoutInterval: BN
   private payoutInterval: BN
   private amountPerPayout: BN
@@ -407,7 +414,7 @@ export class FillOpeningFixture implements Fixture {
     membersKeyPairs: KeyringPair[],
     lead: KeyringPair,
     sudo: KeyringPair,
-    openingId: BN,
+    openingId: OpeningId,
     firstPayoutInterval: BN,
     payoutInterval: BN,
     amountPerPayout: BN,
@@ -426,9 +433,9 @@ export class FillOpeningFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const beginReviewFee: BN = this.apiWrapper.estimateBeginApplicantReviewFee(this.module)
+    const beginReviewFee: BN = this.apiWrapper.estimateFillOpeningFee(this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.lead.address, beginReviewFee)
-    const applicationIds: BN[] = (
+    const applicationIds: ApplicationId[] = (
       await Promise.all(
         this.membersKeyPairs.map(async (keypair) =>
           this.apiWrapper.getActiveApplicationsIdsByRoleAccount(keypair.address, this.module)
@@ -475,7 +482,7 @@ export class FillLeaderOpeningFixture implements Fixture {
   private apiWrapper: ApiWrapper
   private membersKeyPairs: KeyringPair[]
   private sudo: KeyringPair
-  private openingId: BN
+  private openingId: OpeningId
   private firstPayoutInterval: BN
   private payoutInterval: BN
   private amountPerPayout: BN
@@ -485,7 +492,7 @@ export class FillLeaderOpeningFixture implements Fixture {
     apiWrapper: ApiWrapper,
     membersKeyPairs: KeyringPair[],
     sudo: KeyringPair,
-    openingId: BN,
+    openingId: OpeningId,
     firstPayoutInterval: BN,
     payoutInterval: BN,
     amountPerPayout: BN,
@@ -502,7 +509,7 @@ export class FillLeaderOpeningFixture implements Fixture {
   }
 
   public async runner(expectFailure: boolean): Promise<void> {
-    const applicationIds: BN[] = (
+    const applicationIds: ApplicationId[] = (
       await Promise.all(
         this.membersKeyPairs.map(async (keypair) =>
           this.apiWrapper.getActiveApplicationsIdsByRoleAccount(keypair.address, this.module)
@@ -533,7 +540,7 @@ export class FillLeaderOpeningFixture implements Fixture {
         `Role account ids does not match, leader account: ${worker.role_account_id}, application account ${application.role_account_id}`
       )
     })
-    const leadWorkerId: BN = (await this.apiWrapper.getLeadWorkerId(this.module))!
+    const leadWorkerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.module))!
     const openingLeaderAccount: string = (
       await this.apiWrapper.getWorkerById(leadWorkerId, this.module)
     ).role_account_id.toString()
@@ -569,7 +576,10 @@ export class IncreaseStakeFixture implements Fixture {
       this.membersKeyPairs[0].address,
       increaseStakeFee.add(stakeIncrement)
     )
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
 
     // Increase worker stake
     const increasedWorkerStake: BN = (await this.apiWrapper.getWorkerStakeAmount(workerId, this.module)).add(
@@ -612,7 +622,10 @@ export class UpdateRewardAccountFixture implements Fixture {
     // Fee estimation and transfer
     const updateRewardAccountFee: BN = this.apiWrapper.estimateUpdateRewardAccountFee(this.sudo.address, this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.membersKeyPairs[0].address, updateRewardAccountFee)
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
 
     // Update reward account
     const createdAccount: KeyringPair = this.keyring.addFromUri(uuid().substring(0, 8))
@@ -653,7 +666,10 @@ export class UpdateRoleAccountFixture implements Fixture {
     // Fee estimation and transfer
     const updateRoleAccountFee: BN = this.apiWrapper.estimateUpdateRoleAccountFee(this.sudo.address, this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.membersKeyPairs[0].address, updateRoleAccountFee)
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
 
     // Update role account
     const createdAccount: KeyringPair = this.keyring.addFromUri(uuid().substring(0, 8))
@@ -696,7 +712,7 @@ export class TerminateApplicationsFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const terminateApplicationFee = this.apiWrapper.estimateTerminateApplicationFee(this.module)
+    const terminateApplicationFee: BN = this.apiWrapper.estimateTerminateApplicationFee(this.module)
     await this.apiWrapper.transferBalance(
       this.sudo,
       this.lead.address,
@@ -706,7 +722,7 @@ export class TerminateApplicationsFixture implements Fixture {
     // Terminate worker applications
     await this.apiWrapper.batchTerminateApplication(this.lead, this.membersKeyPairs, this.module)
     this.membersKeyPairs.forEach(async (keyPair) => {
-      const activeApplications = await this.apiWrapper.getActiveApplicationsIdsByRoleAccount(
+      const activeApplications: ApplicationId[] = await this.apiWrapper.getActiveApplicationsIdsByRoleAccount(
         keyPair.address,
         this.module
       )
@@ -741,10 +757,13 @@ export class DecreaseStakeFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const decreaseStakeFee = this.apiWrapper.estimateDecreaseStakeFee(this.module)
+    const decreaseStakeFee: BN = this.apiWrapper.estimateDecreaseStakeFee(this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.lead.address, decreaseStakeFee)
-    const workerStakeDecrement = new BN(1)
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const workerStakeDecrement: BN = new BN(1)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
 
     // Worker stake decrement
     const decreasedWorkerStake: BN = (await this.apiWrapper.getWorkerStakeAmount(workerId, this.module)).sub(
@@ -786,10 +805,13 @@ export class SlashFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const slashStakeFee = this.apiWrapper.estimateSlashStakeFee(this.module)
+    const slashStakeFee: BN = this.apiWrapper.estimateSlashStakeFee(this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.lead.address, slashStakeFee)
-    const slashAmount = new BN(1)
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const slashAmount: BN = new BN(1)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
 
     // Slash worker
     const slashedStake: BN = (await this.apiWrapper.getWorkerStakeAmount(workerId, this.module)).sub(slashAmount)
@@ -824,16 +846,22 @@ export class TerminateRoleFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const terminateRoleFee = this.apiWrapper.estimateTerminateRoleFee(this.module)
+    const terminateRoleFee: BN = this.apiWrapper.estimateTerminateRoleFee(this.module)
     await this.apiWrapper.transferBalance(this.sudo, this.lead.address, terminateRoleFee)
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
 
     // Slash worker
     await this.apiWrapper.terminateRole(this.lead, workerId, uuid().substring(0, 8), this.module, expectFailure)
 
     // Assertions
     this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
-    const newWorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const newWorkerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
     assert(newWorkerId === undefined, `Worker with account ${this.membersKeyPairs[0].address} is not terminated`)
   }
 }
@@ -853,7 +881,7 @@ export class LeaveRoleFixture implements Fixture {
 
   public async runner(expectFailure: boolean): Promise<void> {
     // Fee estimation and transfer
-    const leaveRoleFee = this.apiWrapper.estimateLeaveRoleFee(this.module)
+    const leaveRoleFee: BN = this.apiWrapper.estimateLeaveRoleFee(this.module)
     await this.apiWrapper.transferBalanceToAccounts(this.sudo, this.membersKeyPairs, leaveRoleFee)
 
     await this.apiWrapper.batchLeaveRole(this.membersKeyPairs, uuid().substring(0, 8), expectFailure, this.module)
@@ -861,7 +889,7 @@ export class LeaveRoleFixture implements Fixture {
     // Assertions
     this.membersKeyPairs.forEach(async (keyPair) => {
       this.apiWrapper.getWorkerIdByRoleAccount(keyPair.address, this.module)
-      const newWorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(keyPair.address, this.module)
+      const newWorkerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(keyPair.address, this.module)
       assert(newWorkerId === undefined, `Worker with account ${keyPair.address} is not terminated`)
     })
   }
@@ -879,7 +907,10 @@ export class AwaitPayoutFixture implements Fixture {
   }
 
   public async runner(expectFailure: boolean): Promise<void> {
-    const workerId: BN = await this.apiWrapper.getWorkerIdByRoleAccount(this.membersKeyPairs[0].address, this.module)
+    const workerId: WorkerId = await this.apiWrapper.getWorkerIdByRoleAccount(
+      this.membersKeyPairs[0].address,
+      this.module
+    )
     const worker: Worker = await this.apiWrapper.getWorkerById(workerId, this.module)
     const reward: RewardRelationship = await this.apiWrapper.getRewardRelationship(worker.reward_relationship.unwrap())
     const now: BN = await this.apiWrapper.getBestBlock()
@@ -888,23 +919,23 @@ export class AwaitPayoutFixture implements Fixture {
     const amountPerPayout: BN = new BN(reward.getField('amount_per_payout').toString())
 
     assert(now.lt(nextPaymentBlock), `Payout already happened in block ${nextPaymentBlock} now ${now}`)
-    const balance = await this.apiWrapper.getBalance(this.membersKeyPairs[0].address)
+    const balance: BN = await this.apiWrapper.getBalance(this.membersKeyPairs[0].address)
 
-    const firstPayoutWaitingPeriod = nextPaymentBlock.sub(now).addn(1)
+    const firstPayoutWaitingPeriod: BN = nextPaymentBlock.sub(now).addn(1)
     await Utils.wait(this.apiWrapper.getBlockDuration().mul(firstPayoutWaitingPeriod).toNumber())
 
-    const balanceAfterFirstPayout = await this.apiWrapper.getBalance(this.membersKeyPairs[0].address)
-    const expectedBalanceFirst = balance.add(amountPerPayout)
+    const balanceAfterFirstPayout: BN = await this.apiWrapper.getBalance(this.membersKeyPairs[0].address)
+    const expectedBalanceFirst: BN = balance.add(amountPerPayout)
     assert(
       balanceAfterFirstPayout.eq(expectedBalanceFirst),
       `Unexpected balance, expected ${expectedBalanceFirst} got ${balanceAfterFirstPayout}`
     )
 
-    const secondPayoutWaitingPeriod = payoutInterval.addn(1)
+    const secondPayoutWaitingPeriod: BN = payoutInterval.addn(1)
     await Utils.wait(this.apiWrapper.getBlockDuration().mul(secondPayoutWaitingPeriod).toNumber())
 
-    const balanceAfterSecondPayout = await this.apiWrapper.getBalance(this.membersKeyPairs[0].address)
-    const expectedBalanceSecond = expectedBalanceFirst.add(amountPerPayout)
+    const balanceAfterSecondPayout: BN = await this.apiWrapper.getBalance(this.membersKeyPairs[0].address)
+    const expectedBalanceSecond: BN = expectedBalanceFirst.add(amountPerPayout)
     assert(
       balanceAfterSecondPayout.eq(expectedBalanceSecond),
       `Unexpected balance, expected ${expectedBalanceSecond} got ${balanceAfterSecondPayout}`
@@ -918,15 +949,14 @@ export class AwaitPayoutFixture implements Fixture {
 export class ExpectLeadOpeningAddedFixture implements Fixture {
   private apiWrapper: ApiWrapper
 
-  // Opening id
-  private result: BN | undefined
+  private result: OpeningId | undefined
   private events: Event[] = []
 
   constructor(apiWrapper: ApiWrapper) {
     this.apiWrapper = apiWrapper
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): OpeningId | undefined {
     return this.result
   }
 
@@ -937,7 +967,7 @@ export class ExpectLeadOpeningAddedFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('OpeningAdded')
     this.events.push(event)
-    this.result = (event.data as unknown) as BN
+    this.result = (event.data as unknown) as OpeningId
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -949,8 +979,7 @@ export class ExpectLeaderSetFixture implements Fixture {
   private leaderAddress: string
   private module: WorkingGroups
 
-  // Lead worker id
-  private result: BN | undefined
+  private result: WorkerId | undefined
   private events: Event[] = []
 
   constructor(apiWrapper: ApiWrapper, leaderAddress: string, module: WorkingGroups) {
@@ -959,7 +988,7 @@ export class ExpectLeaderSetFixture implements Fixture {
     this.module = module
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): WorkerId | undefined {
     return this.result
   }
 
@@ -970,9 +999,9 @@ export class ExpectLeaderSetFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('LeaderSet')
     this.events.push(event)
-    const leadWorkerId: BN = (event.data as unknown) as BN
+    const leadWorkerId: WorkerId = (event.data as unknown) as WorkerId
     const worker: Worker = await this.apiWrapper.getWorkerById(leadWorkerId, this.module)
-    const leaderApplicationId = (
+    const leaderApplicationId: ApplicationId = (
       await this.apiWrapper.getApplicationsIdsByRoleAccount(this.leaderAddress, this.module)
     )[0]
     const application: Application = await this.apiWrapper.getApplicationById(leaderApplicationId, this.module)
@@ -990,14 +1019,14 @@ export class ExpectLeaderSetFixture implements Fixture {
 export class ExpectBeganApplicationReviewFixture implements Fixture {
   private apiWrapper: ApiWrapper
 
-  private result: BN | undefined
+  private result: ApplicationId | undefined
   private events: Event[] = []
 
   constructor(apiWrapper: ApiWrapper) {
     this.apiWrapper = apiWrapper
   }
 
-  public getResult(): BN | undefined {
+  public getResult(): ApplicationId | undefined {
     return this.result
   }
 
@@ -1008,7 +1037,7 @@ export class ExpectBeganApplicationReviewFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('BeganApplicationReview')
     this.events.push(event)
-    this.result = (event.data as unknown) as BN
+    this.result = (event.data as unknown) as ApplicationId
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
     }
@@ -1038,7 +1067,7 @@ export class ExpectLeaderRoleTerminatedFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('TerminatedLeader')
     this.events.push(event)
-    const leadWorkerId: BN | undefined = await this.apiWrapper.getLeadWorkerId(this.module)
+    const leadWorkerId: WorkerId | undefined = await this.apiWrapper.getLeadWorkerId(this.module)
     assert(leadWorkerId === undefined, `Unexpected lead worker id: ${leadWorkerId}, expected none`)
     if (expectFailure) {
       throw new Error('Successful fixture run while expecting failure')
@@ -1071,7 +1100,7 @@ export class ExpectLeaderRewardAmountUpdatedFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('WorkerRewardAmountUpdated')
     this.events.push(event)
-    const leadWorkerId: BN = (await this.apiWrapper.getLeadWorkerId(this.module))!
+    const leadWorkerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.module))!
     const receivedReward: BN = (await this.apiWrapper.getRewardRelationship(leadWorkerId)).getField<Balance>(
       'amount_per_payout'
     )
@@ -1110,7 +1139,7 @@ export class ExpectLeaderStakeDecreasedFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('StakeDecreased')
     this.events.push(event)
-    const leadWorkerId: BN = (await this.apiWrapper.getLeadWorkerId(this.module))!
+    const leadWorkerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.module))!
     const receivedStake: BN = await this.apiWrapper.getWorkerStakeAmount(leadWorkerId, this.module)
     assert(
       receivedStake.eq(this.expectedStake),
@@ -1147,7 +1176,7 @@ export class ExpectLeaderSlashedFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('StakeSlashed')
     this.events.push(event)
-    const leadWorkerId: BN = (await this.apiWrapper.getLeadWorkerId(this.module))!
+    const leadWorkerId: WorkerId = (await this.apiWrapper.getLeadWorkerId(this.module))!
     const receivedStake: BN = await this.apiWrapper.getWorkerStakeAmount(leadWorkerId, this.module)
     assert(
       receivedStake.eq(this.expectedStake),
@@ -1182,7 +1211,7 @@ export class ExpectMintCapacityChangedFixture implements Fixture {
   public async runner(expectFailure: boolean): Promise<void> {
     const event: Event = await this.apiWrapper.expectEvent('MintCapacityChanged')
     this.events.push(event)
-    const receivedMintCapacity = (event.data[1] as unknown) as BN
+    const receivedMintCapacity: BN = (event.data[1] as unknown) as BN
     assert(
       receivedMintCapacity.eq(this.expectedMintCapacity),
       `Unexpected mint capacity: ${receivedMintCapacity}, expected ${this.expectedMintCapacity}`

+ 2 - 1
tests/network-tests/src/iznik/tests/membership/membershipCreationTest.ts

@@ -8,6 +8,7 @@ import { ApiWrapper } from '../../utils/apiWrapper'
 import { closeApi } from '../../utils/closeApi'
 import { BuyMembershipHappyCaseFixture, BuyMembershipWithInsufficienFundsFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Membership creation scenario', async () => {
   initConfig()
@@ -23,7 +24,7 @@ tap.mocha.describe('Membership creation scenario', async () => {
   const N: number = +process.env.MEMBERSHIP_CREATION_N!
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const aKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
 
   const durationInBlocks = 7
 

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts

@@ -11,6 +11,7 @@ import { ContentWorkingGroupMintCapacityProposalFixture } from '../fixtures/prop
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { Utils } from '../../utils/utils'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Validator count proposal scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Validator count proposal scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/electionParametersProposalTest.ts

@@ -11,6 +11,7 @@ import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { Utils } from '../../utils/utils'
 import { ElectionParametersProposalFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Election parameters proposal scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Election parameters proposal scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 14 - 11
tests/network-tests/src/iznik/tests/proposals/manageLeaderRoleTest.ts

@@ -30,6 +30,9 @@ import {
   ExpectLeadOpeningAddedFixture,
 } from '../fixtures/workingGroupModule'
 import { Utils } from '../../utils/utils'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
+import { ProposalId } from '@nicaea/types/proposals'
 
 tap.mocha.describe('Set lead proposal scenario', async () => {
   initConfig()
@@ -47,7 +50,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
@@ -115,7 +118,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      createWorkingGroupLeaderOpeningFixture.getResult()!
+      createWorkingGroupLeaderOpeningFixture.getResult() as OpeningId
     )
     voteForCreateOpeningProposalFixture.runner(false)
     await expectLeadOpeningAddedFixture.runner(false)
@@ -129,7 +132,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      new BN(expectLeadOpeningAddedFixture.getResult()!),
+      expectLeadOpeningAddedFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -141,7 +144,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m1KeyPairs,
       sudo,
-      new BN(expectLeadOpeningAddedFixture.getResult()!),
+      expectLeadOpeningAddedFixture.getResult() as OpeningId,
       'Storage'
     )
     await beginWorkingGroupLeaderApplicationReviewFixture.runner(false)
@@ -156,7 +159,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      beginWorkingGroupLeaderApplicationReviewFixture.getResult()!
+      beginWorkingGroupLeaderApplicationReviewFixture.getResult() as ProposalId
     )
     voteForBeginReviewProposal.runner(false)
     await expectBeganApplicationReviewFixture.runner(false)
@@ -172,7 +175,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
-      new BN(expectLeadOpeningAddedFixture.getResult()!),
+      expectLeadOpeningAddedFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await fillLeaderOpeningProposalFixture.runner(false)
@@ -189,7 +192,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      fillLeaderOpeningProposalFixture.getResult()!
+      fillLeaderOpeningProposalFixture.getResult() as ProposalId
     )
     voteForFillLeaderProposalFixture.runner(false)
     await expectLeaderSetFixture.runner(false)
@@ -215,7 +218,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      setLeaderRewardProposalFixture.getResult()!
+      setLeaderRewardProposalFixture.getResult() as ProposalId
     )
     voteForeLeaderRewardFixture.runner(false)
     await expectLeaderRewardAmountUpdatedFixture.runner(false)
@@ -239,7 +242,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      decreaseLeaderStakeProposalFixture.getResult()!
+      decreaseLeaderStakeProposalFixture.getResult() as ProposalId
     )
     voteForFillLeaderProposalFixture.runner(false)
     expectLeaderStakeDecreasedFixture = new ExpectLeaderStakeDecreasedFixture(
@@ -267,7 +270,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      slashLeaderProposalFixture.getResult()!
+      slashLeaderProposalFixture.getResult() as ProposalId
     )
     voteForSlashProposalFixture.runner(false)
     expectLeaderSlashedFixture = new ExpectLeaderSlashedFixture(apiWrapper, newStake, WorkingGroups.StorageWorkingGroup)
@@ -294,7 +297,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      terminateLeaderRoleProposalFixture.getResult()!
+      terminateLeaderRoleProposalFixture.getResult() as ProposalId
     )
     voteForLeaderRoleTerminationFixture.runner(false)
     await expectLeaderRoleTerminatedFixture.runner(false)

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/setLeadProposalTest.ts

@@ -11,6 +11,7 @@ import { Utils } from '../../utils/utils'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { SetLeadProposalFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Set lead proposal scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Set lead proposal scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/spendingProposalTest.ts

@@ -11,6 +11,7 @@ import { Utils } from '../../utils/utils'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { SpendingProposalFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Spending proposal scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Spending proposal scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/textProposalTest.ts

@@ -11,6 +11,7 @@ import { Utils } from '../../utils/utils'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { TextProposalFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Text proposal scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Text proposal scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/updateRuntime.ts

@@ -11,6 +11,7 @@ import { Utils } from '../../utils/utils'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { UpdateRuntimeFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Update runtime scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Update runtime scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 2 - 1
tests/network-tests/src/iznik/tests/proposals/validatorCountProposalTest.ts

@@ -11,6 +11,7 @@ import { Utils } from '../../utils/utils'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { ValidatorCountProposalFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
 
 tap.mocha.describe('Validator count proposal scenario', async () => {
   initConfig()
@@ -27,7 +28,7 @@ tap.mocha.describe('Validator count proposal scenario', async () => {
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)

+ 4 - 2
tests/network-tests/src/iznik/tests/proposals/workingGroupMintCapacityProposalTest.ts

@@ -12,6 +12,8 @@ import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
 import { ExpectMintCapacityChangedFixture } from '../fixtures/workingGroupModule'
+import { PaidTermId } from '@nicaea/types/members'
+import { ProposalId } from '@nicaea/types/proposals'
 
 tap.mocha.describe('Set storage working group mint capacity scenario', async () => {
   initConfig()
@@ -28,7 +30,7 @@ tap.mocha.describe('Set storage working group mint capacity scenario', async ()
   const m1KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
@@ -86,7 +88,7 @@ tap.mocha.describe('Set storage working group mint capacity scenario', async ()
       apiWrapper,
       m2KeyPairs,
       sudo,
-      workingGroupMintCapacityProposalFixture.getResult()!
+      workingGroupMintCapacityProposalFixture.getResult() as ProposalId
     )
     voteForProposalFixture.runner(false)
     await expectMintCapacityChanged.runner(false)

+ 6 - 4
tests/network-tests/src/iznik/tests/workingGroup/atLeastValueBugTest.ts

@@ -17,6 +17,8 @@ import BN from 'bn.js'
 import tap from 'tap'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()
@@ -33,7 +35,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
@@ -80,7 +82,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -91,7 +93,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
     beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginLeaderApplicationReviewFixture.runner(false)
@@ -103,7 +105,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,

+ 12 - 11
tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsLeadTest.ts

@@ -11,7 +11,6 @@ import {
   BeginLeaderApplicationReviewFixture,
   FillLeaderOpeningFixture,
   AddWorkerOpeningFixture,
-  WithdrawApplicationFixture,
   BeginApplicationReviewFixture,
   FillOpeningFixture,
   LeaveRoleFixture,
@@ -23,6 +22,8 @@ import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
 import BN from 'bn.js'
 import tap from 'tap'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
 
 tap.mocha.describe('Manage worker as worker scenario', async () => {
   initConfig()
@@ -39,7 +40,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
@@ -86,7 +87,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -97,7 +98,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginLeaderApplicationReviewFixture.runner(false)
@@ -109,7 +110,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
@@ -139,7 +140,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
@@ -151,7 +152,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       apiWrapper,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
@@ -164,7 +165,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       nKeyPairs,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
@@ -209,7 +210,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addNewLeaderOpeningFixture.getResult()!,
+      addNewLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForNewLeaderOpeningFixture.runner(false)
@@ -220,7 +221,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     beginNewLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addNewLeaderOpeningFixture.getResult()!,
+      addNewLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginNewLeaderApplicationReviewFixture.runner(false)
@@ -232,7 +233,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addNewLeaderOpeningFixture.getResult()!,
+      addNewLeaderOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,

+ 9 - 7
tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsWorkerTest.ts

@@ -21,6 +21,8 @@ import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
 import BN from 'bn.js'
 import tap from 'tap'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
 
 tap.mocha.describe('Manage worker as worker scenario', async () => {
   initConfig()
@@ -37,7 +39,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
@@ -84,7 +86,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -95,7 +97,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
     beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginLeaderApplicationReviewFixture.runner(false)
@@ -107,7 +109,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
@@ -137,7 +139,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
@@ -149,7 +151,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       apiWrapper,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
@@ -162,7 +164,7 @@ tap.mocha.describe('Manage worker as worker scenario', async () => {
       nKeyPairs,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,

+ 10 - 8
tests/network-tests/src/iznik/tests/workingGroup/workerApplicationHappyCaseTest.ts

@@ -20,6 +20,8 @@ import {
   LeaveRoleFixture,
   WithdrawApplicationFixture,
 } from '../fixtures/workingGroupModule'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()
@@ -36,7 +38,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   const nKeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
@@ -83,7 +85,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -94,7 +96,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
     beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginLeaderApplicationReviewFixture.runner(false)
@@ -106,7 +108,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
@@ -136,7 +138,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await firstApplyForWorkerOpeningFixture.runner(false)
@@ -158,7 +160,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await secondApplyForWorkerOpeningFixture.runner(false)
@@ -170,7 +172,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
@@ -183,7 +185,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       nKeyPairs,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,

+ 10 - 8
tests/network-tests/src/iznik/tests/workingGroup/workerApplicationRejectionCaseTest.ts

@@ -19,6 +19,8 @@ import {
   LeaveRoleFixture,
   TerminateApplicationsFixture,
 } from '../fixtures/workingGroupModule'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()
@@ -36,7 +38,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
   const nonMemberKeyPairs = Utils.createKeyPairs(keyring, N)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
@@ -84,7 +86,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -95,7 +97,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
     beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginLeaderApplicationReviewFixture.runner(false)
@@ -107,7 +109,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
@@ -137,7 +139,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningBeforeAcceptanceFixture.runner(true)
@@ -149,7 +151,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     acceptApplicationsFixture.runner(false)
@@ -163,7 +165,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningAsNonMemberFixture.runner(true)
@@ -177,7 +179,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)

+ 11 - 8
tests/network-tests/src/iznik/tests/workingGroup/workerPayoutTest.ts

@@ -23,6 +23,9 @@ import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { Utils } from '../../utils/utils'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
+import { PaidTermId } from '@nicaea/types/members'
+import { OpeningId } from '@nicaea/types/hiring'
+import { ProposalId } from '@nicaea/types/proposals'
 
 tap.mocha.describe('Worker application happy case scenario', async () => {
   initConfig()
@@ -40,7 +43,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
   const m2KeyPairs: KeyringPair[] = Utils.createKeyPairs(keyring, N)
   const leadKeyPair: KeyringPair[] = Utils.createKeyPairs(keyring, 1)
 
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
+  const paidTerms: PaidTermId = new PaidTermId(+process.env.MEMBERSHIP_PAID_TERMS!)
   const K: number = +process.env.COUNCIL_ELECTION_K!
   const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
   const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
@@ -112,7 +115,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForLeaderOpeningFixture.runner(false)
@@ -123,7 +126,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
     beginLeaderApplicationReviewFixture = new BeginLeaderApplicationReviewFixture(
       apiWrapper,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginLeaderApplicationReviewFixture.runner(false)
@@ -135,7 +138,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair,
       sudo,
-      addLeaderOpeningFixture.getResult()!,
+      addLeaderOpeningFixture.getResult() as OpeningId,
       leaderFirstRewardInterval,
       leaderRewardInterval,
       payoutAmount,
@@ -163,7 +166,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       m2KeyPairs,
       sudo,
-      workingGroupMintCapacityProposalFixture.getResult()!
+      workingGroupMintCapacityProposalFixture.getResult() as ProposalId
     )
     voteForProposalFixture.runner(false)
     await expectMintCapacityChanged.runner(false)
@@ -190,7 +193,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       sudo,
       applicationStake,
       roleStake,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await applyForWorkerOpeningFixture.runner(false)
@@ -202,7 +205,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       apiWrapper,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       WorkingGroups.StorageWorkingGroup
     )
     await beginApplicationReviewFixture.runner(false)
@@ -215,7 +218,7 @@ tap.mocha.describe('Worker application happy case scenario', async () => {
       m1KeyPairs,
       leadKeyPair[0],
       sudo,
-      addWorkerOpeningFixture.getResult()!,
+      addWorkerOpeningFixture.getResult() as OpeningId,
       firstRewardInterval,
       rewardInterval,
       payoutAmount,

File diff suppressed because it is too large
+ 232 - 228
tests/network-tests/src/iznik/utils/apiWrapper.ts


File diff suppressed because it is too large
+ 206 - 421
yarn.lock


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