소스 검색

integration tests: remove old test and reorg folders

Mokhtar Naamani 4 년 전
부모
커밋
09bad44537
100개의 변경된 파일54개의 추가작업 그리고 7452개의 파일을 삭제
  1. 5 10
      tests/network-tests/package.json
  2. 0 39
      tests/network-tests/src/constantinople/tests/electingCouncilTest.ts
  3. 0 8
      tests/network-tests/src/constantinople/tests/impl/closeApi.ts
  4. 0 100
      tests/network-tests/src/constantinople/tests/impl/electingCouncil.ts
  5. 0 78
      tests/network-tests/src/constantinople/tests/impl/membershipCreation.ts
  6. 0 29
      tests/network-tests/src/constantinople/tests/membershipCreationTest.ts
  7. 0 40
      tests/network-tests/src/constantinople/tests/proposals/evictStorageProviderTest.ts
  8. 0 56
      tests/network-tests/src/constantinople/tests/proposals/impl/evictStoraveProvider.ts
  9. 0 120
      tests/network-tests/src/constantinople/tests/proposals/impl/storageRoleParametersProposal.ts
  10. 0 53
      tests/network-tests/src/constantinople/tests/proposals/impl/updateRuntime.ts
  11. 0 40
      tests/network-tests/src/constantinople/tests/proposals/storageRoleParametersProposalTest.ts
  12. 0 41
      tests/network-tests/src/constantinople/tests/proposals/updateRuntimeTest.ts
  13. 0 644
      tests/network-tests/src/constantinople/utils/apiWrapper.ts
  14. 0 66
      tests/network-tests/src/constantinople/utils/sender.ts
  15. 0 50
      tests/network-tests/src/constantinople/utils/utils.ts
  16. 0 0
      tests/network-tests/src/iznik/tap-parallel-not-ok
  17. 0 5
      tests/network-tests/src/iznik/utils/config.ts
  18. 0 7
      tests/network-tests/src/iznik/utils/setTestTimeout.ts
  19. 0 85
      tests/network-tests/src/nicaea/dto/fillOpeningParameters.ts
  20. 0 255
      tests/network-tests/src/nicaea/dto/workingGroupOpening.ts
  21. 0 0
      tests/network-tests/src/nicaea/tap-parallel-not-ok
  22. 0 38
      tests/network-tests/src/nicaea/tests/electingCouncilTest.ts
  23. 0 8
      tests/network-tests/src/nicaea/tests/impl/closeApi.ts
  24. 0 100
      tests/network-tests/src/nicaea/tests/impl/electingCouncil.ts
  25. 0 86
      tests/network-tests/src/nicaea/tests/impl/membershipCreation.ts
  26. 0 29
      tests/network-tests/src/nicaea/tests/membershipCreationTest.ts
  27. 0 41
      tests/network-tests/src/nicaea/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts
  28. 0 40
      tests/network-tests/src/nicaea/tests/proposals/electionParametersProposalTest.ts
  29. 0 124
      tests/network-tests/src/nicaea/tests/proposals/impl/electionParametersProposal.ts
  30. 0 315
      tests/network-tests/src/nicaea/tests/proposals/impl/proposalsModule.ts
  31. 0 46
      tests/network-tests/src/nicaea/tests/proposals/impl/setLeadProposal.ts
  32. 0 64
      tests/network-tests/src/nicaea/tests/proposals/impl/spendingProposal.ts
  33. 0 46
      tests/network-tests/src/nicaea/tests/proposals/impl/textProposal.ts
  34. 0 52
      tests/network-tests/src/nicaea/tests/proposals/impl/updateRuntime.ts
  35. 0 55
      tests/network-tests/src/nicaea/tests/proposals/impl/validatorCountProposal.ts
  36. 0 59
      tests/network-tests/src/nicaea/tests/proposals/impl/workingGroupMintCapacityProposal.ts
  37. 0 213
      tests/network-tests/src/nicaea/tests/proposals/manageLeaderRole.ts
  38. 0 40
      tests/network-tests/src/nicaea/tests/proposals/setLeadProposalTest.ts
  39. 0 42
      tests/network-tests/src/nicaea/tests/proposals/spendingProposalTest.ts
  40. 0 40
      tests/network-tests/src/nicaea/tests/proposals/textProposalTest.ts
  41. 0 41
      tests/network-tests/src/nicaea/tests/proposals/updateRuntimeTest.ts
  42. 0 41
      tests/network-tests/src/nicaea/tests/proposals/validatorCountProposalTest.ts
  43. 0 63
      tests/network-tests/src/nicaea/tests/proposals/workingGroupMintCapacityProposalTest.ts
  44. 0 130
      tests/network-tests/src/nicaea/tests/workingGroup/atLeastValueBugTest.ts
  45. 0 597
      tests/network-tests/src/nicaea/tests/workingGroup/impl/workingGroupModule.ts
  46. 0 207
      tests/network-tests/src/nicaea/tests/workingGroup/manageWorkerAsLeadTest.ts
  47. 0 159
      tests/network-tests/src/nicaea/tests/workingGroup/manageWorkerAsWorkerTest.ts
  48. 0 160
      tests/network-tests/src/nicaea/tests/workingGroup/workerApplicationHappyCaseTest.ts
  49. 0 160
      tests/network-tests/src/nicaea/tests/workingGroup/workerApplicationRejectionCaseTest.ts
  50. 0 152
      tests/network-tests/src/nicaea/tests/workingGroup/workerPayout.ts
  51. 0 1547
      tests/network-tests/src/nicaea/utils/apiWrapper.ts
  52. 0 5
      tests/network-tests/src/nicaea/utils/config.ts
  53. 0 66
      tests/network-tests/src/nicaea/utils/sender.ts
  54. 0 7
      tests/network-tests/src/nicaea/utils/setTestTimeout.ts
  55. 0 53
      tests/network-tests/src/nicaea/utils/utils.ts
  56. 0 0
      tests/network-tests/src/rome/tap-parallel-not-ok
  57. 0 27
      tests/network-tests/src/rome/tests/electingCouncilTest.ts
  58. 0 111
      tests/network-tests/src/rome/tests/impl/electingCouncil.ts
  59. 0 88
      tests/network-tests/src/rome/tests/impl/membershipCreation.ts
  60. 0 64
      tests/network-tests/src/rome/tests/impl/romeRuntimeUpgrade.ts
  61. 0 20
      tests/network-tests/src/rome/tests/impl/setTimeout.ts
  62. 0 19
      tests/network-tests/src/rome/tests/membershipCreationTest.ts
  63. 0 31
      tests/network-tests/src/rome/tests/romeRuntimeUpgradeTest.ts
  64. 0 370
      tests/network-tests/src/rome/utils/apiWrapper.ts
  65. 0 5
      tests/network-tests/src/rome/utils/config.ts
  66. 0 66
      tests/network-tests/src/rome/utils/sender.ts
  67. 0 50
      tests/network-tests/src/rome/utils/utils.ts
  68. 0 0
      tests/network-tests/src/services/dbService.ts
  69. 0 0
      tests/network-tests/src/tap-parallel-not-ok
  70. 1 1
      tests/network-tests/src/tests/council/electingCouncilTest.ts
  71. 1 1
      tests/network-tests/src/tests/councilSetup.ts
  72. 1 1
      tests/network-tests/src/tests/fixtures/councilElectionHappyCase.ts
  73. 1 1
      tests/network-tests/src/tests/fixtures/councilElectionModule.ts
  74. 0 0
      tests/network-tests/src/tests/fixtures/interfaces/fixture.ts
  75. 2 2
      tests/network-tests/src/tests/fixtures/leaderHiringHappyCase.ts
  76. 1 1
      tests/network-tests/src/tests/fixtures/membershipModule.ts
  77. 3 3
      tests/network-tests/src/tests/fixtures/proposalsModule.ts
  78. 3 3
      tests/network-tests/src/tests/fixtures/workingGroupModule.ts
  79. 1 1
      tests/network-tests/src/tests/leaderSetup.ts
  80. 1 1
      tests/network-tests/src/tests/membership/membershipCreationTest.ts
  81. 1 1
      tests/network-tests/src/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts
  82. 1 1
      tests/network-tests/src/tests/proposals/electionParametersProposalTest.ts
  83. 3 3
      tests/network-tests/src/tests/proposals/manageLeaderRoleTest.ts
  84. 1 1
      tests/network-tests/src/tests/proposals/setLeadProposalTest.ts
  85. 1 1
      tests/network-tests/src/tests/proposals/spendingProposalTest.ts
  86. 1 1
      tests/network-tests/src/tests/proposals/textProposalTest.ts
  87. 1 1
      tests/network-tests/src/tests/proposals/updateRuntime.ts
  88. 1 1
      tests/network-tests/src/tests/proposals/validatorCountProposalTest.ts
  89. 2 2
      tests/network-tests/src/tests/proposals/workingGroupMintCapacityProposalTest.ts
  90. 1 1
      tests/network-tests/src/tests/workingGroup/atLeastValueBugTest.ts
  91. 2 2
      tests/network-tests/src/tests/workingGroup/manageWorkerAsLeadTest.ts
  92. 2 2
      tests/network-tests/src/tests/workingGroup/manageWorkerAsWorkerTest.ts
  93. 2 2
      tests/network-tests/src/tests/workingGroup/workerApplicationHappyCaseTest.ts
  94. 2 2
      tests/network-tests/src/tests/workingGroup/workerApplicationRejectionCaseTest.ts
  95. 3 3
      tests/network-tests/src/tests/workingGroup/workerPayoutTest.ts
  96. 10 10
      tests/network-tests/src/utils/apiWrapper.ts
  97. 0 0
      tests/network-tests/src/utils/closeApi.ts
  98. 0 0
      tests/network-tests/src/utils/config.ts
  99. 0 0
      tests/network-tests/src/utils/sender.ts
  100. 0 0
      tests/network-tests/src/utils/setTestTimeout.ts

+ 5 - 10
tests/network-tests/package.json

@@ -3,22 +3,17 @@
   "version": "0.1.0",
   "license": "GPL-3.0-only",
   "scripts": {
-    "build": "tsc --build tsconfig.json",
-    "test": "rm -f ../../.tmp/db.json && tap --files src/iznik/tests/unknown.unknown src/iznik/tests/councilSetup.ts src/iznik/tests/proposals/*Test.ts src/iznik/tests/leaderSetup.ts src/iznik/tests/workingGroup/*Test.ts -T",
-    "test-migration-constantinople": "tap --files src/rome/tests/romeRuntimeUpgradeTest.ts --files src/constantinople/tests/electingCouncilTest.ts -T",
-    "test-migration-nicaea": "tap --files src/constantinople/tests/proposals/updateRuntimeTest.ts --files src/nicaea/tests/electingCouncilTest.ts -T",
-    "debug": "tap --files src/iznik/tests/workingGroup/workerPayoutTest.ts -T",
+    "build": "tsc --noEmit",
+    "test": "yarn remove-db && tap --files src/tests/unknown.unknown src/tests/councilSetup.ts src/tests/proposals/*Test.ts src/tests/leaderSetup.ts src/tests/workingGroup/*Test.ts -T",
     "lint": "eslint . --quiet --ext .ts",
     "checks": "yarn lint && tsc --noEmit --pretty && prettier ./ --check",
-    "format": "prettier ./ --write "
+    "format": "prettier ./ --write ",
+    "remove-db": "rm ../../.tmp/db.json || echo ''"
   },
   "dependencies": {
-    "@constantinople/types@npm:@joystream/types": "^0.10.0",
-    "@nicaea/types@npm:@joystream/types": "^0.12.0",
-    "@alexandria/types": "link:../../types",
+    "@joystream/types": "link:../../types",
     "@polkadot/api": "1.26.1",
     "@polkadot/keyring": "3.0.1",
-    "@rome/types@npm:@joystream/types": "^0.7.0",
     "@types/bn.js": "^4.11.5",
     "@types/lowdb": "^1.0.9",
     "bn.js": "^4.11.8",

+ 0 - 39
tests/network-tests/src/constantinople/tests/electingCouncilTest.ts

@@ -1,39 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { councilTest } from './impl/electingCouncil'
-import { initConfig } from '../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import { setTestTimeout } from '../utils/setTestTimeout'
-import BN from 'bn.js'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@constantinople/types'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { closeApi } from './impl/closeApi'
-
-tap.mocha.describe('Electing council scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 25
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  closeApi(apiWrapper)
-})

+ 0 - 8
tests/network-tests/src/constantinople/tests/impl/closeApi.ts

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

+ 0 - 100
tests/network-tests/src/constantinople/tests/impl/electingCouncil.ts

@@ -1,100 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Keyring } from '@polkadot/api'
-import BN from 'bn.js'
-import { Seat } from '@constantinople/types'
-import { assert } from 'chai'
-import { v4 as uuid } from 'uuid'
-import { Utils } from '../../utils/utils'
-import tap from 'tap'
-
-export function councilTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  k: number,
-  sudoUri: string,
-  greaterStake: BN,
-  lesserStake: BN
-) {
-  let sudo: KeyringPair
-
-  tap.test('Electing a council test', async () => {
-    // Setup goes here because M keypairs are generated after before() function
-    sudo = keyring.addFromUri(sudoUri)
-    let now = await apiWrapper.getBestBlock()
-    const applyForCouncilFee: BN = apiWrapper.estimateApplyForCouncilFee(greaterStake)
-    const voteForCouncilFee: BN = apiWrapper.estimateVoteForCouncilFee(sudo.address, sudo.address, greaterStake)
-    const salt: string[] = []
-    m1KeyPairs.forEach(() => {
-      salt.push(''.concat(uuid().replace(/-/g, '')))
-    })
-    const revealVoteFee: BN = apiWrapper.estimateRevealVoteFee(sudo.address, salt[0])
-
-    // Topping the balances
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, applyForCouncilFee.add(greaterStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m1KeyPairs, voteForCouncilFee.add(revealVoteFee).add(greaterStake))
-
-    // First K members stake more
-    await apiWrapper.sudoStartAnnouncingPerion(sudo, now.addn(100))
-    await apiWrapper.batchApplyForCouncilElection(m2KeyPairs.slice(0, k), greaterStake)
-    m2KeyPairs.slice(0, k).forEach((keyPair) =>
-      apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
-        assert(
-          stake.eq(greaterStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${greaterStake}`
-        )
-      })
-    )
-
-    // Last members stake less
-    await apiWrapper.batchApplyForCouncilElection(m2KeyPairs.slice(k), lesserStake)
-    m2KeyPairs.slice(k).forEach((keyPair) =>
-      apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
-        assert(
-          stake.eq(lesserStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${lesserStake}`
-        )
-      })
-    )
-
-    // Voting
-    await apiWrapper.sudoStartVotingPerion(sudo, now.addn(100))
-    await apiWrapper.batchVoteForCouncilMember(
-      m1KeyPairs.slice(0, k),
-      m2KeyPairs.slice(0, k),
-      salt.slice(0, k),
-      lesserStake
-    )
-    await apiWrapper.batchVoteForCouncilMember(m1KeyPairs.slice(k), m2KeyPairs.slice(k), salt.slice(k), greaterStake)
-
-    // Revealing
-    await apiWrapper.sudoStartRevealingPerion(sudo, now.addn(100))
-    await apiWrapper.batchRevealVote(m1KeyPairs.slice(0, k), m2KeyPairs.slice(0, k), salt.slice(0, k))
-    await apiWrapper.batchRevealVote(m1KeyPairs.slice(k), m2KeyPairs.slice(k), salt.slice(k))
-    now = await apiWrapper.getBestBlock()
-
-    // Resolving election
-    // 3 is to ensure the revealing block is in future
-    await apiWrapper.sudoStartRevealingPerion(sudo, now.addn(3))
-    await Utils.wait(apiWrapper.getBlockDuration().muln(2.5).toNumber())
-    const seats: Seat[] = await apiWrapper.getCouncil()
-
-    // Preparing collections to increase assertion readability
-    const m2addresses: string[] = m2KeyPairs.map((keyPair) => keyPair.address)
-    const m1addresses: string[] = m1KeyPairs.map((keyPair) => keyPair.address)
-    const members: string[] = seats.map((seat) => seat.member.toString())
-    const bakers: string[] = seats.map((seat) => seat.backers.map((baker) => baker.member.toString())).flat()
-
-    // Assertions
-    m2addresses.forEach((address) => assert(members.includes(address), `Account ${address} is not in the council`))
-    m1addresses.forEach((address) => assert(bakers.includes(address), `Account ${address} is not in the voters`))
-    seats.forEach((seat) =>
-      assert(
-        Utils.getTotalStake(seat).eq(greaterStake.add(lesserStake)),
-        `Member ${seat.member} has unexpected stake ${Utils.getTotalStake(seat)}`
-      )
-    )
-  })
-}

+ 0 - 78
tests/network-tests/src/constantinople/tests/impl/membershipCreation.ts

@@ -1,78 +0,0 @@
-import { Keyring } from '@polkadot/keyring'
-import { assert } from 'chai'
-import { KeyringPair } from '@polkadot/keyring/types'
-import BN from 'bn.js'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import tap from 'tap'
-
-export function membershipTest(
-  apiWrapper: ApiWrapper,
-  nKeyPairs: KeyringPair[],
-  keyring: Keyring,
-  n: number,
-  paidTerms: number,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-  let aKeyPair: KeyringPair
-  let membershipFee: BN
-  let membershipTransactionFee: BN
-
-  tap.test('Membership creation test setup', async () => {
-    sudo = keyring.addFromUri(sudoUri)
-    for (let i = 0; i < n; i++) {
-      nKeyPairs.push(keyring.addFromUri(i + uuid().substring(0, 8)))
-    }
-    aKeyPair = keyring.addFromUri(uuid().substring(0, 8))
-    membershipFee = await apiWrapper.getMembershipFee(paidTerms)
-    membershipTransactionFee = apiWrapper.estimateBuyMembershipFee(
-      sudo,
-      paidTerms,
-      'member_name_which_is_longer_than_expected'
-    )
-    await apiWrapper.transferBalanceToAccounts(sudo, nKeyPairs, membershipTransactionFee.add(new BN(membershipFee)))
-    await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipTransactionFee)
-  })
-
-  tap.test('Buy membeship is accepted with sufficient funds', async () => {
-    await Promise.all(
-      nKeyPairs.map(async (keyPair, index) => {
-        await apiWrapper.buyMembership(keyPair, paidTerms, `new_member_${index}${keyPair.address.substring(0, 8)}`)
-      })
-    )
-    nKeyPairs.forEach((keyPair, index) =>
-      apiWrapper
-        .getMemberIds(keyPair.address)
-        .then((membership) => assert(membership.length > 0, `Account ${keyPair.address} is not a member`))
-    )
-  })
-
-  tap.test('Account A can not buy the membership with insufficient funds', async () => {
-    await apiWrapper
-      .getBalance(aKeyPair.address)
-      .then((balance) =>
-        assert(
-          balance.toBn() < membershipFee.add(membershipTransactionFee),
-          'Account A already have sufficient balance to purchase membership'
-        )
-      )
-    await apiWrapper.buyMembership(aKeyPair, paidTerms, `late_member_${aKeyPair.address.substring(0, 8)}`, true)
-    apiWrapper
-      .getMemberIds(aKeyPair.address)
-      .then((membership) => assert(membership.length === 0, 'Account A is a member'))
-  })
-
-  tap.test('Account A was able to buy the membership with sufficient funds', async () => {
-    await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipFee.add(membershipTransactionFee))
-    apiWrapper
-      .getBalance(aKeyPair.address)
-      .then((balance) =>
-        assert(balance.toBn() >= membershipFee, 'The account balance is insufficient to purchase membership')
-      )
-    await apiWrapper.buyMembership(aKeyPair, paidTerms, `late_member_${aKeyPair.address.substring(0, 8)}`)
-    apiWrapper
-      .getMemberIds(aKeyPair.address)
-      .then((membership) => assert(membership.length > 0, 'Account A is a not member'))
-  })
-}

+ 0 - 29
tests/network-tests/src/constantinople/tests/membershipCreationTest.ts

@@ -1,29 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { Keyring, WsProvider } from '@polkadot/api'
-import { initConfig } from '../utils/config'
-import { setTestTimeout } from '../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@constantinople/types'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { closeApi } from './impl/closeApi'
-
-tap.mocha.describe('Membership creation scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const durationInBlocks = 7
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 40
tests/network-tests/src/constantinople/tests/proposals/evictStorageProviderTest.ts

@@ -1,40 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { evictStorageProviderTest } from './impl/evictStoraveProvider'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@constantinople/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Evict Storage provider scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 32
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  evictStorageProviderTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 56
tests/network-tests/src/constantinople/tests/proposals/impl/evictStoraveProvider.ts

@@ -1,56 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import { Utils } from '../../../utils/utils'
-import tap from 'tap'
-
-export function evictStorageProviderTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('Evict storage provider proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing validator count proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-    if (!(await apiWrapper.isStorageProvider(sudo.address))) {
-      await apiWrapper.createStorageProvider(sudo)
-    }
-    assert(await apiWrapper.isStorageProvider(sudo.address), `Account ${sudo.address} is not storage provider`)
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(25000)
-    const proposalFee: BN = apiWrapper.estimateProposeEvictStorageProviderFee(
-      description,
-      description,
-      proposalStake,
-      sudo.address
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeEvictStorageProvider(m1KeyPairs[0], proposalTitle, description, proposalStake, sudo.address)
-    const proposalNumber = await proposalPromise
-
-    // Approving the proposal
-    const proposalExecutionPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await proposalExecutionPromise
-    await Utils.wait(apiWrapper.getBlockDuration().toNumber())
-    assert(
-      !(await apiWrapper.isStorageProvider(sudo.address)),
-      `Account ${sudo.address} is storage provider after eviction`
-    )
-  })
-}

+ 0 - 120
tests/network-tests/src/constantinople/tests/proposals/impl/storageRoleParametersProposal.ts

@@ -1,120 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import { RoleParameters } from '@constantinople/types/lib/roles'
-import tap from 'tap'
-
-export function storageRoleParametersProposalTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('Storage role parameters proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing validator count proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-    const roleParameters: RoleParameters = ((await apiWrapper.getStorageRoleParameters()) as unknown) as RoleParameters
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(100000)
-    const proposalFee: BN = apiWrapper.estimateProposeStorageRoleParametersFee(
-      description,
-      description,
-      proposalStake,
-      roleParameters.min_stake.toBn(),
-      roleParameters.min_actors.toBn(),
-      roleParameters.max_actors.toBn(),
-      roleParameters.reward.toBn(),
-      roleParameters.reward_period.toBn(),
-      roleParameters.bonding_period.toBn(),
-      roleParameters.unbonding_period.toBn(),
-      roleParameters.min_service_period.toBn(),
-      roleParameters.startup_grace_period.toBn(),
-      roleParameters.entry_request_fee.toBn()
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-    // Proposal creation
-    const proposedMinStake: BN = roleParameters.min_stake.toBn().addn(1)
-    const proposedMaxActors: BN = roleParameters.max_actors.toBn().addn(1)
-    const proposedReward: BN = roleParameters.reward.toBn().addn(1)
-    const proposedRewardPeriod: BN = roleParameters.reward_period.toBn().addn(1)
-    const proposedBondingPeriod: BN = roleParameters.bonding_period.toBn().addn(1)
-    const proposedUnbondingPeriod: BN = roleParameters.unbonding_period.toBn().addn(1)
-    const proposedMinServicePeriod: BN = roleParameters.min_service_period.toBn().addn(1)
-    const proposedStartupGracePeriod: BN = roleParameters.startup_grace_period.toBn().addn(1)
-    const proposedEntryRequestFee: BN = roleParameters.entry_request_fee.toBn().addn(1)
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeStorageRoleParameters(
-      m1KeyPairs[0],
-      proposalTitle,
-      description,
-      proposalStake,
-      proposedMinStake,
-      roleParameters.min_actors.toBn(),
-      proposedMaxActors,
-      proposedReward,
-      proposedRewardPeriod,
-      proposedBondingPeriod,
-      proposedUnbondingPeriod,
-      proposedMinServicePeriod,
-      proposedStartupGracePeriod,
-      proposedEntryRequestFee
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving the proposal
-    const proposalExecutionPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await proposalExecutionPromise
-
-    // Assertions
-    const newRoleParameters: RoleParameters = await apiWrapper.getStorageRoleParameters()
-    assert(
-      proposedMinStake.eq(newRoleParameters.min_stake.toBn()),
-      `Min stake has unexpected value ${newRoleParameters.min_stake.toBn()}, expected ${proposedMinStake}`
-    )
-    assert(
-      proposedMaxActors.eq(newRoleParameters.max_actors.toBn()),
-      `Max actors has unexpected value ${newRoleParameters.max_actors.toBn()}, expected ${proposedMaxActors}`
-    )
-    assert(
-      proposedReward.eq(newRoleParameters.reward.toBn()),
-      `Reward has unexpected value ${newRoleParameters.reward.toBn()}, expected ${proposedReward}`
-    )
-    assert(
-      proposedRewardPeriod.eq(newRoleParameters.reward_period.toBn()),
-      `Reward period has unexpected value ${newRoleParameters.reward_period.toBn()}, expected ${proposedRewardPeriod}`
-    )
-    assert(
-      proposedBondingPeriod.eq(newRoleParameters.bonding_period.toBn()),
-      `Bonding period has unexpected value ${newRoleParameters.bonding_period.toBn()}, expected ${proposedBondingPeriod}`
-    )
-    assert(
-      proposedUnbondingPeriod.eq(newRoleParameters.unbonding_period.toBn()),
-      `Unbonding period has unexpected value ${newRoleParameters.unbonding_period.toBn()}, expected ${proposedUnbondingPeriod}`
-    )
-    assert(
-      proposedMinServicePeriod.eq(newRoleParameters.min_service_period.toBn()),
-      `Min service period has unexpected value ${newRoleParameters.min_service_period.toBn()}, expected ${proposedMinServicePeriod}`
-    )
-    assert(
-      proposedStartupGracePeriod.eq(newRoleParameters.startup_grace_period.toBn()),
-      `Startup grace period has unexpected value ${newRoleParameters.startup_grace_period.toBn()}, expected ${proposedStartupGracePeriod}`
-    )
-    assert(
-      proposedEntryRequestFee.eq(newRoleParameters.entry_request_fee.toBn()),
-      `Entry request fee has unexpected value ${newRoleParameters.entry_request_fee.toBn()}, expected ${proposedEntryRequestFee}`
-    )
-  })
-}

+ 0 - 53
tests/network-tests/src/constantinople/tests/proposals/impl/updateRuntime.ts

@@ -1,53 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import tap from 'tap'
-import { Utils } from '../../../utils/utils'
-
-export function updateRuntimeTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string,
-  runtimePath: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('\n\tUpgrading the runtime test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const runtime: string = Utils.readRuntimeFromFile(runtimePath)
-    const description = 'runtime upgrade proposal which is used for API network testing'
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-
-    // Topping the balances
-    const proposalStake: BN = new BN(1000000)
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeRuntimeUpgradeFee(
-      proposalStake,
-      description,
-      description,
-      runtime
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeRuntime(
-      m1KeyPairs[0],
-      proposalStake,
-      'testing runtime' + uuid().substring(0, 8),
-      'runtime to test proposal functionality' + uuid().substring(0, 8),
-      runtime
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving runtime update proposal
-    const runtimePromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await runtimePromise
-  })
-}

+ 0 - 40
tests/network-tests/src/constantinople/tests/proposals/storageRoleParametersProposalTest.ts

@@ -1,40 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { storageRoleParametersProposalTest } from './impl/storageRoleParametersProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@constantinople/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Storage role parameters proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 29
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  storageRoleParametersProposalTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 41
tests/network-tests/src/constantinople/tests/proposals/updateRuntimeTest.ts

@@ -1,41 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { updateRuntimeTest } from './impl/updateRuntime'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@constantinople/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Update runtime scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 54
-  const runtimePath: string = process.env.RUNTIME_WASM_PATH!
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  updateRuntimeTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri, runtimePath)
-  closeApi(apiWrapper)
-})

+ 0 - 644
tests/network-tests/src/constantinople/utils/apiWrapper.ts

@@ -1,644 +0,0 @@
-import { ApiPromise, WsProvider } from '@polkadot/api'
-import { Option, Vec, Bytes, u32 } from '@polkadot/types'
-import { Codec } from '@polkadot/types/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { UserInfo, PaidMembershipTerms, MemberId } from '@constantinople/types/lib/members'
-import { Mint, MintId } from '@constantinople/types/lib/mint'
-import { Lead, LeadId } from '@constantinople/types/lib/content-working-group'
-import { RoleParameters } from '@constantinople/types/lib/roles'
-import { Seat } from '@constantinople/types'
-import { Balance, EventRecord, AccountId, BlockNumber, BalanceOf } from '@polkadot/types/interfaces'
-import BN from 'bn.js'
-import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { Sender } from './sender'
-import { Utils } from './utils'
-
-export class ApiWrapper {
-  private readonly api: ApiPromise
-  private readonly sender: Sender
-
-  public static async create(provider: WsProvider): Promise<ApiWrapper> {
-    const api = await ApiPromise.create({ provider })
-    return new ApiWrapper(api)
-  }
-
-  constructor(api: ApiPromise) {
-    this.api = api
-    this.sender = new Sender(api)
-  }
-
-  public close() {
-    this.api.disconnect()
-  }
-
-  public async buyMembership(
-    account: KeyringPair,
-    paidTermsId: number,
-    name: string,
-    expectFailure = false
-  ): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' })),
-      account,
-      expectFailure
-    )
-  }
-
-  public getMemberIds(address: string): Promise<MemberId[]> {
-    return this.api.query.members.memberIdsByControllerAccountId<Vec<MemberId>>(address)
-  }
-
-  public getBalance(address: string): Promise<Balance> {
-    return this.api.query.balances.freeBalance<Balance>(address)
-  }
-
-  public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.balances.transfer(to, amount), from)
-  }
-
-  public getPaidMembershipTerms(paidTermsId: number): Promise<Option<PaidMembershipTerms>> {
-    return this.api.query.members.paidMembershipTermsById<Option<PaidMembershipTerms>>(paidTermsId)
-  }
-
-  public getMembershipFee(paidTermsId: number): Promise<BN> {
-    return this.getPaidMembershipTerms(paidTermsId).then((terms) => terms.unwrap().fee.toBn())
-  }
-
-  public async transferBalanceToAccounts(from: KeyringPair, to: KeyringPair[], amount: BN): Promise<void[]> {
-    return Promise.all(
-      to.map(async (keyPair) => {
-        await this.transferBalance(from, keyPair.address, amount)
-      })
-    )
-  }
-
-  private getBaseTxFee(): BN {
-    return this.api.createType('BalanceOf', this.api.consts.transactionPayment.transactionBaseFee).toBn()
-  }
-
-  private estimateTxFee(tx: SubmittableExtrinsic<'promise'>): BN {
-    const baseFee: BN = this.getBaseTxFee()
-    const byteFee: BN = this.api.createType('BalanceOf', this.api.consts.transactionPayment.transactionByteFee).toBn()
-    return Utils.calcTxLength(tx).mul(byteFee).add(baseFee)
-  }
-
-  public estimateBuyMembershipFee(account: KeyringPair, paidTermsId: number, name: string): BN {
-    return this.estimateTxFee(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' }))
-    )
-  }
-
-  public estimateApplyForCouncilFee(amount: BN): BN {
-    return this.estimateTxFee(this.api.tx.councilElection.apply(amount))
-  }
-
-  public estimateVoteForCouncilFee(nominee: string, salt: string, stake: BN): BN {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.estimateTxFee(this.api.tx.councilElection.vote(hashedVote, stake))
-  }
-
-  public estimateRevealVoteFee(nominee: string, salt: string): BN {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.estimateTxFee(this.api.tx.councilElection.reveal(hashedVote, nominee, salt))
-  }
-
-  public estimateProposeRuntimeUpgradeFee(stake: BN, name: string, description: string, runtime: Bytes | string): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createRuntimeUpgradeProposal(stake, name, description, stake, runtime)
-    )
-  }
-
-  public estimateProposeTextFee(stake: BN, name: string, description: string, text: string): BN {
-    return this.estimateTxFee(this.api.tx.proposalsCodex.createTextProposal(stake, name, description, stake, text))
-  }
-
-  public estimateProposeSpendingFee(
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN,
-    destination: string
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSpendingProposal(stake, title, description, stake, balance, destination)
-    )
-  }
-
-  public estimateProposeWorkingGroupMintCapacityFee(title: string, description: string, stake: BN, balance: BN): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        stake,
-        title,
-        description,
-        stake,
-        balance
-      )
-    )
-  }
-
-  public estimateProposeValidatorCountFee(title: string, description: string, stake: BN): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetValidatorCountProposal(stake, title, description, stake, stake)
-    )
-  }
-
-  public estimateProposeLeadFee(title: string, description: string, stake: BN, address: string): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetLeadProposal(stake, title, description, stake, { stake, address })
-    )
-  }
-
-  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,
-    stake: BN,
-    announcingPeriod: BN,
-    votingPeriod: BN,
-    revealingPeriod: BN,
-    councilSize: BN,
-    candidacyLimit: BN,
-    newTermDuration: BN,
-    minCouncilStake: BN,
-    minVotingStake: BN
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetElectionParametersProposal(stake, title, description, stake, [
-        announcingPeriod,
-        votingPeriod,
-        revealingPeriod,
-        councilSize,
-        candidacyLimit,
-        newTermDuration,
-        minCouncilStake,
-        minVotingStake,
-      ])
-    )
-  }
-
-  public estimateVoteForProposalFee(): BN {
-    return this.estimateTxFee(this.api.tx.proposalsEngine.vote(0, 0, 'Approve'))
-  }
-
-  private applyForCouncilElection(account: KeyringPair, amount: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.councilElection.apply(amount), account, false)
-  }
-
-  public batchApplyForCouncilElection(accounts: KeyringPair[], amount: BN): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair) => {
-        await this.applyForCouncilElection(keyPair, amount)
-      })
-    )
-  }
-
-  public async getCouncilElectionStake(address: string): Promise<BN> {
-    // TODO alter then `applicantStake` type will be introduced
-    return this.api.query.councilElection.applicantStakes(address).then((stake) => {
-      const parsed = JSON.parse(stake.toString())
-      return new BN(parsed.new)
-    })
-  }
-
-  private voteForCouncilMember(account: KeyringPair, nominee: string, salt: string, stake: BN): Promise<void> {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.sender.signAndSend(this.api.tx.councilElection.vote(hashedVote, stake), account, false)
-  }
-
-  public batchVoteForCouncilMember(
-    accounts: KeyringPair[],
-    nominees: KeyringPair[],
-    salt: string[],
-    stake: BN
-  ): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair, index) => {
-        await this.voteForCouncilMember(keyPair, nominees[index].address, salt[index], stake)
-      })
-    )
-  }
-
-  private revealVote(account: KeyringPair, commitment: string, nominee: string, salt: string): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.councilElection.reveal(commitment, nominee, salt), account, false)
-  }
-
-  public batchRevealVote(accounts: KeyringPair[], nominees: KeyringPair[], salt: string[]): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair, index) => {
-        const commitment = Utils.hashVote(nominees[index].address, salt[index])
-        await this.revealVote(keyPair, commitment, nominees[index].address, salt[index])
-      })
-    )
-  }
-
-  // TODO consider using configurable genesis instead
-  public sudoStartAnnouncingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageAnnouncing(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoStartVotingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageVoting(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoStartRevealingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageRevealing(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoSetCouncilMintCapacity(sudo: KeyringPair, capacity: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.council.setCouncilMintCapacity(capacity)),
-      sudo,
-      false
-    )
-  }
-
-  public getBestBlock(): Promise<BN> {
-    return this.api.derive.chain.bestNumber()
-  }
-
-  public getCouncil(): Promise<Seat[]> {
-    return this.api.query.council.activeCouncil<Vec<Codec>>().then((seats) => {
-      return (seats as unknown) as Seat[]
-    })
-  }
-
-  public getRuntime(): Promise<Bytes> {
-    return this.api.query.substrate.code<Bytes>()
-  }
-
-  public async proposeRuntime(
-    account: KeyringPair,
-    stake: BN,
-    name: string,
-    description: string,
-    runtime: Bytes | string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createRuntimeUpgradeProposal(memberId, name, description, stake, runtime),
-      account,
-      false
-    )
-  }
-
-  public async proposeText(
-    account: KeyringPair,
-    stake: BN,
-    name: string,
-    description: string,
-    text: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createTextProposal(memberId, name, description, stake, text),
-      account,
-      false
-    )
-  }
-
-  public async proposeSpending(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN,
-    destination: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSpendingProposal(memberId, title, description, stake, balance, destination),
-      account,
-      false
-    )
-  }
-
-  public async proposeWorkingGroupMintCapacity(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        balance
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeValidatorCount(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    validatorCount: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetValidatorCountProposal(memberId, title, description, stake, validatorCount),
-      account,
-      false
-    )
-  }
-
-  public async proposeLead(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    leadAccount: KeyringPair
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    const leadMemberId: BN = (await this.getMemberIds(leadAccount.address))[0].toBn()
-    const addressString: string = leadAccount.address
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetLeadProposal(memberId, title, description, stake, [
-        leadMemberId,
-        addressString,
-      ]),
-      account,
-      false
-    )
-  }
-
-  public async proposeEvictStorageProvider(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    storageProvider: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createEvictStorageProviderProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        storageProvider
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeStorageRoleParameters(
-    account: KeyringPair,
-    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
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetStorageRoleParametersProposal(memberId, title, description, stake, [
-        minStake,
-        minActors,
-        maxActors,
-        reward,
-        rewardPeriod,
-        bondingPeriod,
-        unbondingPeriod,
-        minServicePeriod,
-        startupGracePeriod,
-        entryRequestFee,
-      ]),
-      account,
-      false
-    )
-  }
-
-  public async proposeElectionParameters(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    announcingPeriod: BN,
-    votingPeriod: BN,
-    revealingPeriod: BN,
-    councilSize: BN,
-    candidacyLimit: BN,
-    newTermDuration: BN,
-    minCouncilStake: BN,
-    minVotingStake: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetElectionParametersProposal(memberId, title, description, stake, [
-        announcingPeriod,
-        votingPeriod,
-        revealingPeriod,
-        councilSize,
-        candidacyLimit,
-        newTermDuration,
-        minCouncilStake,
-        minVotingStake,
-      ]),
-      account,
-      false
-    )
-  }
-
-  public approveProposal(account: KeyringPair, memberId: BN, proposal: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.proposalsEngine.vote(memberId, proposal, 'Approve'), account, false)
-  }
-
-  public batchApproveProposal(council: KeyringPair[], proposal: BN): Promise<void[]> {
-    return Promise.all(
-      council.map(async (keyPair) => {
-        const memberId: BN = (await this.getMemberIds(keyPair.address))[0].toBn()
-        await this.approveProposal(keyPair, memberId, proposal)
-      })
-    )
-  }
-
-  public getBlockDuration(): BN {
-    return this.api.createType('Moment', this.api.consts.babe.expectedBlockTime).toBn()
-  }
-
-  public expectProposalCreated(): Promise<BN> {
-    return new Promise(async (resolve) => {
-      await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method && record.event.method.toString() === 'ProposalCreated') {
-            resolve(new BN(record.event.data[1].toString()))
-          }
-        })
-      })
-    })
-  }
-
-  public expectRuntimeUpgraded(): Promise<void> {
-    return new Promise(async (resolve) => {
-      await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method.toString() === 'RuntimeUpdated') {
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public expectProposalFinalized(): Promise<void> {
-    return new Promise(async (resolve) => {
-      await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (
-            record.event.method &&
-            record.event.method.toString() === 'ProposalStatusUpdated' &&
-            record.event.data[1].toString().includes('Executed')
-          ) {
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public getTotalIssuance(): Promise<BN> {
-    return this.api.query.balances.totalIssuance<Balance>()
-  }
-
-  public async getRequiredProposalStake(numerator: number, denominator: number): Promise<BN> {
-    const issuance: number = await (await this.getTotalIssuance()).toNumber()
-    const stake = (issuance * numerator) / denominator
-    return new BN(stake.toFixed(0))
-  }
-
-  public getProposalCount(): Promise<BN> {
-    return this.api.query.proposalsEngine.proposalCount<u32>()
-  }
-
-  public async getWorkingGroupMintCapacity(): Promise<BN> {
-    const mintId: MintId = await this.api.query.contentWorkingGroup.mint<MintId>()
-    const mintCodec = await this.api.query.minting.mints<Codec[]>(mintId)
-    const mint: Mint = (mintCodec[0] as unknown) as Mint
-    return mint.getField<Balance>('capacity')
-  }
-
-  public getValidatorCount(): Promise<BN> {
-    return this.api.query.staking.validatorCount<u32>()
-  }
-
-  public async getCurrentLeadAddress(): Promise<string> {
-    const leadId: Option<LeadId> = await this.api.query.contentWorkingGroup.currentLeadId<Option<LeadId>>()
-    const leadCodec = await this.api.query.contentWorkingGroup.leadById<Codec[]>(leadId.unwrap())
-    const lead = (leadCodec[0] as unknown) as Lead
-    return lead.role_account.toString()
-  }
-
-  public async createStorageProvider(account: KeyringPair): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    await this.sender.signAndSend(this.api.tx.actors.roleEntryRequest('StorageProvider', memberId), account, false)
-    await this.sender.signAndSend(this.api.tx.actors.stake('StorageProvider', account.address), account, false)
-    return
-  }
-
-  public async isStorageProvider(address: string): Promise<boolean> {
-    const storageProviders: Vec<AccountId> = await this.api.query.actors.accountIdsByRole<Vec<AccountId>>(
-      'StorageProvider'
-    )
-    return storageProviders.map((accountId) => accountId.toString()).includes(address)
-  }
-
-  public async getStorageRoleParameters(): Promise<RoleParameters> {
-    return (await this.api.query.actors.parameters<Option<RoleParameters>>('StorageProvider')).unwrap()
-  }
-
-  public async getAnnouncingPeriod(): Promise<BN> {
-    return await this.api.query.councilElection.announcingPeriod<BlockNumber>()
-  }
-
-  public async getVotingPeriod(): Promise<BN> {
-    return await this.api.query.councilElection.votingPeriod<BlockNumber>()
-  }
-
-  public async getRevealingPeriod(): Promise<BN> {
-    return await this.api.query.councilElection.revealingPeriod<BlockNumber>()
-  }
-
-  public async getCouncilSize(): Promise<BN> {
-    return await this.api.query.councilElection.councilSize<u32>()
-  }
-
-  public async getCandidacyLimit(): Promise<BN> {
-    return await this.api.query.councilElection.candidacyLimit<u32>()
-  }
-
-  public async getNewTermDuration(): Promise<BN> {
-    return await this.api.query.councilElection.newTermDuration<BlockNumber>()
-  }
-
-  public async getMinCouncilStake(): Promise<BN> {
-    return await this.api.query.councilElection.minCouncilStake<BalanceOf>()
-  }
-
-  public async getMinVotingStake(): Promise<BN> {
-    return await this.api.query.councilElection.minVotingStake<BalanceOf>()
-  }
-}

+ 0 - 66
tests/network-tests/src/constantinople/utils/sender.ts

@@ -1,66 +0,0 @@
-import BN from 'bn.js'
-import { ApiPromise } from '@polkadot/api'
-import { Index } from '@polkadot/types/interfaces'
-import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-
-export class Sender {
-  private readonly api: ApiPromise
-  private static nonceMap: Map<string, BN> = new Map()
-
-  constructor(api: ApiPromise) {
-    this.api = api
-  }
-
-  private async getNonce(address: string): Promise<BN> {
-    let oncahinNonce: BN = new BN(0)
-    if (!Sender.nonceMap.get(address)) {
-      oncahinNonce = await this.api.query.system.accountNonce<Index>(address)
-    }
-    let nonce: BN | undefined = Sender.nonceMap.get(address)
-    if (!nonce) {
-      nonce = oncahinNonce
-    }
-    const nextNonce: BN = nonce.addn(1)
-    Sender.nonceMap.set(address, nextNonce)
-    return nonce
-  }
-
-  private clearNonce(address: string): void {
-    Sender.nonceMap.delete(address)
-  }
-
-  public async signAndSend(
-    tx: SubmittableExtrinsic<'promise'>,
-    account: KeyringPair,
-    expectFailure = false
-  ): Promise<void> {
-    return new Promise(async (resolve, reject) => {
-      const nonce: BN = await this.getNonce(account.address)
-      const signedTx = tx.sign(account, { nonce })
-      await signedTx
-        .send(async (result) => {
-          if (result.status.isFinalized === true && result.events !== undefined) {
-            result.events.forEach((event) => {
-              if (event.event.method === 'ExtrinsicFailed') {
-                if (expectFailure) {
-                  resolve()
-                } else {
-                  reject(new Error('Extrinsic failed unexpectedly'))
-                }
-              }
-            })
-            resolve()
-          }
-          if (result.status.isFuture) {
-            console.log('nonce ' + nonce + ' for account ' + account.address + ' is in future')
-            this.clearNonce(account.address)
-            reject(new Error('Extrinsic nonce is in future'))
-          }
-        })
-        .catch((error) => {
-          reject(error)
-        })
-    })
-  }
-}

+ 0 - 50
tests/network-tests/src/constantinople/utils/utils.ts

@@ -1,50 +0,0 @@
-import { IExtrinsic } from '@polkadot/types/types'
-import { compactToU8a, stringToU8a } from '@polkadot/util'
-import { blake2AsHex } from '@polkadot/util-crypto'
-import BN from 'bn.js'
-import fs from 'fs'
-import { decodeAddress } from '@polkadot/keyring'
-import { Seat } from '@constantinople/types'
-
-export class Utils {
-  private static LENGTH_ADDRESS = 32 + 1 // publicKey + prefix
-  private static LENGTH_ERA = 2 // assuming mortals
-  private static LENGTH_SIGNATURE = 64 // assuming ed25519 or sr25519
-  private static LENGTH_VERSION = 1 // 0x80 & version
-
-  public static calcTxLength = (extrinsic?: IExtrinsic | null, nonce?: BN): BN => {
-    return new BN(
-      Utils.LENGTH_VERSION +
-        Utils.LENGTH_ADDRESS +
-        Utils.LENGTH_SIGNATURE +
-        Utils.LENGTH_ERA +
-        compactToU8a(nonce || 0).length +
-        (extrinsic ? extrinsic.encodedLength : 0)
-    )
-  }
-
-  /** hash(accountId + salt) */
-  public static hashVote(accountId: string, salt: string): string {
-    const accountU8a = decodeAddress(accountId)
-    const saltU8a = stringToU8a(salt)
-    const voteU8a = new Uint8Array(accountU8a.length + saltU8a.length)
-    voteU8a.set(accountU8a)
-    voteU8a.set(saltU8a, accountU8a.length)
-
-    const hash = blake2AsHex(voteU8a, 256)
-    // console.log('Vote hash:', hash, 'for', { accountId, salt });
-    return hash
-  }
-
-  public static wait(ms: number): Promise<void> {
-    return new Promise((resolve) => setTimeout(resolve, ms))
-  }
-
-  public static getTotalStake(seat: Seat): BN {
-    return new BN(+seat.stake.toString() + seat.backers.reduce((a, baker) => a + +baker.stake.toString(), 0))
-  }
-
-  public static readRuntimeFromFile(path: string): string {
-    return '0x' + fs.readFileSync(path).toString('hex')
-  }
-}

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


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

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

+ 0 - 7
tests/network-tests/src/iznik/utils/setTestTimeout.ts

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

+ 0 - 85
tests/network-tests/src/nicaea/dto/fillOpeningParameters.ts

@@ -1,85 +0,0 @@
-import BN from 'bn.js'
-
-export class FillOpeningParameters {
-  private amountPerPayout!: BN
-  private nextPaymentAtBlock!: BN
-  private payoutInterval!: BN
-  private openingId!: BN
-  private successfulApplicationId!: BN
-  private workingGroup!: string
-
-  public getAmountPerPayout(): BN {
-    return this.amountPerPayout
-  }
-
-  public getNextPaymentAtBlock(): BN {
-    return this.nextPaymentAtBlock
-  }
-
-  public getPayoutInterval(): BN {
-    return this.payoutInterval
-  }
-
-  public getOpeningId(): BN {
-    return this.openingId
-  }
-
-  public getSuccessfulApplicationId(): BN {
-    return this.successfulApplicationId
-  }
-
-  public getWorkingGroup(): string {
-    return this.workingGroup
-  }
-
-  public setAmountPerPayout(value: BN): FillOpeningParameters {
-    this.amountPerPayout = value
-    return this
-  }
-
-  public setNextPaymentAtBlock(value: BN): FillOpeningParameters {
-    this.nextPaymentAtBlock = value
-    return this
-  }
-
-  public setPayoutInterval(value: BN): FillOpeningParameters {
-    this.payoutInterval = value
-    return this
-  }
-
-  public setOpeningId(value: BN): FillOpeningParameters {
-    this.openingId = value
-    return this
-  }
-
-  public setSuccessfulApplicationId(value: BN): FillOpeningParameters {
-    this.successfulApplicationId = value
-    return this
-  }
-
-  public setWorkingGroup(value: string): FillOpeningParameters {
-    this.workingGroup = value
-    return this
-  }
-
-  constructor() {
-    return
-  }
-
-  public getRewardPolicy() {
-    return {
-      amount_per_payout: this.amountPerPayout,
-      next_payment_at_block: this.nextPaymentAtBlock,
-      payout_interval: this.payoutInterval,
-    }
-  }
-
-  public getFillOpeningParameters() {
-    return {
-      opening_id: this.openingId,
-      successful_application_id: this.successfulApplicationId,
-      reward_policy: this.getRewardPolicy(),
-      working_group: this.workingGroup,
-    }
-  }
-}

+ 0 - 255
tests/network-tests/src/nicaea/dto/workingGroupOpening.ts

@@ -1,255 +0,0 @@
-import BN from 'bn.js'
-
-export class WorkingGroupOpening {
-  private activateAtBlock: BN | undefined
-  private maxActiveApplicants!: BN
-  private maxReviewPeriodLength!: BN
-  private applicationStakingPolicyAmount!: BN
-  private applicationCrowdedOutUnstakingPeriodLength!: BN
-  private applicationExpiredUnstakingPeriodLength!: BN
-  private roleStakingPolicyAmount!: BN
-  private roleCrowdedOutUnstakingPeriodLength!: BN
-  private roleExpiredUnstakingPeriodLength!: BN
-  private slashableMaxCount!: BN
-  private slashableMaxPercentPtsPerTime!: BN
-  private successfulApplicantApplicationStakeUnstakingPeriod!: BN
-  private failedApplicantApplicationStakeUnstakingPeriod!: BN
-  private failedApplicantRoleStakeUnstakingPeriod!: BN
-  private terminateApplicationStakeUnstakingPeriod!: BN
-  private terminateRoleStakeUnstakingPeriod!: BN
-  private exitRoleApplicationStakeUnstakingPeriod!: BN
-  private exitRoleStakeUnstakingPeriod!: BN
-  private text!: string
-  private openingType!: string
-
-  public getActivateAtBlock(): BN | undefined {
-    return this.activateAtBlock
-  }
-
-  public getMaxActiveApplicants(): BN {
-    return this.maxActiveApplicants
-  }
-
-  public getMaxReviewPeriodLength(): BN {
-    return this.maxReviewPeriodLength
-  }
-
-  public getApplicationStakingPolicyAmount(): BN {
-    return this.applicationStakingPolicyAmount
-  }
-
-  public getApplicationCrowdedOutUnstakingPeriodLength(): BN {
-    return this.applicationCrowdedOutUnstakingPeriodLength
-  }
-
-  public getApplicationExpiredUnstakingPeriodLength(): BN {
-    return this.applicationExpiredUnstakingPeriodLength
-  }
-
-  public getRoleStakingPolicyAmount(): BN {
-    return this.roleStakingPolicyAmount
-  }
-
-  public getRoleCrowdedOutUnstakingPeriodLength(): BN {
-    return this.roleCrowdedOutUnstakingPeriodLength
-  }
-
-  public getRoleExpiredUnstakingPeriodLength(): BN {
-    return this.roleExpiredUnstakingPeriodLength
-  }
-
-  public getSlashableMaxCount(): BN {
-    return this.slashableMaxCount
-  }
-
-  public getSlashableMaxPercentPtsPerTime(): BN {
-    return this.slashableMaxPercentPtsPerTime
-  }
-
-  public getSuccessfulApplicantApplicationStakeUnstakingPeriod(): BN {
-    return this.successfulApplicantApplicationStakeUnstakingPeriod
-  }
-
-  public getFailedApplicantApplicationStakeUnstakingPeriod(): BN {
-    return this.failedApplicantApplicationStakeUnstakingPeriod
-  }
-
-  public getFailedApplicantRoleStakeUnstakingPeriod(): BN {
-    return this.failedApplicantRoleStakeUnstakingPeriod
-  }
-
-  public getTerminateApplicationStakeUnstakingPeriod(): BN {
-    return this.terminateApplicationStakeUnstakingPeriod
-  }
-
-  public getTerminateRoleStakeUnstakingPeriod(): BN {
-    return this.terminateRoleStakeUnstakingPeriod
-  }
-
-  public getExitRoleApplicationStakeUnstakingPeriod(): BN {
-    return this.exitRoleApplicationStakeUnstakingPeriod
-  }
-
-  public getExitRoleStakeUnstakingPeriod(): BN {
-    return this.exitRoleStakeUnstakingPeriod
-  }
-
-  public getText(): string {
-    return this.text
-  }
-
-  public getOpeningType(): string {
-    return this.openingType
-  }
-
-  public setActivateAtBlock(value: BN | undefined): WorkingGroupOpening {
-    this.activateAtBlock = value
-    return this
-  }
-
-  public setMaxActiveApplicants(value: BN): WorkingGroupOpening {
-    this.maxActiveApplicants = value
-    return this
-  }
-
-  public setMaxReviewPeriodLength(value: BN): WorkingGroupOpening {
-    this.maxReviewPeriodLength = value
-    return this
-  }
-
-  public setApplicationStakingPolicyAmount(value: BN): WorkingGroupOpening {
-    this.applicationStakingPolicyAmount = value
-    return this
-  }
-
-  public setApplicationCrowdedOutUnstakingPeriodLength(value: BN): WorkingGroupOpening {
-    this.applicationCrowdedOutUnstakingPeriodLength = value
-    return this
-  }
-
-  public setApplicationExpiredUnstakingPeriodLength(value: BN): WorkingGroupOpening {
-    this.applicationExpiredUnstakingPeriodLength = value
-    return this
-  }
-
-  public setRoleStakingPolicyAmount(value: BN): WorkingGroupOpening {
-    this.roleStakingPolicyAmount = value
-    return this
-  }
-
-  public setRoleCrowdedOutUnstakingPeriodLength(value: BN): WorkingGroupOpening {
-    this.roleCrowdedOutUnstakingPeriodLength = value
-    return this
-  }
-
-  public setRoleExpiredUnstakingPeriodLength(value: BN): WorkingGroupOpening {
-    this.roleExpiredUnstakingPeriodLength = value
-    return this
-  }
-
-  public setSlashableMaxCount(value: BN): WorkingGroupOpening {
-    this.slashableMaxCount = value
-    return this
-  }
-
-  public setSlashableMaxPercentPtsPerTime(value: BN): WorkingGroupOpening {
-    this.slashableMaxPercentPtsPerTime = value
-    return this
-  }
-
-  public setSuccessfulApplicantApplicationStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.successfulApplicantApplicationStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setFailedApplicantApplicationStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.failedApplicantApplicationStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setFailedApplicantRoleStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.failedApplicantRoleStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setTerminateApplicationStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.terminateApplicationStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setTerminateRoleStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.terminateRoleStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setExitRoleApplicationStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.exitRoleApplicationStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setExitRoleStakeUnstakingPeriod(value: BN): WorkingGroupOpening {
-    this.exitRoleStakeUnstakingPeriod = value
-    return this
-  }
-
-  public setText(value: string): WorkingGroupOpening {
-    this.text = value
-    return this
-  }
-
-  public setOpeningType(value: string): WorkingGroupOpening {
-    this.openingType = value
-    return this
-  }
-
-  constructor() {
-    return
-  }
-
-  public getActivateAt() {
-    return this.activateAtBlock === undefined ? 'CurrentBlock' : { ExactBlock: this.activateAtBlock }
-  }
-
-  public getCommitment() {
-    return {
-      'application_rationing_policy': { 'max_active_applicants': this.maxActiveApplicants },
-      'max_review_period_length': this.maxReviewPeriodLength,
-      'application_staking_policy': {
-        'amount': this.applicationStakingPolicyAmount,
-        'amount_mode': 'AtLeast',
-        'crowded_out_unstaking_period_length': this.applicationCrowdedOutUnstakingPeriodLength,
-        'review_period_expired_unstaking_period_length': this.applicationExpiredUnstakingPeriodLength,
-      },
-      'role_staking_policy': {
-        'amount': this.roleStakingPolicyAmount,
-        'amount_mode': 'AtLeast',
-        'crowded_out_unstaking_period_length': this.roleCrowdedOutUnstakingPeriodLength,
-        'review_period_expired_unstaking_period_length': this.roleExpiredUnstakingPeriodLength,
-      },
-      'role_slashing_terms': {
-        'Slashable': {
-          'max_count': this.slashableMaxCount,
-          'max_percent_pts_per_time': this.slashableMaxPercentPtsPerTime,
-        },
-      },
-      'fill_opening_successful_applicant_application_stake_unstaking_period': this
-        .successfulApplicantApplicationStakeUnstakingPeriod,
-      'fill_opening_failed_applicant_application_stake_unstaking_period': this
-        .failedApplicantApplicationStakeUnstakingPeriod,
-      'fill_opening_failed_applicant_role_stake_unstaking_period': this.failedApplicantRoleStakeUnstakingPeriod,
-      'terminate_application_stake_unstaking_period': this.terminateApplicationStakeUnstakingPeriod,
-      'terminate_role_stake_unstaking_period': this.terminateRoleStakeUnstakingPeriod,
-      'exit_role_application_stake_unstaking_period': this.exitRoleApplicationStakeUnstakingPeriod,
-      'exit_role_stake_unstaking_period': this.exitRoleStakeUnstakingPeriod,
-    }
-  }
-
-  public getAddOpeningParameters(workingGroup: string) {
-    return {
-      activate_at: this.getActivateAt(),
-      commitment: this.getCommitment(),
-      human_readable_text: this.getText(),
-      working_group: workingGroup,
-    }
-  }
-}

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


+ 0 - 38
tests/network-tests/src/nicaea/tests/electingCouncilTest.ts

@@ -1,38 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { councilTest } from './impl/electingCouncil'
-import { initConfig } from '../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import { setTestTimeout } from '../utils/setTestTimeout'
-import BN from 'bn.js'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { closeApi } from './impl/closeApi'
-
-tap.mocha.describe('Electing council scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 25
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  closeApi(apiWrapper)
-})

+ 0 - 8
tests/network-tests/src/nicaea/tests/impl/closeApi.ts

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

+ 0 - 100
tests/network-tests/src/nicaea/tests/impl/electingCouncil.ts

@@ -1,100 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { Keyring } from '@polkadot/api'
-import BN from 'bn.js'
-import { Seat } from '@nicaea/types/council'
-import { assert } from 'chai'
-import { v4 as uuid } from 'uuid'
-import { Utils } from '../../utils/utils'
-import tap from 'tap'
-
-export function councilTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  k: number,
-  sudoUri: string,
-  greaterStake: BN,
-  lesserStake: BN
-) {
-  let sudo: KeyringPair
-
-  tap.test('Electing a council test', async () => {
-    // Setup goes here because M keypairs are generated after before() function
-    sudo = keyring.addFromUri(sudoUri)
-    let now = await apiWrapper.getBestBlock()
-    const applyForCouncilFee: BN = apiWrapper.estimateApplyForCouncilFee(greaterStake)
-    const voteForCouncilFee: BN = apiWrapper.estimateVoteForCouncilFee(sudo.address, sudo.address, greaterStake)
-    const salt: string[] = []
-    m1KeyPairs.forEach(() => {
-      salt.push(''.concat(uuid().replace(/-/g, '')))
-    })
-    const revealVoteFee: BN = apiWrapper.estimateRevealVoteFee(sudo.address, salt[0])
-
-    // Topping the balances
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, applyForCouncilFee.add(greaterStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m1KeyPairs, voteForCouncilFee.add(revealVoteFee).add(greaterStake))
-
-    // First K members stake more
-    await apiWrapper.sudoStartAnnouncingPerion(sudo, now.addn(100))
-    await apiWrapper.batchApplyForCouncilElection(m2KeyPairs.slice(0, k), greaterStake)
-    m2KeyPairs.slice(0, k).forEach((keyPair) =>
-      apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
-        assert(
-          stake.eq(greaterStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${greaterStake}`
-        )
-      })
-    )
-
-    // Last members stake less
-    await apiWrapper.batchApplyForCouncilElection(m2KeyPairs.slice(k), lesserStake)
-    m2KeyPairs.slice(k).forEach((keyPair) =>
-      apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
-        assert(
-          stake.eq(lesserStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${lesserStake}`
-        )
-      })
-    )
-
-    // Voting
-    await apiWrapper.sudoStartVotingPerion(sudo, now.addn(100))
-    await apiWrapper.batchVoteForCouncilMember(
-      m1KeyPairs.slice(0, k),
-      m2KeyPairs.slice(0, k),
-      salt.slice(0, k),
-      lesserStake
-    )
-    await apiWrapper.batchVoteForCouncilMember(m1KeyPairs.slice(k), m2KeyPairs.slice(k), salt.slice(k), greaterStake)
-
-    // Revealing
-    await apiWrapper.sudoStartRevealingPerion(sudo, now.addn(100))
-    await apiWrapper.batchRevealVote(m1KeyPairs.slice(0, k), m2KeyPairs.slice(0, k), salt.slice(0, k))
-    await apiWrapper.batchRevealVote(m1KeyPairs.slice(k), m2KeyPairs.slice(k), salt.slice(k))
-    now = await apiWrapper.getBestBlock()
-
-    // Resolving election
-    // 3 is to ensure the revealing block is in future
-    await apiWrapper.sudoStartRevealingPerion(sudo, now.addn(3))
-    await Utils.wait(apiWrapper.getBlockDuration().muln(2.5).toNumber())
-    const seats: Seat[] = await apiWrapper.getCouncil()
-
-    // Preparing collections to increase assertion readability
-    const m2addresses: string[] = m2KeyPairs.map((keyPair) => keyPair.address)
-    const m1addresses: string[] = m1KeyPairs.map((keyPair) => keyPair.address)
-    const members: string[] = seats.map((seat) => seat.member.toString())
-    const bakers: string[] = seats.map((seat) => seat.backers.map((baker) => baker.member.toString())).flat()
-
-    // Assertions
-    m2addresses.forEach((address) => assert(members.includes(address), `Account ${address} is not in the council`))
-    m1addresses.forEach((address) => assert(bakers.includes(address), `Account ${address} is not in the voters`))
-    seats.forEach((seat) =>
-      assert(
-        Utils.getTotalStake(seat).eq(greaterStake.add(lesserStake)),
-        `Member ${seat.member} has unexpected stake ${Utils.getTotalStake(seat)}`
-      )
-    )
-  })
-}

+ 0 - 86
tests/network-tests/src/nicaea/tests/impl/membershipCreation.ts

@@ -1,86 +0,0 @@
-import { Keyring } from '@polkadot/keyring'
-import { assert } from 'chai'
-import { KeyringPair } from '@polkadot/keyring/types'
-import BN from 'bn.js'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import tap from 'tap'
-
-export function membershipTest(
-  apiWrapper: ApiWrapper,
-  nKeyPairs: KeyringPair[],
-  keyring: Keyring,
-  n: number,
-  paidTerms: number,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-  let aKeyPair: KeyringPair
-  let membershipFee: BN
-  let membershipTransactionFee: BN
-
-  tap.test('Membership creation test setup', async () => {
-    sudo = keyring.addFromUri(sudoUri)
-    for (let i = 0; i < n; i++) {
-      nKeyPairs.push(keyring.addFromUri(i + uuid().substring(0, 8)))
-    }
-    aKeyPair = keyring.addFromUri(uuid().substring(0, 8))
-    membershipFee = await apiWrapper.getMembershipFee(paidTerms)
-    membershipTransactionFee = apiWrapper.estimateBuyMembershipFee(
-      sudo,
-      paidTerms,
-      'member_name_which_is_longer_than_expected'
-    )
-    await apiWrapper.transferBalanceToAccounts(sudo, nKeyPairs, membershipTransactionFee.add(new BN(membershipFee)))
-    await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipTransactionFee)
-  })
-
-  tap.test('Buy membeship is accepted with sufficient funds', async () => {
-    await Promise.all(
-      nKeyPairs.map(async (keyPair, index) => {
-        await apiWrapper.buyMembership(keyPair, paidTerms, `new_member_${index}${keyPair.address.substring(0, 8)}`)
-      })
-    )
-    nKeyPairs.forEach((keyPair, index) =>
-      apiWrapper
-        .getMemberIds(keyPair.address)
-        .then((membership) => assert(membership.length > 0, `Account ${keyPair.address} is not a member`))
-    )
-  })
-
-  tap.test('Account A can not buy the membership with insufficient funds', async () => {
-    await apiWrapper
-      .getBalance(aKeyPair.address)
-      .then((balance) =>
-        assert(
-          balance.toBn() < membershipFee.add(membershipTransactionFee),
-          'Account A already have sufficient balance to purchase membership'
-        )
-      )
-    await apiWrapper.buyMembership(aKeyPair, paidTerms, `late_member_${aKeyPair.address.substring(0, 8)}`, true)
-    apiWrapper
-      .getMemberIds(aKeyPair.address)
-      .then((membership) => assert(membership.length === 0, 'Account A is a member'))
-  })
-
-  tap.test('Account A was able to buy the membership with sufficient funds', async () => {
-    await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipFee.add(membershipTransactionFee))
-    apiWrapper
-      .getBalance(aKeyPair.address)
-      .then((balance) =>
-        assert(balance.toBn() >= membershipFee, 'The account balance is insufficient to purchase membership')
-      )
-    await apiWrapper.buyMembership(aKeyPair, paidTerms, `late_member_${aKeyPair.address.substring(0, 8)}`)
-    apiWrapper
-      .getMemberIds(aKeyPair.address)
-      .then((membership) => assert(membership.length > 0, 'Account A is a not member'))
-  })
-}
-
-export function createKeyPairs(keyring: Keyring, n: number): KeyringPair[] {
-  const nKeyPairs: KeyringPair[] = []
-  for (let i = 0; i < n; i++) {
-    nKeyPairs.push(keyring.addFromUri(i + uuid().substring(0, 8)))
-  }
-  return nKeyPairs
-}

+ 0 - 29
tests/network-tests/src/nicaea/tests/membershipCreationTest.ts

@@ -1,29 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { Keyring, WsProvider } from '@polkadot/api'
-import { initConfig } from '../utils/config'
-import { setTestTimeout } from '../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { ApiWrapper } from '../utils/apiWrapper'
-import { closeApi } from './impl/closeApi'
-
-tap.mocha.describe('Membership creation scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const durationInBlocks = 7
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 41
tests/network-tests/src/nicaea/tests/proposals/contentWorkingGroupMintCapacityProposalTest.ts

@@ -1,41 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { workingGroupMintCapacityProposalTest } from './impl/workingGroupMintCapacityProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Validator count proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const mintingCapacityIncrement: BN = new BN(+process.env.MINTING_CAPACITY_INCREMENT!)
-  const durationInBlocks = 29
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  workingGroupMintCapacityProposalTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri, mintingCapacityIncrement)
-  closeApi(apiWrapper)
-})

+ 0 - 40
tests/network-tests/src/nicaea/tests/proposals/electionParametersProposalTest.ts

@@ -1,40 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { electionParametersProposalTest } from './impl/electionParametersProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Election parameters proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 29
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  electionParametersProposalTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 124
tests/network-tests/src/nicaea/tests/proposals/impl/electionParametersProposal.ts

@@ -1,124 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import tap from 'tap'
-
-export function electionParametersProposalTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('Election parameters proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing validator count proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-    const announcingPeriod: BN = await apiWrapper.getAnnouncingPeriod()
-    const votingPeriod: BN = await apiWrapper.getVotingPeriod()
-    const revealingPeriod: BN = await apiWrapper.getRevealingPeriod()
-    const councilSize: BN = await apiWrapper.getCouncilSize()
-    const candidacyLimit: BN = await apiWrapper.getCandidacyLimit()
-    const newTermDuration: BN = await apiWrapper.getNewTermDuration()
-    const minCouncilStake: BN = await apiWrapper.getMinCouncilStake()
-    const minVotingStake: BN = await apiWrapper.getMinVotingStake()
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(200000)
-    const proposalFee: BN = apiWrapper.estimateProposeElectionParametersFee(
-      description,
-      description,
-      proposalStake,
-      announcingPeriod,
-      votingPeriod,
-      revealingPeriod,
-      councilSize,
-      candidacyLimit,
-      newTermDuration,
-      minCouncilStake,
-      minVotingStake
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-    // Proposal creation
-    const proposedAnnouncingPeriod: BN = announcingPeriod.subn(1)
-    const proposedVotingPeriod: BN = votingPeriod.addn(1)
-    const proposedRevealingPeriod: BN = revealingPeriod.addn(1)
-    const proposedCouncilSize: BN = councilSize.addn(1)
-    const proposedCandidacyLimit: BN = candidacyLimit.addn(1)
-    const proposedNewTermDuration: BN = newTermDuration.addn(1)
-    const proposedMinCouncilStake: BN = minCouncilStake.addn(1)
-    const proposedMinVotingStake: BN = minVotingStake.addn(1)
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeElectionParameters(
-      m1KeyPairs[0],
-      proposalTitle,
-      description,
-      proposalStake,
-      proposedAnnouncingPeriod,
-      proposedVotingPeriod,
-      proposedRevealingPeriod,
-      proposedCouncilSize,
-      proposedCandidacyLimit,
-      proposedNewTermDuration,
-      proposedMinCouncilStake,
-      proposedMinVotingStake
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving the proposal
-    const proposalExecutionPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await proposalExecutionPromise
-
-    // Assertions
-    const newAnnouncingPeriod: BN = await apiWrapper.getAnnouncingPeriod()
-    const newVotingPeriod: BN = await apiWrapper.getVotingPeriod()
-    const newRevealingPeriod: BN = await apiWrapper.getRevealingPeriod()
-    const newCouncilSize: BN = await apiWrapper.getCouncilSize()
-    const newCandidacyLimit: BN = await apiWrapper.getCandidacyLimit()
-    const newNewTermDuration: BN = await apiWrapper.getNewTermDuration()
-    const newMinCouncilStake: BN = await apiWrapper.getMinCouncilStake()
-    const newMinVotingStake: BN = await apiWrapper.getMinVotingStake()
-    assert(
-      proposedAnnouncingPeriod.eq(newAnnouncingPeriod),
-      `Announcing period has unexpected value ${newAnnouncingPeriod}, expected ${proposedAnnouncingPeriod}`
-    )
-    assert(
-      proposedVotingPeriod.eq(newVotingPeriod),
-      `Voting period has unexpected value ${newVotingPeriod}, expected ${proposedVotingPeriod}`
-    )
-    assert(
-      proposedRevealingPeriod.eq(newRevealingPeriod),
-      `Revealing has unexpected value ${newRevealingPeriod}, expected ${proposedRevealingPeriod}`
-    )
-    assert(
-      proposedCouncilSize.eq(newCouncilSize),
-      `Council size has unexpected value ${newCouncilSize}, expected ${proposedCouncilSize}`
-    )
-    assert(
-      proposedCandidacyLimit.eq(newCandidacyLimit),
-      `Candidacy limit has unexpected value ${newCandidacyLimit}, expected ${proposedCandidacyLimit}`
-    )
-    assert(
-      proposedNewTermDuration.eq(newNewTermDuration),
-      `New term duration has unexpected value ${newNewTermDuration}, expected ${proposedNewTermDuration}`
-    )
-    assert(
-      proposedMinCouncilStake.eq(newMinCouncilStake),
-      `Min council stake has unexpected value ${newMinCouncilStake}, expected ${proposedMinCouncilStake}`
-    )
-    assert(
-      proposedMinVotingStake.eq(newMinVotingStake),
-      `Min voting stake has unexpected value ${newMinVotingStake}, expected ${proposedMinVotingStake}`
-    )
-  })
-}

+ 0 - 315
tests/network-tests/src/nicaea/tests/proposals/impl/proposalsModule.ts

@@ -1,315 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper, WorkingGroups } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { WorkingGroupOpening } from '../../../dto/workingGroupOpening'
-import { FillOpeningParameters } from '../../../dto/fillOpeningParameters'
-
-export async function createWorkingGroupLeaderOpening(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  applicationStake: BN,
-  roleStake: BN,
-  workingGroup: string
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing working group lead opening proposal ' + uuid().substring(0, 8)
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(100000)
-  const proposalFee: BN = apiWrapper.estimateProposeCreateWorkingGroupLeaderOpeningFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Opening construction
-  const opening = new WorkingGroupOpening()
-    .setMaxActiveApplicants(new BN(m1KeyPairs.length))
-    .setMaxReviewPeriodLength(new BN(32))
-    .setApplicationStakingPolicyAmount(new BN(applicationStake))
-    .setApplicationCrowdedOutUnstakingPeriodLength(new BN(1))
-    .setApplicationExpiredUnstakingPeriodLength(new BN(1))
-    .setRoleStakingPolicyAmount(new BN(roleStake))
-    .setRoleCrowdedOutUnstakingPeriodLength(new BN(1))
-    .setRoleExpiredUnstakingPeriodLength(new BN(1))
-    .setSlashableMaxCount(new BN(1))
-    .setSlashableMaxPercentPtsPerTime(new BN(100))
-    .setSuccessfulApplicantApplicationStakeUnstakingPeriod(new BN(1))
-    .setFailedApplicantApplicationStakeUnstakingPeriod(new BN(1))
-    .setFailedApplicantRoleStakeUnstakingPeriod(new BN(1))
-    .setTerminateApplicationStakeUnstakingPeriod(new BN(1))
-    .setTerminateRoleStakeUnstakingPeriod(new BN(1))
-    .setExitRoleApplicationStakeUnstakingPeriod(new BN(1))
-    .setExitRoleStakeUnstakingPeriod(new BN(1))
-    .setText(uuid().substring(0, 8))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeCreateWorkingGroupLeaderOpening(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    opening,
-    workingGroup
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function beginWorkingGroupLeaderApplicationReview(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  openingId: BN,
-  workingGroup: string
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing begin working group lead application review proposal ' + uuid().substring(0, 8)
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(25000)
-  const proposalFee: BN = apiWrapper.estimateProposeBeginWorkingGroupLeaderApplicationReviewFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeBeginWorkingGroupLeaderApplicationReview(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    openingId,
-    workingGroup
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function fillLeaderOpeningProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  applicantRoleAccountAddress: string,
-  sudo: KeyringPair,
-  firstRewardInterval: BN,
-  rewardInterval: BN,
-  payoutAmount: BN,
-  openingId: BN,
-  workingGroup: WorkingGroups
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing fill opening proposal ' + uuid().substring(0, 8)
-  const workingGroupString: string = apiWrapper.getWorkingGroupString(workingGroup)
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(50000)
-  const proposalFee: BN = apiWrapper.estimateProposeFillLeaderOpeningFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const applicationId: BN = (
-    await apiWrapper.getActiveApplicationsIdsByRoleAccount(applicantRoleAccountAddress, workingGroup)
-  )[0]
-  const now = await apiWrapper.getBestBlock()
-  const fillOpeningParameters: FillOpeningParameters = new FillOpeningParameters()
-    .setAmountPerPayout(payoutAmount)
-    .setNextPaymentAtBlock(now.add(firstRewardInterval))
-    .setPayoutInterval(rewardInterval)
-    .setOpeningId(openingId)
-    .setSuccessfulApplicationId(applicationId)
-    .setWorkingGroup(workingGroupString)
-
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeFillLeaderOpening(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    fillOpeningParameters
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function terminateLeaderRoleProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  leaderRoleAccountAddress: string,
-  sudo: KeyringPair,
-  slash: boolean,
-  workingGroup: WorkingGroups
-) {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing begin working group lead application review proposal ' + uuid().substring(0, 8)
-  const rationale: string = 'Testing leader termination ' + uuid().substring(0, 8)
-  const workingGroupString: string = apiWrapper.getWorkingGroupString(workingGroup)
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(leaderRoleAccountAddress, workingGroup)
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(100000)
-  const proposalFee: BN = apiWrapper.estimateProposeTerminateLeaderRoleFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeTerminateLeaderRole(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    workerId,
-    rationale,
-    slash,
-    workingGroupString
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function setLeaderRewardProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  payoutAmount: BN,
-  workingGroup: WorkingGroups
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing set leader reward proposal ' + uuid().substring(0, 8)
-  const workingGroupString: string = apiWrapper.getWorkingGroupString(workingGroup)
-  const workerId: BN = (await apiWrapper.getLeadWorkerId(workingGroup))!
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(50000)
-  const proposalFee: BN = apiWrapper.estimateProposeLeaderRewardFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeLeaderReward(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    workerId,
-    payoutAmount,
-    workingGroupString
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function decreaseLeaderStakeProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  stakeDecrement: BN,
-  workingGroup: WorkingGroups
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing decrease leader stake proposal ' + uuid().substring(0, 8)
-  const workingGroupString: string = apiWrapper.getWorkingGroupString(workingGroup)
-  const workerId: BN = (await apiWrapper.getLeadWorkerId(workingGroup))!
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(50000)
-  const proposalFee: BN = apiWrapper.estimateProposeDecreaseLeaderStakeFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeDecreaseLeaderStake(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    workerId,
-    stakeDecrement,
-    workingGroupString
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function slashLeaderProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  slashAmount: BN,
-  workingGroup: WorkingGroups
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing slash leader stake proposal ' + uuid().substring(0, 8)
-  const workingGroupString: string = apiWrapper.getWorkingGroupString(workingGroup)
-  const workerId: BN = (await apiWrapper.getLeadWorkerId(workingGroup))!
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(50000)
-  const proposalFee: BN = apiWrapper.estimateProposeSlashLeaderStakeFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeSlashLeaderStake(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    workerId,
-    slashAmount,
-    workingGroupString
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function workingGroupMintCapacityProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  mintCapacity: BN,
-  workingGroup: WorkingGroups
-): Promise<BN> {
-  // Setup
-  const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-  const description: string = 'Testing working group mint capacity proposal ' + uuid().substring(0, 8)
-  const workingGroupString: string = apiWrapper.getWorkingGroupString(workingGroup)
-
-  // Proposal stake calculation
-  const proposalStake: BN = new BN(50000)
-  const proposalFee: BN = apiWrapper.estimateProposeWorkingGroupMintCapacityFee()
-  await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-  // Proposal creation
-  const proposalPromise = apiWrapper.expectProposalCreated()
-  await apiWrapper.proposeWorkingGroupMintCapacity(
-    m1KeyPairs[0],
-    proposalTitle,
-    description,
-    proposalStake,
-    mintCapacity,
-    workingGroupString
-  )
-  const proposalNumber: BN = await proposalPromise
-  return proposalNumber
-}
-
-export async function voteForProposal(
-  apiWrapper: ApiWrapper,
-  m2KeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  proposalNumber: BN
-): Promise<void> {
-  const proposalVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-  await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, proposalVoteFee)
-
-  // Approving the proposal
-  const proposalExecutionPromise = apiWrapper.expectProposalFinalized()
-  await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-  await proposalExecutionPromise
-}

+ 0 - 46
tests/network-tests/src/nicaea/tests/proposals/impl/setLeadProposal.ts

@@ -1,46 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import tap from 'tap'
-
-export function setLeadProposalTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('Lead proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing validator count proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(50000)
-    const proposalFee: BN = apiWrapper.estimateProposeLeadFee(description, description, proposalStake, sudo.address)
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeLead(m1KeyPairs[0], proposalTitle, description, proposalStake, m1KeyPairs[1])
-    const proposalNumber = await proposalPromise
-
-    // Approving the proposal
-    const proposalExecutionPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await proposalExecutionPromise
-    const newLead: string = await apiWrapper.getCurrentLeadAddress()
-    assert(
-      newLead === m1KeyPairs[1].address,
-      `New lead has unexpected value ${newLead}, expected ${m1KeyPairs[1].address}`
-    )
-  })
-}

+ 0 - 64
tests/network-tests/src/nicaea/tests/proposals/impl/spendingProposal.ts

@@ -1,64 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import tap from 'tap'
-
-export function spendingProposalTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string,
-  spendingBalance: BN,
-  mintCapacity: BN
-) {
-  let sudo: KeyringPair
-
-  tap.test('Spending proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const description = 'spending proposal which is used for API network testing with some mock data'
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-
-    // Topping the balances
-    const proposalStake: BN = new BN(25000)
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeSpendingFee(
-      description,
-      description,
-      proposalStake,
-      spendingBalance,
-      sudo.address
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-    await apiWrapper.sudoSetCouncilMintCapacity(sudo, mintCapacity)
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeSpending(
-      m1KeyPairs[0],
-      'testing spending' + uuid().substring(0, 8),
-      'spending to test proposal functionality' + uuid().substring(0, 8),
-      proposalStake,
-      spendingBalance,
-      sudo.address
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving spending proposal
-    const balanceBeforeMinting: BN = await apiWrapper.getBalance(sudo.address)
-    const spendingPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await spendingPromise
-    const balanceAfterMinting: BN = await apiWrapper.getBalance(sudo.address)
-    assert(
-      balanceAfterMinting.sub(balanceBeforeMinting).eq(spendingBalance),
-      `member ${
-        m1KeyPairs[0].address
-      } has unexpected balance ${balanceAfterMinting}, expected ${balanceBeforeMinting.add(spendingBalance)}`
-    )
-  })
-}

+ 0 - 46
tests/network-tests/src/nicaea/tests/proposals/impl/textProposal.ts

@@ -1,46 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import tap from 'tap'
-
-export function textProposalTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('Text proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing text proposal ' + uuid().substring(0, 8)
-    const proposalText: string = 'Text of the testing proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(25000)
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeTextFee(
-      proposalStake,
-      description,
-      description,
-      proposalText
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeText(m1KeyPairs[0], proposalStake, proposalTitle, description, proposalText)
-    const proposalNumber = await proposalPromise
-
-    // Approving text proposal
-    const textProposalPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await textProposalPromise
-  })
-}

+ 0 - 52
tests/network-tests/src/nicaea/tests/proposals/impl/updateRuntime.ts

@@ -1,52 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { Bytes } from '@polkadot/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import tap from 'tap'
-
-export function updateRuntimeTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string
-) {
-  let sudo: KeyringPair
-
-  tap.test('\n\tUpgrading the runtime test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const runtime: Bytes = await apiWrapper.getRuntime()
-    const description = 'runtime upgrade proposal which is used for API network testing'
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-
-    // Topping the balances
-    const proposalStake: BN = new BN(1000000)
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeRuntimeUpgradeFee(
-      proposalStake,
-      description,
-      description,
-      runtime
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeRuntime(
-      m1KeyPairs[0],
-      proposalStake,
-      'testing runtime' + uuid().substring(0, 8),
-      'runtime to test proposal functionality' + uuid().substring(0, 8),
-      runtime
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving runtime update proposal
-    const runtimePromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await runtimePromise
-  })
-}

+ 0 - 55
tests/network-tests/src/nicaea/tests/proposals/impl/validatorCountProposal.ts

@@ -1,55 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import tap from 'tap'
-
-export function validatorCountProposal(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string,
-  validatorCountIncrement: BN
-) {
-  let sudo: KeyringPair
-
-  tap.test('Validator count proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8)
-    const description: string = 'Testing validator count proposal ' + uuid().substring(0, 8)
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal stake calculation
-    const proposalStake: BN = new BN(100000)
-    const proposalFee: BN = apiWrapper.estimateProposeValidatorCountFee(description, description, proposalStake)
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, proposalFee.add(proposalStake))
-    const validatorCount: BN = await apiWrapper.getValidatorCount()
-
-    // Proposal creation
-    const proposedValidatorCount: BN = validatorCount.add(validatorCountIncrement)
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeValidatorCount(
-      m1KeyPairs[0],
-      proposalTitle,
-      description,
-      proposalStake,
-      proposedValidatorCount
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving the proposal
-    const proposalExecutionPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await proposalExecutionPromise
-    const newValidatorCount: BN = await apiWrapper.getValidatorCount()
-    assert(
-      proposedValidatorCount.eq(newValidatorCount),
-      `Validator count has unexpeccted value ${newValidatorCount}, expected ${proposedValidatorCount}`
-    )
-  })
-}

+ 0 - 59
tests/network-tests/src/nicaea/tests/proposals/impl/workingGroupMintCapacityProposal.ts

@@ -1,59 +0,0 @@
-import { Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import BN from 'bn.js'
-import { assert } from 'chai'
-import tap from 'tap'
-
-export function workingGroupMintCapacityProposalTest(
-  apiWrapper: ApiWrapper,
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudoUri: string,
-  mintingCapacityIncrement: BN
-) {
-  let sudo: KeyringPair
-
-  tap.test('Mint capacity proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const description = 'Mint capacity proposal which is used for API network testing'
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee()
-    const initialMintingCapacity: BN = await apiWrapper.getContentWorkingGroupMintCapacity()
-
-    // Topping the balances
-    const proposalStake: BN = new BN(50000)
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeContentWorkingGroupMintCapacityFee(
-      description,
-      description,
-      proposalStake,
-      initialMintingCapacity.add(mintingCapacityIncrement)
-    )
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal creation
-    const proposedMintingCapacity: BN = initialMintingCapacity.add(mintingCapacityIncrement)
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeContentWorkingGroupMintCapacity(
-      m1KeyPairs[0],
-      'testing mint capacity' + uuid().substring(0, 8),
-      'mint capacity to test proposal functionality' + uuid().substring(0, 8),
-      proposalStake,
-      proposedMintingCapacity
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving mint capacity proposal
-    const mintCapacityPromise = apiWrapper.expectProposalFinalized()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await mintCapacityPromise
-    const newMintingCapacity: BN = await apiWrapper.getContentWorkingGroupMintCapacity()
-    assert(
-      proposedMintingCapacity.eq(newMintingCapacity),
-      `Content working group has unexpected minting capacity ${newMintingCapacity}, expected ${proposedMintingCapacity}`
-    )
-  })
-}

+ 0 - 213
tests/network-tests/src/nicaea/tests/proposals/manageLeaderRole.ts

@@ -1,213 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import {
-  createWorkingGroupLeaderOpening,
-  voteForProposal,
-  beginWorkingGroupLeaderApplicationReview,
-  fillLeaderOpeningProposal,
-  terminateLeaderRoleProposal,
-  setLeaderRewardProposal,
-  decreaseLeaderStakeProposal,
-  slashLeaderProposal,
-} from './impl/proposalsModule'
-import {
-  applyForOpening,
-  expectLeadOpeningAdded,
-  expectLeaderSet,
-  expectBeganApplicationReview,
-  expectLeaderRoleTerminated,
-  expectLeaderRewardAmountUpdated,
-  expectLeaderStakeDecreased,
-  expectLeaderSlashed,
-} from '../workingGroup/impl/workingGroupModule'
-
-tap.mocha.describe('Set lead proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const alteredPayoutAmount: BN = new BN(process.env.ALTERED_PAYOUT_AMOUNT!)
-  const stakeDecrement: BN = new BN(process.env.STAKE_DECREMENT!)
-  const slashAmount: BN = new BN(process.env.SLASH_AMOUNT!)
-  const durationInBlocks = 70
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-
-  let createOpeningProposalId: BN
-  let openingId: BN
-  tap.test(
-    'Propose create leader opening',
-    async () =>
-      (createOpeningProposalId = await createWorkingGroupLeaderOpening(
-        apiWrapper,
-        m1KeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        'Storage'
-      ))
-  )
-  tap.test('Approve add opening proposal', async () => {
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, createOpeningProposalId)
-    openingId = await expectLeadOpeningAdded(apiWrapper)
-  })
-
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        new BN(openingId),
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  let beginReviewProposalId: BN
-  tap.test(
-    'Propose begin leader application review',
-    async () =>
-      (beginReviewProposalId = await beginWorkingGroupLeaderApplicationReview(
-        apiWrapper,
-        m1KeyPairs,
-        sudo,
-        new BN(openingId),
-        'Storage'
-      ))
-  )
-  tap.test('Approve begin review proposal', async () => {
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, beginReviewProposalId)
-    expectBeganApplicationReview(apiWrapper)
-  })
-
-  let fillLeaderOpeningProposalId: BN
-  tap.test(
-    'Propose fill leader opening',
-    async () =>
-      (fillLeaderOpeningProposalId = await fillLeaderOpeningProposal(
-        apiWrapper,
-        m1KeyPairs,
-        leadKeyPair[0].address,
-        sudo,
-        firstRewardInterval,
-        rewardInterval,
-        payoutAmount,
-        new BN(openingId),
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test('Approve fill leader opening', async () => {
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, fillLeaderOpeningProposalId)
-    await expectLeaderSet(apiWrapper, leadKeyPair[0].address, WorkingGroups.StorageWorkingGroup)
-  })
-
-  let rewardProposalId: BN
-  tap.test(
-    'Propose leader reward',
-    async () =>
-      (rewardProposalId = await setLeaderRewardProposal(
-        apiWrapper,
-        m1KeyPairs,
-        sudo,
-        alteredPayoutAmount,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test('Approve new leader reward', async () => {
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, rewardProposalId)
-    await expectLeaderRewardAmountUpdated(apiWrapper, alteredPayoutAmount, WorkingGroups.StorageWorkingGroup)
-  })
-
-  let decreaseStakeProposalId: BN
-  let newStake: BN
-  tap.test(
-    'Propose decrease stake',
-    async () =>
-      (decreaseStakeProposalId = await decreaseLeaderStakeProposal(
-        apiWrapper,
-        m1KeyPairs,
-        sudo,
-        stakeDecrement,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test('Approve decreased leader stake', async () => {
-    newStake = applicationStake.sub(stakeDecrement)
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, decreaseStakeProposalId)
-    await expectLeaderStakeDecreased(apiWrapper, newStake, WorkingGroups.StorageWorkingGroup)
-  })
-
-  let slashProposalId: BN
-  tap.test(
-    'Propose leader slash',
-    async () =>
-      (slashProposalId = await slashLeaderProposal(
-        apiWrapper,
-        m1KeyPairs,
-        sudo,
-        slashAmount,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test('Approve leader slash', async () => {
-    newStake = newStake.sub(slashAmount)
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, slashProposalId)
-    await expectLeaderSlashed(apiWrapper, newStake, WorkingGroups.StorageWorkingGroup)
-  })
-
-  let terminateLeaderRoleProposalId: BN
-  tap.test(
-    'Propose terminate leader role',
-    async () =>
-      (terminateLeaderRoleProposalId = await terminateLeaderRoleProposal(
-        apiWrapper,
-        m1KeyPairs,
-        leadKeyPair[0].address,
-        sudo,
-        false,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test('Approve leader role termination', async () => {
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, terminateLeaderRoleProposalId)
-    await expectLeaderRoleTerminated(apiWrapper, WorkingGroups.StorageWorkingGroup)
-  })
-
-  closeApi(apiWrapper)
-})

+ 0 - 40
tests/network-tests/src/nicaea/tests/proposals/setLeadProposalTest.ts

@@ -1,40 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { setLeadProposalTest } from './impl/setLeadProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Set lead proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 29
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  setLeadProposalTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 42
tests/network-tests/src/nicaea/tests/proposals/spendingProposalTest.ts

@@ -1,42 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { spendingProposalTest } from './impl/spendingProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Spending proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const spendingBalance: BN = new BN(+process.env.SPENDING_BALANCE!)
-  const mintCapacity: BN = new BN(+process.env.COUNCIL_MINTING_CAPACITY!)
-  const durationInBlocks = 29
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  spendingProposalTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri, spendingBalance, mintCapacity)
-  closeApi(apiWrapper)
-})

+ 0 - 40
tests/network-tests/src/nicaea/tests/proposals/textProposalTest.ts

@@ -1,40 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { textProposalTest } from './impl/textProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Text proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 28
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  textProposalTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 41
tests/network-tests/src/nicaea/tests/proposals/updateRuntimeTest.ts

@@ -1,41 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { updateRuntimeTest } from './impl/updateRuntime'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Update runtime scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const durationInBlocks = 54
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  updateRuntimeTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri)
-  membershipTest(apiWrapper, new Array<KeyringPair>(), keyring, N, paidTerms, sudoUri)
-  closeApi(apiWrapper)
-})

+ 0 - 41
tests/network-tests/src/nicaea/tests/proposals/validatorCountProposalTest.ts

@@ -1,41 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { validatorCountProposal } from './impl/validatorCountProposal'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper } from '../../utils/apiWrapper'
-
-tap.mocha.describe('Validator count proposal scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const validatorCountIncrement: BN = new BN(+process.env.VALIDATOR_COUNT_INCREMENT!)
-  const durationInBlocks = 29
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-  validatorCountProposal(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, sudoUri, validatorCountIncrement)
-  closeApi(apiWrapper)
-})

+ 0 - 63
tests/network-tests/src/nicaea/tests/proposals/workingGroupMintCapacityProposalTest.ts

@@ -1,63 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from '../impl/membershipCreation'
-import { councilTest } from '../impl/electingCouncil'
-import { initConfig } from '../../utils/config'
-import { Keyring, WsProvider } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import tap from 'tap'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { voteForProposal, workingGroupMintCapacityProposal } from './impl/proposalsModule'
-import { expectMintCapacityChanged } from '../workingGroup/impl/workingGroupModule'
-
-tap.mocha.describe('Set storage working group mint capacity scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const m1KeyPairs: KeyringPair[] = []
-  const m2KeyPairs: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.MEMBERSHIP_CREATION_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const K: number = +process.env.COUNCIL_ELECTION_K!
-  const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-  const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-  const mintCapacityIncrement: BN = new BN(process.env.MINT_CAPACITY_INCREMENT!)
-  const durationInBlocks = 30
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, m1KeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, m2KeyPairs, keyring, N, paidTerms, sudoUri)
-  councilTest(apiWrapper, m1KeyPairs, m2KeyPairs, keyring, K, sudoUri, greaterStake, lesserStake)
-
-  let mintCapacityProposalId: BN
-  const newMintCapacity: BN = (await apiWrapper.getWorkingGroupMintCapacity(WorkingGroups.StorageWorkingGroup)).add(
-    mintCapacityIncrement
-  )
-  tap.test(
-    'Propose mint capacity',
-    async () =>
-      (mintCapacityProposalId = await workingGroupMintCapacityProposal(
-        apiWrapper,
-        m1KeyPairs,
-        sudo,
-        newMintCapacity,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test('Approve mint capacity', async () => {
-    voteForProposal(apiWrapper, m2KeyPairs, sudo, mintCapacityProposalId)
-    await expectMintCapacityChanged(apiWrapper, newMintCapacity)
-  })
-
-  closeApi(apiWrapper)
-})

+ 0 - 130
tests/network-tests/src/nicaea/tests/workingGroup/atLeastValueBugTest.ts

@@ -1,130 +0,0 @@
-import { initConfig } from '../../utils/config'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { membershipTest } from '../impl/membershipCreation'
-import {
-  addWorkerOpening,
-  applyForOpening,
-  addLeaderOpening,
-  beginLeaderApplicationReview,
-  fillLeaderOpening,
-  leaveRole,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap from 'tap'
-
-tap.mocha.describe('Worker application happy case scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.WORKING_GROUP_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 48
-  const openingActivationDelay: BN = new BN(0)
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-
-  let leadOpenignId: BN
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  let workerOpenignId: BN
-  tap.test(
-    'Add worker opening with 0 stake, expect failure',
-    async () =>
-      (workerOpenignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        new BN(0),
-        new BN(0),
-        openingActivationDelay,
-        unstakingPeriod,
-        WorkingGroups.StorageWorkingGroup,
-        true
-      ))
-  )
-  tap.test(
-    'Add worker opening with 0 unstaking period, expect failure',
-    async () =>
-      (workerOpenignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        new BN(0),
-        WorkingGroups.StorageWorkingGroup,
-        true
-      ))
-  )
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})

+ 0 - 597
tests/network-tests/src/nicaea/tests/workingGroup/impl/workingGroupModule.ts

@@ -1,597 +0,0 @@
-import BN from 'bn.js'
-import { assert } from 'chai'
-import { ApiWrapper, WorkingGroups } from '../../../utils/apiWrapper'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { Balance } from '@polkadot/types/interfaces'
-import { Keyring } from '@polkadot/api'
-import { v4 as uuid } from 'uuid'
-import { RewardRelationship } from '@nicaea/types/recurring-rewards'
-import { Worker, ApplicationIdToWorkerIdMap, Application } from '@nicaea/types/working-group'
-import { Utils } from '../../../utils/utils'
-import { Opening as HiringOpening } from '@nicaea/types/hiring'
-import { WorkingGroupOpening } from '../../../dto/workingGroupOpening'
-
-export async function addWorkerOpening(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  applicationStake: BN,
-  roleStake: BN,
-  activationDelay: BN,
-  unstakingPeriod: BN,
-  module: WorkingGroups,
-  expectFailure: boolean
-): Promise<BN> {
-  // Worker opening construction
-  const activateAtBlock: BN | undefined = activationDelay.eqn(0)
-    ? undefined
-    : (await apiWrapper.getBestBlock()).add(activationDelay)
-  const opening = new WorkingGroupOpening()
-    .setActivateAtBlock(activateAtBlock)
-    .setMaxActiveApplicants(new BN(membersKeyPairs.length))
-    .setMaxReviewPeriodLength(new BN(32))
-    .setApplicationStakingPolicyAmount(new BN(applicationStake))
-    .setApplicationCrowdedOutUnstakingPeriodLength(new BN(1))
-    .setApplicationExpiredUnstakingPeriodLength(new BN(1))
-    .setRoleStakingPolicyAmount(new BN(roleStake))
-    .setRoleCrowdedOutUnstakingPeriodLength(new BN(1))
-    .setRoleExpiredUnstakingPeriodLength(new BN(1))
-    .setSlashableMaxCount(new BN(1))
-    .setSlashableMaxPercentPtsPerTime(new BN(100))
-    .setSuccessfulApplicantApplicationStakeUnstakingPeriod(unstakingPeriod)
-    .setFailedApplicantApplicationStakeUnstakingPeriod(unstakingPeriod)
-    .setFailedApplicantRoleStakeUnstakingPeriod(unstakingPeriod)
-    .setTerminateApplicationStakeUnstakingPeriod(unstakingPeriod)
-    .setTerminateRoleStakeUnstakingPeriod(unstakingPeriod)
-    .setExitRoleApplicationStakeUnstakingPeriod(unstakingPeriod)
-    .setExitRoleStakeUnstakingPeriod(unstakingPeriod)
-    .setText(uuid().substring(0, 8))
-    .setOpeningType('Worker')
-
-  // Fee estimation and transfer
-  const addOpeningFee: BN = apiWrapper.estimateAddOpeningFee(opening, module)
-  await apiWrapper.transferBalance(sudo, lead.address, addOpeningFee)
-
-  // Worker opening creation
-  const addOpeningPromise: Promise<BN> = apiWrapper.expectOpeningAdded()
-  await apiWrapper.addOpening(lead, opening, module, expectFailure)
-  if (!expectFailure) {
-    const openingId: BN = await addOpeningPromise
-    return openingId
-  }
-  return new BN(-1)
-}
-
-export async function addLeaderOpening(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  applicationStake: BN,
-  roleStake: BN,
-  activationDelay: BN,
-  module: WorkingGroups
-): Promise<BN> {
-  // Leader opening creation
-  const activateAtBlock: BN | undefined = activationDelay.eqn(0)
-    ? undefined
-    : (await apiWrapper.getBestBlock()).add(activationDelay)
-  const opening = new WorkingGroupOpening()
-    .setActivateAtBlock(activateAtBlock)
-    .setMaxActiveApplicants(new BN(membersKeyPairs.length))
-    .setMaxReviewPeriodLength(new BN(32))
-    .setApplicationStakingPolicyAmount(new BN(applicationStake))
-    .setApplicationCrowdedOutUnstakingPeriodLength(new BN(1))
-    .setApplicationExpiredUnstakingPeriodLength(new BN(1))
-    .setRoleStakingPolicyAmount(new BN(roleStake))
-    .setRoleCrowdedOutUnstakingPeriodLength(new BN(1))
-    .setRoleExpiredUnstakingPeriodLength(new BN(1))
-    .setSlashableMaxCount(new BN(1))
-    .setSlashableMaxPercentPtsPerTime(new BN(100))
-    .setSuccessfulApplicantApplicationStakeUnstakingPeriod(new BN(1))
-    .setFailedApplicantApplicationStakeUnstakingPeriod(new BN(1))
-    .setFailedApplicantRoleStakeUnstakingPeriod(new BN(1))
-    .setTerminateApplicationStakeUnstakingPeriod(new BN(1))
-    .setTerminateRoleStakeUnstakingPeriod(new BN(1))
-    .setExitRoleApplicationStakeUnstakingPeriod(new BN(1))
-    .setExitRoleStakeUnstakingPeriod(new BN(1))
-    .setText(uuid().substring(0, 8))
-    .setOpeningType('leader')
-
-  const addOpeningPromise: Promise<BN> = apiWrapper.expectOpeningAdded()
-  await apiWrapper.sudoAddOpening(sudo, opening, module)
-  const openingId: BN = await addOpeningPromise
-
-  return openingId
-}
-
-export async function acceptApplications(
-  apiWrapper: ApiWrapper,
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  openingId: BN,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const acceptApplicationsFee = apiWrapper.estimateAcceptApplicationsFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, acceptApplicationsFee)
-
-  // Begin accepting applications
-  await apiWrapper.acceptApplications(lead, openingId, module)
-
-  const opening: HiringOpening = await apiWrapper.getHiringOpening(openingId)
-  assert(opening.is_active, `Opening ${openingId} is not active`)
-}
-
-export async function applyForOpening(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  applicationStake: BN,
-  roleStake: BN,
-  openingId: BN,
-  module: WorkingGroups,
-  expectFailure: boolean
-): Promise<void> {
-  // Fee estimation and transfer
-  const applyOnOpeningFee: BN = apiWrapper.estimateApplyOnOpeningFee(sudo, module).add(applicationStake).add(roleStake)
-  await apiWrapper.transferBalanceToAccounts(sudo, membersKeyPairs, applyOnOpeningFee)
-
-  // Applying for created worker opening
-  await apiWrapper.batchApplyOnOpening(
-    membersKeyPairs,
-    openingId,
-    roleStake,
-    applicationStake,
-    uuid().substring(0, 8),
-    module,
-    expectFailure
-  )
-}
-
-export async function withdrawApplicaiton(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const withdrawApplicaitonFee: BN = apiWrapper.estimateWithdrawApplicationFee(module)
-  await apiWrapper.transferBalanceToAccounts(sudo, membersKeyPairs, withdrawApplicaitonFee)
-
-  // Application withdrawal
-  await apiWrapper.batchWithdrawApplication(membersKeyPairs, module)
-
-  // Assertions
-  membersKeyPairs.forEach(async (keyPair) => {
-    const activeApplications: BN[] = await apiWrapper.getActiveApplicationsIdsByRoleAccount(keyPair.address, module)
-    assert(activeApplications.length === 0, `Unexpected active application found for ${keyPair.address}`)
-  })
-}
-
-export async function beginApplicationReview(
-  apiWrapper: ApiWrapper,
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  openingId: BN,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const beginReviewFee: BN = apiWrapper.estimateBeginApplicantReviewFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, beginReviewFee)
-
-  // Begin application review
-  const beginApplicantReviewPromise: Promise<BN> = apiWrapper.expectApplicationReviewBegan()
-  await apiWrapper.beginApplicantReview(lead, openingId, module)
-  await beginApplicantReviewPromise
-}
-
-export async function beginLeaderApplicationReview(
-  apiWrapper: ApiWrapper,
-  sudo: KeyringPair,
-  openingId: BN,
-  module: WorkingGroups
-) {
-  // Begin application review
-  await apiWrapper.sudoBeginApplicantReview(sudo, openingId, module)
-}
-
-export async function fillOpening(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  openingId: BN,
-  firstPayoutInterval: BN,
-  payoutInterval: BN,
-  amountPerPayout: BN,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const beginReviewFee: BN = apiWrapper.estimateBeginApplicantReviewFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, beginReviewFee)
-  const applicationIds: BN[] = (
-    await Promise.all(
-      membersKeyPairs.map(async (keypair) => apiWrapper.getActiveApplicationsIdsByRoleAccount(keypair.address, module))
-    )
-  ).flat()
-
-  // Fill worker opening
-  const now: BN = await apiWrapper.getBestBlock()
-  const fillOpeningPromise: Promise<ApplicationIdToWorkerIdMap> = apiWrapper.expectOpeningFilled()
-  await apiWrapper.fillOpening(
-    lead,
-    openingId,
-    applicationIds,
-    amountPerPayout,
-    now.add(firstPayoutInterval),
-    payoutInterval,
-    module
-  )
-  const applicationIdToWorkerIdMap: ApplicationIdToWorkerIdMap = await fillOpeningPromise
-
-  // Assertions
-  applicationIdToWorkerIdMap.forEach(async (workerId, applicationId) => {
-    const worker: Worker = await apiWrapper.getWorkerById(workerId, module)
-    const application: Application = await apiWrapper.getApplicationById(applicationId, module)
-    assert(
-      worker.role_account_id.toString() === application.role_account_id.toString(),
-      `Role account ids does not match, worker account: ${worker.role_account_id}, application account ${application.role_account_id}`
-    )
-  })
-  const openingWorkersAccounts: string[] = (await apiWrapper.getWorkers(module)).map((worker) =>
-    worker.role_account_id.toString()
-  )
-  membersKeyPairs.forEach((keyPair) =>
-    assert(openingWorkersAccounts.includes(keyPair.address), `Account ${keyPair.address} is not worker`)
-  )
-}
-
-export async function fillLeaderOpening(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  openingId: BN,
-  firstPayoutInterval: BN,
-  payoutInterval: BN,
-  amountPerPayout: BN,
-  module: WorkingGroups
-) {
-  const applicationIds: BN[] = (
-    await Promise.all(
-      membersKeyPairs.map(async (keypair) => apiWrapper.getActiveApplicationsIdsByRoleAccount(keypair.address, module))
-    )
-  ).flat()
-
-  // Fill leader opening
-  const now: BN = await apiWrapper.getBestBlock()
-  const fillOpeningPromise: Promise<ApplicationIdToWorkerIdMap> = apiWrapper.expectOpeningFilled()
-  await apiWrapper.sudoFillOpening(
-    sudo,
-    openingId,
-    applicationIds,
-    amountPerPayout,
-    now.add(firstPayoutInterval),
-    payoutInterval,
-    module
-  )
-
-  // Assertions
-  const applicationIdToWorkerIdMap: ApplicationIdToWorkerIdMap = await fillOpeningPromise
-  applicationIdToWorkerIdMap.forEach(async (workerId, applicationId) => {
-    const worker: Worker = await apiWrapper.getWorkerById(workerId, module)
-    const application: Application = await apiWrapper.getApplicationById(applicationId, module)
-    assert(
-      worker.role_account_id.toString() === application.role_account_id.toString(),
-      `Role account ids does not match, leader account: ${worker.role_account_id}, application account ${application.role_account_id}`
-    )
-  })
-  const leadWorkerId: BN = (await apiWrapper.getLeadWorkerId(module))!
-  const openingLeaderAccount: string = (await apiWrapper.getWorkerById(leadWorkerId, module)).role_account_id.toString()
-  assert(
-    openingLeaderAccount === membersKeyPairs[0].address,
-    `Unexpected leader account ${openingLeaderAccount}, expected ${membersKeyPairs[0].address}`
-  )
-}
-
-export async function increaseStake(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const increaseStakeFee: BN = apiWrapper.estimateIncreaseStakeFee(module)
-  const stakeIncrement: BN = new BN(1)
-  await apiWrapper.transferBalance(sudo, membersKeyPairs[0].address, increaseStakeFee.add(stakeIncrement))
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-
-  // Increase worker stake
-  const increasedWorkerStake: BN = (await apiWrapper.getWorkerStakeAmount(workerId, module)).add(stakeIncrement)
-  await apiWrapper.increaseStake(membersKeyPairs[0], workerId, stakeIncrement, module)
-  const newWorkerStake: BN = await apiWrapper.getWorkerStakeAmount(workerId, module)
-  assert(
-    increasedWorkerStake.eq(newWorkerStake),
-    `Unexpected worker stake ${newWorkerStake}, expected ${increasedWorkerStake}`
-  )
-}
-
-export async function updateRewardAccount(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudo: KeyringPair,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const updateRewardAccountFee: BN = apiWrapper.estimateUpdateRewardAccountFee(sudo.address, module)
-  await apiWrapper.transferBalance(sudo, membersKeyPairs[0].address, updateRewardAccountFee)
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-
-  // Update reward account
-  const createdAccount: KeyringPair = keyring.addFromUri(uuid().substring(0, 8))
-  await apiWrapper.updateRewardAccount(membersKeyPairs[0], workerId, createdAccount.address, module)
-  const newRewardAccount: string = await apiWrapper.getWorkerRewardAccount(workerId, module)
-  assert(
-    newRewardAccount === createdAccount.address,
-    `Unexpected role account ${newRewardAccount}, expected ${createdAccount.address}`
-  )
-}
-
-export async function updateRoleAccount(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  keyring: Keyring,
-  sudo: KeyringPair,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const updateRoleAccountFee: BN = apiWrapper.estimateUpdateRoleAccountFee(sudo.address, module)
-  await apiWrapper.transferBalance(sudo, membersKeyPairs[0].address, updateRoleAccountFee)
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-
-  // Update role account
-  const createdAccount: KeyringPair = keyring.addFromUri(uuid().substring(0, 8))
-  await apiWrapper.updateRoleAccount(membersKeyPairs[0], workerId, createdAccount.address, module)
-  const newRoleAccount: string = (await apiWrapper.getWorkerById(workerId, module)).role_account_id.toString()
-  assert(
-    newRoleAccount === createdAccount.address,
-    `Unexpected role account ${newRoleAccount}, expected ${createdAccount.address}`
-  )
-}
-
-export async function terminateApplications(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const terminateApplicationFee = apiWrapper.estimateTerminateApplicationFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, terminateApplicationFee.muln(membersKeyPairs.length))
-
-  // Terminate worker applications
-  await apiWrapper.batchTerminateApplication(lead, membersKeyPairs, module)
-  membersKeyPairs.forEach(async (keyPair) => {
-    const activeApplications = await apiWrapper.getActiveApplicationsIdsByRoleAccount(keyPair.address, module)
-    assert(activeApplications.length === 0, `Account ${keyPair.address} has unexpected active applications`)
-  })
-}
-
-export async function decreaseStake(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  module: WorkingGroups,
-  expectFailure: boolean
-) {
-  // Fee estimation and transfer
-  const decreaseStakeFee = apiWrapper.estimateDecreaseStakeFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, decreaseStakeFee)
-  const workerStakeDecrement = new BN(1)
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-
-  // Worker stake decrement
-  const decreasedWorkerStake: BN = (await apiWrapper.getWorkerStakeAmount(workerId, module)).sub(workerStakeDecrement)
-  await apiWrapper.decreaseStake(lead, workerId, workerStakeDecrement, module, expectFailure)
-  const newWorkerStake: BN = await apiWrapper.getWorkerStakeAmount(workerId, module)
-
-  // Assertions
-  if (!expectFailure) {
-    assert(
-      decreasedWorkerStake.eq(newWorkerStake),
-      `Unexpected worker stake ${newWorkerStake}, expected ${decreasedWorkerStake}`
-    )
-  }
-}
-
-export async function slash(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  module: WorkingGroups,
-  expectFailure: boolean
-) {
-  // Fee estimation and transfer
-  const slashStakeFee = apiWrapper.estimateSlashStakeFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, slashStakeFee)
-  const slashAmount = new BN(1)
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-
-  // Slash worker
-  const slashedStake: BN = (await apiWrapper.getWorkerStakeAmount(workerId, module)).sub(slashAmount)
-  await apiWrapper.slashStake(lead, workerId, slashAmount, module, expectFailure)
-  const newStake: BN = await apiWrapper.getWorkerStakeAmount(workerId, module)
-
-  // Assertions
-  assert(slashedStake.eq(newStake), `Unexpected worker stake ${newStake}, expected ${slashedStake}`)
-}
-
-export async function terminateRole(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  lead: KeyringPair,
-  sudo: KeyringPair,
-  module: WorkingGroups,
-  expectFailure: boolean
-) {
-  // Fee estimation and transfer
-  const terminateRoleFee = apiWrapper.estimateTerminateRoleFee(module)
-  await apiWrapper.transferBalance(sudo, lead.address, terminateRoleFee)
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-
-  // Slash worker
-  await apiWrapper.terminateRole(lead, workerId, uuid().substring(0, 8), module, expectFailure)
-
-  // Assertions
-  apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-  const newWorkerId = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-  assert(newWorkerId === undefined, `Worker with account ${membersKeyPairs[0].address} is not terminated`)
-}
-
-export async function leaveRole(
-  apiWrapper: ApiWrapper,
-  membersKeyPairs: KeyringPair[],
-  sudo: KeyringPair,
-  module: WorkingGroups
-) {
-  // Fee estimation and transfer
-  const leaveRoleFee = apiWrapper.estimateLeaveRoleFee(module)
-  await apiWrapper.transferBalanceToAccounts(sudo, membersKeyPairs, leaveRoleFee)
-
-  await apiWrapper.batchLeaveRole(membersKeyPairs, uuid().substring(0, 8), false, module)
-
-  // Assertions
-  membersKeyPairs.forEach(async (keyPair) => {
-    apiWrapper.getWorkerIdByRoleAccount(keyPair.address, module)
-    const newWorkerId = await apiWrapper.getWorkerIdByRoleAccount(keyPair.address, module)
-    assert(newWorkerId === undefined, `Worker with account ${keyPair.address} is not terminated`)
-  })
-}
-
-export async function awaitPayout(apiWrapper: ApiWrapper, membersKeyPairs: KeyringPair[], module: WorkingGroups) {
-  const workerId: BN = await apiWrapper.getWorkerIdByRoleAccount(membersKeyPairs[0].address, module)
-  const worker: Worker = await apiWrapper.getWorkerById(workerId, module)
-  const reward: RewardRelationship = await apiWrapper.getRewardRelationship(worker.reward_relationship.unwrap())
-  const now: BN = await apiWrapper.getBestBlock()
-  const nextPaymentBlock: BN = new BN(reward.getField('next_payment_at_block').toString())
-  const payoutInterval: BN = new BN(reward.getField('payout_interval').toString())
-  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 apiWrapper.getBalance(membersKeyPairs[0].address)
-
-  const firstPayoutWaitingPeriod = nextPaymentBlock.sub(now).addn(1)
-  await Utils.wait(apiWrapper.getBlockDuration().mul(firstPayoutWaitingPeriod).toNumber())
-
-  const balanceAfterFirstPayout = await apiWrapper.getBalance(membersKeyPairs[0].address)
-  const expectedBalanceFirst = balance.add(amountPerPayout)
-  assert(
-    balanceAfterFirstPayout.eq(expectedBalanceFirst),
-    `Unexpected balance, expected ${expectedBalanceFirst} got ${balanceAfterFirstPayout}`
-  )
-
-  const secondPayoutWaitingPeriod = payoutInterval.addn(1)
-  await Utils.wait(apiWrapper.getBlockDuration().mul(secondPayoutWaitingPeriod).toNumber())
-
-  const balanceAfterSecondPayout = await apiWrapper.getBalance(membersKeyPairs[0].address)
-  const expectedBalanceSecond = expectedBalanceFirst.add(amountPerPayout)
-  assert(
-    balanceAfterSecondPayout.eq(expectedBalanceSecond),
-    `Unexpected balance, expected ${expectedBalanceSecond} got ${balanceAfterSecondPayout}`
-  )
-}
-
-export async function setMintCapacity(apiWrapper: ApiWrapper, sudo: KeyringPair, capacity: BN, module: WorkingGroups) {
-  await apiWrapper.sudoSetWorkingGroupMintCapacity(sudo, capacity, module)
-}
-
-export async function expectLeadOpeningAdded(apiWrapper: ApiWrapper): Promise<BN> {
-  return apiWrapper.expectOpeningAdded()
-}
-
-export async function expectLeaderSet(
-  apiWrapper: ApiWrapper,
-  leaderAddress: string,
-  module: WorkingGroups
-): Promise<BN> {
-  const leadWorkerId: BN = await apiWrapper.expectLeaderSet()
-  const worker: Worker = await apiWrapper.getWorkerById(leadWorkerId, module)
-  const leaderApplicationId = (await apiWrapper.getApplicationsIdsByRoleAccount(leaderAddress, module))[0]
-  const application: Application = await apiWrapper.getApplicationById(leaderApplicationId, module)
-  assert(
-    worker.role_account_id.eq(application.role_account_id),
-    `Role account ids does not match, leader account: ${worker.role_account_id}, application account ${application.role_account_id}`
-  )
-  return leadWorkerId
-}
-
-export async function expectBeganApplicationReview(apiWrapper: ApiWrapper): Promise<BN> {
-  return apiWrapper.expectApplicationReviewBegan()
-}
-
-export async function expectLeaderRoleTerminated(apiWrapper: ApiWrapper, module: WorkingGroups): Promise<void> {
-  await apiWrapper.expectLeaderTerminated()
-  const leadWorkerId: BN | undefined = await apiWrapper.getLeadWorkerId(module)
-  assert(leadWorkerId === undefined, `Unexpected lead worker id: ${leadWorkerId}, expected none`)
-  return
-}
-
-export async function expectLeaderRewardAmountUpdated(
-  apiWrapper: ApiWrapper,
-  expectedReward: BN,
-  module: WorkingGroups
-): Promise<void> {
-  await apiWrapper.expectWorkerRewardAmountUpdated()
-  const leadWorkerId: BN = (await apiWrapper.getLeadWorkerId(module))!
-  const receivedReward: BN = (await apiWrapper.getRewardRelationship(leadWorkerId)).getField<Balance>(
-    'amount_per_payout'
-  )
-  assert(
-    receivedReward.eq(expectedReward),
-    `Unexpected reward amount for worker with id ${leadWorkerId}: ${receivedReward}, expected ${expectedReward}`
-  )
-  return
-}
-
-export async function expectLeaderStakeDecreased(
-  apiWrapper: ApiWrapper,
-  expectedStake: BN,
-  module: WorkingGroups
-): Promise<void> {
-  await apiWrapper.expectWorkerStakeDecreased()
-  const leadWorkerId: BN = (await apiWrapper.getLeadWorkerId(module))!
-  const receivedStake: BN = await apiWrapper.getWorkerStakeAmount(leadWorkerId, module)
-  assert(
-    receivedStake.eq(expectedStake),
-    `Unexpected stake amount for worker with id ${leadWorkerId}: ${receivedStake}, expected ${expectedStake}`
-  )
-  return
-}
-
-export async function expectLeaderSlashed(
-  apiWrapper: ApiWrapper,
-  expectedStake: BN,
-  module: WorkingGroups
-): Promise<void> {
-  await apiWrapper.expectWorkerStakeSlashed()
-  const leadWorkerId: BN = (await apiWrapper.getLeadWorkerId(module))!
-  const receivedStake: BN = await apiWrapper.getWorkerStakeAmount(leadWorkerId, module)
-  assert(
-    receivedStake.eq(expectedStake),
-    `Unexpected stake amount for worker with id after slash ${leadWorkerId}: ${receivedStake}, expected ${expectedStake}`
-  )
-  return
-}
-
-export async function expectMintCapacityChanged(apiWrapper: ApiWrapper, expectedMintCapacity: BN): Promise<void> {
-  const receivedMintCapacity = await apiWrapper.expectMintCapacityChanged()
-  assert(
-    receivedMintCapacity.eq(expectedMintCapacity),
-    `Unexpected mint capacity: ${receivedMintCapacity}, expected ${expectedMintCapacity}`
-  )
-  return
-}

+ 0 - 207
tests/network-tests/src/nicaea/tests/workingGroup/manageWorkerAsLeadTest.ts

@@ -1,207 +0,0 @@
-import { initConfig } from '../../utils/config'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { membershipTest } from '../impl/membershipCreation'
-import {
-  addWorkerOpening,
-  applyForOpening,
-  beginApplicationReview,
-  fillOpening,
-  decreaseStake,
-  slash,
-  terminateRole,
-  addLeaderOpening,
-  beginLeaderApplicationReview,
-  fillLeaderOpening,
-  leaveRole,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap = require('tap')
-
-tap.mocha.describe('Manage worker as worker scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.WORKING_GROUP_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 60
-  const openingActivationDelay: BN = new BN(0)
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-
-  let leadOpenignId: BN
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  let openignId: BN
-  tap.test(
-    'Add worker opening',
-    async () =>
-      (openignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        unstakingPeriod,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      ))
-  )
-  tap.test(
-    'Apply for worker opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin application review', async () =>
-    beginApplicationReview(apiWrapper, leadKeyPair[0], sudo, openignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill worker opening', async () =>
-    fillOpening(
-      apiWrapper,
-      nKeyPairs,
-      leadKeyPair[0],
-      sudo,
-      openignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-  tap.test('Decrease worker stake, expect failure', async () =>
-    decreaseStake(apiWrapper, nKeyPairs, leadKeyPair[0], sudo, WorkingGroups.StorageWorkingGroup, true)
-  )
-
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  tap.test('Decrease worker stake', async () =>
-    decreaseStake(apiWrapper, nKeyPairs, leadKeyPair[0], sudo, WorkingGroups.StorageWorkingGroup, false)
-  )
-  tap.test('Slash worker', async () =>
-    slash(apiWrapper, nKeyPairs, leadKeyPair[0], sudo, WorkingGroups.StorageWorkingGroup, false)
-  )
-  tap.test('Terminate worker role', async () =>
-    terminateRole(apiWrapper, nKeyPairs, leadKeyPair[0], sudo, WorkingGroups.StorageWorkingGroup, false)
-  )
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})

+ 0 - 159
tests/network-tests/src/nicaea/tests/workingGroup/manageWorkerAsWorkerTest.ts

@@ -1,159 +0,0 @@
-import { initConfig } from '../../utils/config'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { membershipTest } from '../impl/membershipCreation'
-import {
-  addWorkerOpening,
-  applyForOpening,
-  beginApplicationReview,
-  fillOpening,
-  increaseStake,
-  updateRewardAccount,
-  updateRoleAccount,
-  addLeaderOpening,
-  beginLeaderApplicationReview,
-  fillLeaderOpening,
-  leaveRole,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap = require('tap')
-
-tap.mocha.describe('Manage worker as worker scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.WORKING_GROUP_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 38
-  const openingActivationDelay: BN = new BN(0)
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-
-  let leadOpenignId: BN
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  let openignId: BN
-  tap.test(
-    'Add worker opening',
-    async () =>
-      (openignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        unstakingPeriod,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      ))
-  )
-  tap.test(
-    'Apply for worker opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin application review', async () =>
-    beginApplicationReview(apiWrapper, leadKeyPair[0], sudo, openignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill worker opening', async () =>
-    fillOpening(
-      apiWrapper,
-      nKeyPairs,
-      leadKeyPair[0],
-      sudo,
-      openignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  tap.test('Increase worker stake', async () =>
-    increaseStake(apiWrapper, nKeyPairs, sudo, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Update reward account', async () =>
-    updateRewardAccount(apiWrapper, nKeyPairs, keyring, sudo, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Update role account', async () =>
-    updateRoleAccount(apiWrapper, nKeyPairs, keyring, sudo, WorkingGroups.StorageWorkingGroup)
-  )
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})

+ 0 - 160
tests/network-tests/src/nicaea/tests/workingGroup/workerApplicationHappyCaseTest.ts

@@ -1,160 +0,0 @@
-import { initConfig } from '../../utils/config'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { membershipTest } from '../impl/membershipCreation'
-import {
-  addWorkerOpening,
-  applyForOpening,
-  beginApplicationReview,
-  fillOpening,
-  withdrawApplicaiton,
-  addLeaderOpening,
-  beginLeaderApplicationReview,
-  fillLeaderOpening,
-  leaveRole,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap from 'tap'
-
-tap.mocha.describe('Worker application happy case scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.WORKING_GROUP_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 48
-  const openingActivationDelay: BN = new BN(0)
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-
-  let leadOpenignId: BN
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  let workerOpenignId: BN
-  tap.test(
-    'Add worker opening',
-    async () =>
-      (workerOpenignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        unstakingPeriod,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      ))
-  )
-  tap.test('Apply for worker opening', async () =>
-    applyForOpening(
-      apiWrapper,
-      nKeyPairs,
-      sudo,
-      applicationStake,
-      roleStake,
-      workerOpenignId,
-      WorkingGroups.StorageWorkingGroup,
-      false
-    )
-  )
-  tap.test('Withdraw worker application', async () =>
-    withdrawApplicaiton(apiWrapper, nKeyPairs, sudo, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Apply for worker opening', async () =>
-    applyForOpening(
-      apiWrapper,
-      nKeyPairs,
-      sudo,
-      applicationStake,
-      roleStake,
-      workerOpenignId,
-      WorkingGroups.StorageWorkingGroup,
-      false
-    )
-  )
-  tap.test('Begin application review', async () =>
-    beginApplicationReview(apiWrapper, leadKeyPair[0], sudo, workerOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill worker opening', async () =>
-    fillOpening(
-      apiWrapper,
-      nKeyPairs,
-      leadKeyPair[0],
-      sudo,
-      workerOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})

+ 0 - 160
tests/network-tests/src/nicaea/tests/workingGroup/workerApplicationRejectionCaseTest.ts

@@ -1,160 +0,0 @@
-import { initConfig } from '../../utils/config'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { membershipTest, createKeyPairs } from '../impl/membershipCreation'
-import {
-  addWorkerOpening,
-  applyForOpening,
-  acceptApplications,
-  terminateApplications,
-  addLeaderOpening,
-  beginLeaderApplicationReview,
-  fillLeaderOpening,
-  leaveRole,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap from 'tap'
-
-tap.mocha.describe('Worker application happy case scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.WORKING_GROUP_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  const applicationStake: BN = new BN(process.env.WORKING_GROUP_APPLICATION_STAKE!)
-  const roleStake: BN = new BN(process.env.WORKING_GROUP_ROLE_STAKE!)
-  const firstRewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.LONG_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const durationInBlocks = 38
-  const openingActivationDelay: BN = new BN(100)
-  const leadOpeningActivationDelay: BN = new BN(0)
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-  const nonMemberKeyPairs = createKeyPairs(keyring, N)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-
-  let leadOpenignId: BN
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpeningActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  let openignId: BN
-  tap.test(
-    'Add worker opening',
-    async () =>
-      (openignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        unstakingPeriod,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      ))
-  )
-  tap.test('Apply for worker opening, expect failure', async () =>
-    applyForOpening(
-      apiWrapper,
-      nKeyPairs,
-      sudo,
-      applicationStake,
-      roleStake,
-      openignId,
-      WorkingGroups.StorageWorkingGroup,
-      true
-    )
-  )
-  tap.test('Begin accepting worker applications', async () =>
-    acceptApplications(apiWrapper, leadKeyPair[0], sudo, openignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Apply for worker opening as non-member, expect failure', async () =>
-    applyForOpening(
-      apiWrapper,
-      nonMemberKeyPairs,
-      sudo,
-      applicationStake,
-      roleStake,
-      openignId,
-      WorkingGroups.StorageWorkingGroup,
-      true
-    )
-  )
-  tap.test('Apply for worker opening as member', async () =>
-    applyForOpening(
-      apiWrapper,
-      nKeyPairs,
-      sudo,
-      applicationStake,
-      roleStake,
-      openignId,
-      WorkingGroups.StorageWorkingGroup,
-      false
-    )
-  )
-  tap.test('Terminate worker applicaitons', async () =>
-    terminateApplications(apiWrapper, nKeyPairs, leadKeyPair[0], sudo, WorkingGroups.StorageWorkingGroup)
-  )
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})

+ 0 - 152
tests/network-tests/src/nicaea/tests/workingGroup/workerPayout.ts

@@ -1,152 +0,0 @@
-import { initConfig } from '../../utils/config'
-import { registerJoystreamTypes } from '@nicaea/types'
-import { closeApi } from '../impl/closeApi'
-import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { setTestTimeout } from '../../utils/setTestTimeout'
-import { membershipTest } from '../impl/membershipCreation'
-import {
-  addWorkerOpening,
-  applyForOpening,
-  beginApplicationReview,
-  fillOpening,
-  addLeaderOpening,
-  beginLeaderApplicationReview,
-  fillLeaderOpening,
-  leaveRole,
-  awaitPayout,
-  setMintCapacity,
-} from './impl/workingGroupModule'
-import BN from 'bn.js'
-import tap from 'tap'
-
-tap.mocha.describe('Worker application happy case scenario', async () => {
-  initConfig()
-  registerJoystreamTypes()
-
-  const nKeyPairs: KeyringPair[] = []
-  const leadKeyPair: KeyringPair[] = []
-
-  const keyring = new Keyring({ type: 'sr25519' })
-  const N: number = +process.env.WORKING_GROUP_N!
-  const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-  const nodeUrl: string = process.env.NODE_URL!
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-  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.SHORT_FIRST_REWARD_INTERVAL!)
-  const rewardInterval: BN = new BN(process.env.SHORT_REWARD_INTERVAL!)
-  const payoutAmount: BN = new BN(process.env.PAYOUT_AMOUNT!)
-  const unstakingPeriod: BN = new BN(process.env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
-  const mintCapacity: BN = new BN(process.env.STORAGE_WORKING_GROUP_MINTING_CAPACITY!)
-  const durationInBlocks = 48
-  const openingActivationDelay: BN = new BN(0)
-
-  const provider = new WsProvider(nodeUrl)
-  const apiWrapper: ApiWrapper = await ApiWrapper.create(provider)
-  const sudo: KeyringPair = keyring.addFromUri(sudoUri)
-
-  setTestTimeout(apiWrapper, durationInBlocks)
-  membershipTest(apiWrapper, nKeyPairs, keyring, N, paidTerms, sudoUri)
-  membershipTest(apiWrapper, leadKeyPair, keyring, 1, paidTerms, sudoUri)
-
-  let leadOpenignId: BN
-  tap.test(
-    'Add lead opening',
-    async () =>
-      (leadOpenignId = await addLeaderOpening(
-        apiWrapper,
-        nKeyPairs,
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        WorkingGroups.StorageWorkingGroup
-      ))
-  )
-  tap.test(
-    'Apply for lead opening',
-    async () =>
-      await applyForOpening(
-        apiWrapper,
-        leadKeyPair,
-        sudo,
-        applicationStake,
-        roleStake,
-        leadOpenignId,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      )
-  )
-  tap.test('Begin lead application review', async () =>
-    beginLeaderApplicationReview(apiWrapper, sudo, leadOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill lead opening', async () =>
-    fillLeaderOpening(
-      apiWrapper,
-      leadKeyPair,
-      sudo,
-      leadOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  let workerOpenignId: BN
-  tap.test(
-    'Add worker opening',
-    async () =>
-      (workerOpenignId = await addWorkerOpening(
-        apiWrapper,
-        nKeyPairs,
-        leadKeyPair[0],
-        sudo,
-        applicationStake,
-        roleStake,
-        openingActivationDelay,
-        unstakingPeriod,
-        WorkingGroups.StorageWorkingGroup,
-        false
-      ))
-  )
-  tap.test('Apply for worker opening', async () =>
-    applyForOpening(
-      apiWrapper,
-      nKeyPairs,
-      sudo,
-      applicationStake,
-      roleStake,
-      workerOpenignId,
-      WorkingGroups.StorageWorkingGroup,
-      false
-    )
-  )
-  tap.test('Begin application review', async () =>
-    beginApplicationReview(apiWrapper, leadKeyPair[0], sudo, workerOpenignId, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Set mint capacity', async () =>
-    setMintCapacity(apiWrapper, sudo, mintCapacity, WorkingGroups.StorageWorkingGroup)
-  )
-  tap.test('Fill worker opening', async () =>
-    fillOpening(
-      apiWrapper,
-      nKeyPairs,
-      leadKeyPair[0],
-      sudo,
-      workerOpenignId,
-      firstRewardInterval,
-      rewardInterval,
-      payoutAmount,
-      WorkingGroups.StorageWorkingGroup
-    )
-  )
-
-  tap.test('Await worker payout', async () => awaitPayout(apiWrapper, nKeyPairs, WorkingGroups.StorageWorkingGroup))
-
-  tap.test('Leaving lead role', async () => leaveRole(apiWrapper, leadKeyPair, sudo, WorkingGroups.StorageWorkingGroup))
-
-  closeApi(apiWrapper)
-})

+ 0 - 1547
tests/network-tests/src/nicaea/utils/apiWrapper.ts

@@ -1,1547 +0,0 @@
-import { ApiPromise, WsProvider } from '@polkadot/api'
-import { Option, Vec, Bytes, u32 } from '@polkadot/types'
-import { Codec } from '@polkadot/types/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { UserInfo, PaidMembershipTerms, MemberId } from '@nicaea/types/members'
-import { Mint, MintId } from '@nicaea/types/mint'
-import { Lead, LeadId } from '@nicaea/types/content-working-group'
-import { Application, WorkerId, Worker, ApplicationIdToWorkerIdMap, Opening } from '@nicaea/types/working-group'
-import { RoleParameters } from '@nicaea/types/roles'
-import { Seat } from '@nicaea/types/council'
-import { Balance, EventRecord, AccountId, BlockNumber, BalanceOf } from '@polkadot/types/interfaces'
-import BN from 'bn.js'
-import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { Sender } from './sender'
-import { Utils } from './utils'
-import { Stake, StakedState } from '@nicaea/types/stake'
-import { RewardRelationship } from '@nicaea/types/recurring-rewards'
-import { Opening as HiringOpening, Application as HiringApplication, ApplicationId } from '@nicaea/types/hiring'
-import { WorkingGroupOpening } from '../dto/workingGroupOpening'
-import { FillOpeningParameters } from '../dto/fillOpeningParameters'
-
-export enum WorkingGroups {
-  StorageWorkingGroup = 'storageWorkingGroup',
-}
-
-export class ApiWrapper {
-  private readonly api: ApiPromise
-  private readonly sender: Sender
-
-  public static async create(provider: WsProvider): Promise<ApiWrapper> {
-    const api = await ApiPromise.create({ provider })
-    return new ApiWrapper(api)
-  }
-
-  constructor(api: ApiPromise) {
-    this.api = api
-    this.sender = new Sender(api)
-  }
-
-  public close() {
-    this.api.disconnect()
-  }
-
-  public getWorkingGroupString(workingGroup: WorkingGroups): string {
-    switch (workingGroup) {
-      case WorkingGroups.StorageWorkingGroup:
-        return 'Storage'
-      default:
-        throw new Error(`Invalid working group string representation: ${workingGroup}`)
-    }
-  }
-
-  public async buyMembership(
-    account: KeyringPair,
-    paidTermsId: number,
-    name: string,
-    expectFailure = false
-  ): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' })),
-      account,
-      expectFailure
-    )
-  }
-
-  public getMemberIds(address: string): Promise<MemberId[]> {
-    return this.api.query.members.memberIdsByControllerAccountId<Vec<MemberId>>(address)
-  }
-
-  public getBalance(address: string): Promise<Balance> {
-    return this.api.query.balances.freeBalance<Balance>(address)
-  }
-
-  public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.balances.transfer(to, amount), from)
-  }
-
-  public getPaidMembershipTerms(paidTermsId: number): Promise<Option<PaidMembershipTerms>> {
-    return this.api.query.members.paidMembershipTermsById<Option<PaidMembershipTerms>>(paidTermsId)
-  }
-
-  public getMembershipFee(paidTermsId: number): Promise<BN> {
-    return this.getPaidMembershipTerms(paidTermsId).then((terms) => terms.unwrap().fee.toBn())
-  }
-
-  public async transferBalanceToAccounts(from: KeyringPair, to: KeyringPair[], amount: BN): Promise<void[]> {
-    return Promise.all(
-      to.map(async (keyPair) => {
-        await this.transferBalance(from, keyPair.address, amount)
-      })
-    )
-  }
-
-  private getBaseTxFee(): BN {
-    return this.api.createType('BalanceOf', this.api.consts.transactionPayment.transactionBaseFee).toBn()
-  }
-
-  private estimateTxFee(tx: SubmittableExtrinsic<'promise'>): BN {
-    const baseFee: BN = this.getBaseTxFee()
-    const byteFee: BN = this.api.createType('BalanceOf', this.api.consts.transactionPayment.transactionByteFee).toBn()
-    return Utils.calcTxLength(tx).mul(byteFee).add(baseFee)
-  }
-
-  public estimateBuyMembershipFee(account: KeyringPair, paidTermsId: number, name: string): BN {
-    return this.estimateTxFee(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' }))
-    )
-  }
-
-  public estimateApplyForCouncilFee(amount: BN): BN {
-    return this.estimateTxFee(this.api.tx.councilElection.apply(amount))
-  }
-
-  public estimateVoteForCouncilFee(nominee: string, salt: string, stake: BN): BN {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.estimateTxFee(this.api.tx.councilElection.vote(hashedVote, stake))
-  }
-
-  public estimateRevealVoteFee(nominee: string, salt: string): BN {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.estimateTxFee(this.api.tx.councilElection.reveal(hashedVote, nominee, salt))
-  }
-
-  public estimateProposeRuntimeUpgradeFee(stake: BN, name: string, description: string, runtime: Bytes | string): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createRuntimeUpgradeProposal(stake, name, description, stake, runtime)
-    )
-  }
-
-  public estimateProposeTextFee(stake: BN, name: string, description: string, text: string): BN {
-    return this.estimateTxFee(this.api.tx.proposalsCodex.createTextProposal(stake, name, description, stake, text))
-  }
-
-  public estimateProposeSpendingFee(
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN,
-    destination: string
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSpendingProposal(stake, title, description, stake, balance, destination)
-    )
-  }
-
-  public estimateProposeContentWorkingGroupMintCapacityFee(
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        stake,
-        title,
-        description,
-        stake,
-        balance
-      )
-    )
-  }
-
-  public estimateProposeValidatorCountFee(title: string, description: string, stake: BN): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetValidatorCountProposal(stake, title, description, stake, stake)
-    )
-  }
-
-  public estimateProposeLeadFee(title: string, description: string, stake: BN, address: string): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetLeadProposal(stake, title, description, stake, { stake, address })
-    )
-  }
-
-  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,
-    stake: BN,
-    announcingPeriod: BN,
-    votingPeriod: BN,
-    revealingPeriod: BN,
-    councilSize: BN,
-    candidacyLimit: BN,
-    newTermDuration: BN,
-    minCouncilStake: BN,
-    minVotingStake: BN
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetElectionParametersProposal(stake, title, description, stake, [
-        announcingPeriod,
-        votingPeriod,
-        revealingPeriod,
-        councilSize,
-        candidacyLimit,
-        newTermDuration,
-        minCouncilStake,
-        minVotingStake,
-      ])
-    )
-  }
-
-  public estimateVoteForProposalFee(): BN {
-    return this.estimateTxFee(this.api.tx.proposalsEngine.vote(0, 0, 'Approve'))
-  }
-
-  public estimateAddOpeningFee(opening: WorkingGroupOpening, module: WorkingGroups): BN {
-    return this.estimateTxFee(
-      this.api.tx[module].addOpening(
-        opening.getActivateAt(),
-        opening.getCommitment(),
-        opening.getText(),
-        opening.getOpeningType()
-      )
-    )
-  }
-
-  public estimateAcceptApplicationsFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].acceptApplications(0))
-  }
-
-  public estimateApplyOnOpeningFee(account: KeyringPair, module: WorkingGroups): BN {
-    return this.estimateTxFee(
-      this.api.tx[module].applyOnOpening(
-        0,
-        0,
-        account.address,
-        0,
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test'
-      )
-    )
-  }
-
-  public estimateBeginApplicantReviewFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].beginApplicantReview(0))
-  }
-
-  public estimateFillOpeningFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(
-      this.api.tx[module].fillOpening(0, [0], {
-        'amount_per_payout': 0,
-        'next_payment_at_block': 0,
-        'payout_interval': 0,
-      })
-    )
-  }
-
-  public estimateIncreaseStakeFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].increaseStake(0, 0))
-  }
-
-  public estimateDecreaseStakeFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].decreaseStake(0, 0))
-  }
-
-  public estimateUpdateRoleAccountFee(address: string, module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].updateRoleAccount(0, address))
-  }
-
-  public estimateUpdateRewardAccountFee(address: string, module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].updateRewardAccount(0, address))
-  }
-
-  public estimateLeaveRoleFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].leaveRole(0, 'Long justification text'))
-  }
-
-  public estimateWithdrawApplicationFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].withdrawApplication(0))
-  }
-
-  public estimateTerminateApplicationFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].terminateApplication(0))
-  }
-
-  public estimateSlashStakeFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(this.api.tx[module].slashStake(0, 0))
-  }
-
-  public estimateTerminateRoleFee(module: WorkingGroups): BN {
-    return this.estimateTxFee(
-      this.api.tx[module].terminateRole(
-        0,
-        'Long justification text explaining why the worker role will be terminated',
-        false
-      )
-    )
-  }
-
-  public estimateProposeCreateWorkingGroupLeaderOpeningFee(): BN {
-    const opening: WorkingGroupOpening = new WorkingGroupOpening()
-      .setActivateAtBlock(undefined)
-      .setMaxActiveApplicants(new BN(32))
-      .setMaxReviewPeriodLength(new BN(32))
-      .setApplicationStakingPolicyAmount(new BN(1))
-      .setApplicationCrowdedOutUnstakingPeriodLength(new BN(1))
-      .setApplicationExpiredUnstakingPeriodLength(new BN(1))
-      .setRoleStakingPolicyAmount(new BN(1))
-      .setRoleCrowdedOutUnstakingPeriodLength(new BN(1))
-      .setRoleExpiredUnstakingPeriodLength(new BN(1))
-      .setSlashableMaxCount(new BN(0))
-      .setSlashableMaxPercentPtsPerTime(new BN(0))
-      .setSuccessfulApplicantApplicationStakeUnstakingPeriod(new BN(1))
-      .setFailedApplicantApplicationStakeUnstakingPeriod(new BN(1))
-      .setFailedApplicantRoleStakeUnstakingPeriod(new BN(1))
-      .setTerminateApplicationStakeUnstakingPeriod(new BN(1))
-      .setTerminateRoleStakeUnstakingPeriod(new BN(1))
-      .setExitRoleApplicationStakeUnstakingPeriod(new BN(1))
-      .setExitRoleStakeUnstakingPeriod(new BN(1))
-
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
-        0,
-        'some long title for the purpose of testing',
-        'some long description for the purpose of testing',
-        0,
-        {
-          'activate_at': opening.getActivateAt(),
-          'commitment': opening.getCommitment(),
-          'human_readable_text': 'Opening readable text',
-          'working_group': 'Storage',
-        }
-      )
-    )
-  }
-
-  public estimateProposeBeginWorkingGroupLeaderApplicationReviewFee(): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createBeginReviewWorkingGroupLeaderApplicationsProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        0,
-        'Storage'
-      )
-    )
-  }
-
-  public estimateProposeFillLeaderOpeningFee(): BN {
-    const fillOpeningParameters: FillOpeningParameters = new FillOpeningParameters()
-      .setAmountPerPayout(new BN(1))
-      .setNextPaymentAtBlock(new BN(99999))
-      .setPayoutInterval(new BN(99999))
-      .setOpeningId(new BN(0))
-      .setSuccessfulApplicationId(new BN(0))
-      .setWorkingGroup('Storage')
-
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createFillWorkingGroupLeaderOpeningProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        fillOpeningParameters.getFillOpeningParameters()
-      )
-    )
-  }
-
-  public estimateProposeTerminateLeaderRoleFee(): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        {
-          'worker_id': 0,
-          'rationale': 'Exceptionaly long and extraordinary descriptive rationale',
-          'slash': true,
-          'working_group': 'Storage',
-        }
-      )
-    )
-  }
-
-  public estimateProposeLeaderRewardFee(): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetWorkingGroupLeaderRewardProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        0,
-        0,
-        'Storage'
-      )
-    )
-  }
-
-  public estimateProposeDecreaseLeaderStakeFee(): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createDecreaseWorkingGroupLeaderStakeProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        0,
-        0,
-        'Storage'
-      )
-    )
-  }
-
-  public estimateProposeSlashLeaderStakeFee(): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSlashWorkingGroupLeaderStakeProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        0,
-        0,
-        'Storage'
-      )
-    )
-  }
-
-  public estimateProposeWorkingGroupMintCapacityFee(): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetWorkingGroupMintCapacityProposal(
-        0,
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        'Some testing text used for estimation purposes which is longer than text expected during the test',
-        0,
-        0,
-        'Storage'
-      )
-    )
-  }
-
-  private applyForCouncilElection(account: KeyringPair, amount: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.councilElection.apply(amount), account, false)
-  }
-
-  public batchApplyForCouncilElection(accounts: KeyringPair[], amount: BN): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair) => {
-        await this.applyForCouncilElection(keyPair, amount)
-      })
-    )
-  }
-
-  public async getCouncilElectionStake(address: string): Promise<BN> {
-    // TODO alter then `applicantStake` type will be introduced
-    return this.api.query.councilElection.applicantStakes(address).then((stake) => {
-      const parsed = JSON.parse(stake.toString())
-      return new BN(parsed.new)
-    })
-  }
-
-  private voteForCouncilMember(account: KeyringPair, nominee: string, salt: string, stake: BN): Promise<void> {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.sender.signAndSend(this.api.tx.councilElection.vote(hashedVote, stake), account, false)
-  }
-
-  public batchVoteForCouncilMember(
-    accounts: KeyringPair[],
-    nominees: KeyringPair[],
-    salt: string[],
-    stake: BN
-  ): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair, index) => {
-        await this.voteForCouncilMember(keyPair, nominees[index].address, salt[index], stake)
-      })
-    )
-  }
-
-  private revealVote(account: KeyringPair, commitment: string, nominee: string, salt: string): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.councilElection.reveal(commitment, nominee, salt), account, false)
-  }
-
-  public batchRevealVote(accounts: KeyringPair[], nominees: KeyringPair[], salt: string[]): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair, index) => {
-        const commitment = Utils.hashVote(nominees[index].address, salt[index])
-        await this.revealVote(keyPair, commitment, nominees[index].address, salt[index])
-      })
-    )
-  }
-
-  // TODO consider using configurable genesis instead
-  public sudoStartAnnouncingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageAnnouncing(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoStartVotingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageVoting(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoStartRevealingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageRevealing(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoSetCouncilMintCapacity(sudo: KeyringPair, capacity: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.council.setCouncilMintCapacity(capacity)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoSetWorkingGroupMintCapacity(sudo: KeyringPair, capacity: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.sudo.sudo(this.api.tx[module].setMintCapacity(capacity)), sudo, false)
-  }
-
-  public getBestBlock(): Promise<BN> {
-    return this.api.derive.chain.bestNumber()
-  }
-
-  public getCouncil(): Promise<Seat[]> {
-    return this.api.query.council.activeCouncil<Vec<Codec>>().then((seats) => {
-      return (seats as unknown) as Seat[]
-    })
-  }
-
-  public getRuntime(): Promise<Bytes> {
-    return this.api.query.substrate.code<Bytes>()
-  }
-
-  public async proposeRuntime(
-    account: KeyringPair,
-    stake: BN,
-    name: string,
-    description: string,
-    runtime: Bytes | string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createRuntimeUpgradeProposal(memberId, name, description, stake, runtime),
-      account,
-      false
-    )
-  }
-
-  public async proposeText(
-    account: KeyringPair,
-    stake: BN,
-    name: string,
-    description: string,
-    text: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createTextProposal(memberId, name, description, stake, text),
-      account,
-      false
-    )
-  }
-
-  public async proposeSpending(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN,
-    destination: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSpendingProposal(memberId, title, description, stake, balance, destination),
-      account,
-      false
-    )
-  }
-
-  public async proposeContentWorkingGroupMintCapacity(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        balance
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeValidatorCount(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    validatorCount: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetValidatorCountProposal(memberId, title, description, stake, validatorCount),
-      account,
-      false
-    )
-  }
-
-  public async proposeLead(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    leadAccount: KeyringPair
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    const leadMemberId: BN = (await this.getMemberIds(leadAccount.address))[0].toBn()
-    const addressString: string = leadAccount.address
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetLeadProposal(memberId, title, description, stake, [
-        leadMemberId,
-        addressString,
-      ]),
-      account,
-      false
-    )
-  }
-
-  public async proposeEvictStorageProvider(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    storageProvider: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createEvictStorageProviderProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        storageProvider
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeStorageRoleParameters(
-    account: KeyringPair,
-    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
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetStorageRoleParametersProposal(memberId, title, description, stake, [
-        minStake,
-        minActors,
-        maxActors,
-        reward,
-        rewardPeriod,
-        bondingPeriod,
-        unbondingPeriod,
-        minServicePeriod,
-        startupGracePeriod,
-        entryRequestFee,
-      ]),
-      account,
-      false
-    )
-  }
-
-  public async proposeElectionParameters(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    announcingPeriod: BN,
-    votingPeriod: BN,
-    revealingPeriod: BN,
-    councilSize: BN,
-    candidacyLimit: BN,
-    newTermDuration: BN,
-    minCouncilStake: BN,
-    minVotingStake: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetElectionParametersProposal(memberId, title, description, stake, [
-        announcingPeriod,
-        votingPeriod,
-        revealingPeriod,
-        councilSize,
-        candidacyLimit,
-        newTermDuration,
-        minCouncilStake,
-        minVotingStake,
-      ]),
-      account,
-      false
-    )
-  }
-
-  public async proposeBeginWorkingGroupLeaderApplicationReview(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    openingId: BN,
-    workingGroup: string
-  ) {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createBeginReviewWorkingGroupLeaderApplicationsProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        openingId,
-        workingGroup
-      ),
-      account,
-      false
-    )
-  }
-
-  public approveProposal(account: KeyringPair, memberId: BN, proposal: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.proposalsEngine.vote(memberId, proposal, 'Approve'), account, false)
-  }
-
-  public batchApproveProposal(council: KeyringPair[], proposal: BN): Promise<void[]> {
-    return Promise.all(
-      council.map(async (keyPair) => {
-        const memberId: BN = (await this.getMemberIds(keyPair.address))[0].toBn()
-        await this.approveProposal(keyPair, memberId, proposal)
-      })
-    )
-  }
-
-  public getBlockDuration(): BN {
-    return this.api.createType('Moment', this.api.consts.babe.expectedBlockTime).toBn()
-  }
-
-  public expectProposalCreated(): Promise<BN> {
-    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(new BN(record.event.data[1].toString()))
-          }
-        })
-      })
-    })
-  }
-
-  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 expectProposalFinalized(): 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[1].toString().includes('Executed')
-          ) {
-            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 expectOpeningAdded(): Promise<BN> {
-    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() === 'OpeningAdded') {
-            unsubscribe()
-            resolve((record.event.data as unknown) as BN)
-          }
-        })
-      })
-    })
-  }
-
-  public expectLeaderSet(): Promise<BN> {
-    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() === 'LeaderSet') {
-            unsubscribe()
-            resolve((record.event.data as unknown) as BN)
-          }
-        })
-      })
-    })
-  }
-
-  public expectLeaderTerminated(): 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() === 'TerminatedLeader') {
-            unsubscribe()
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public expectWorkerRewardAmountUpdated(): 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() === 'WorkerRewardAmountUpdated') {
-            unsubscribe()
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public expectWorkerStakeDecreased(): 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() === 'StakeDecreased') {
-            unsubscribe()
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public expectWorkerStakeSlashed(): 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() === 'StakeSlashed') {
-            unsubscribe()
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public expectApplicationReviewBegan(): Promise<BN> {
-    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 BN)
-          }
-        })
-      })
-    })
-  }
-
-  public expectMintCapacityChanged(): Promise<BN> {
-    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() === 'MintCapacityChanged') {
-            unsubscribe()
-            resolve((record.event.data[1] as unknown) as BN)
-          }
-        })
-      })
-    })
-  }
-
-  public getTotalIssuance(): Promise<BN> {
-    return this.api.query.balances.totalIssuance<Balance>()
-  }
-
-  public async getRequiredProposalStake(numerator: number, denominator: number): Promise<BN> {
-    const issuance: number = await (await this.getTotalIssuance()).toNumber()
-    const stake = (issuance * numerator) / denominator
-    return new BN(stake.toFixed(0))
-  }
-
-  public getProposalCount(): Promise<BN> {
-    return this.api.query.proposalsEngine.proposalCount<u32>()
-  }
-
-  public async getContentWorkingGroupMintCapacity(): Promise<BN> {
-    const mintId: MintId = await this.api.query.contentWorkingGroup.mint<MintId>()
-    const mintCodec = await this.api.query.minting.mints<Codec[]>(mintId)
-    const mint: Mint = (mintCodec[0] as unknown) as Mint
-    return mint.getField<Balance>('capacity')
-  }
-
-  public async getWorkingGroupMintCapacity(module: WorkingGroups): Promise<BN> {
-    const mintId: MintId = await this.api.query[module].mint<MintId>()
-    const mintCodec = await this.api.query.minting.mints<Codec[]>(mintId)
-    const mint: Mint = (mintCodec[0] as unknown) as Mint
-    return mint.getField<Balance>('capacity')
-  }
-
-  public getValidatorCount(): Promise<BN> {
-    return this.api.query.staking.validatorCount<u32>()
-  }
-
-  public async getCurrentLeadAddress(): Promise<string> {
-    const leadId: Option<LeadId> = await this.api.query.contentWorkingGroup.currentLeadId<Option<LeadId>>()
-    const leadCodec = await this.api.query.contentWorkingGroup.leadById<Codec[]>(leadId.unwrap())
-    const lead = (leadCodec[0] as unknown) as Lead
-    return lead.role_account.toString()
-  }
-
-  public async createStorageProvider(account: KeyringPair): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    await this.sender.signAndSend(this.api.tx.actors.roleEntryRequest('StorageProvider', memberId), account, false)
-    await this.sender.signAndSend(this.api.tx.actors.stake('StorageProvider', account.address), account, false)
-    return
-  }
-
-  public async isStorageProvider(address: string): Promise<boolean> {
-    const storageProviders: Vec<AccountId> = await this.api.query.actors.accountIdsByRole<Vec<AccountId>>(
-      'StorageProvider'
-    )
-    const accountWorkers: BN = await this.getWorkerIdByRoleAccount(address, WorkingGroups.StorageWorkingGroup)
-    return accountWorkers !== undefined
-  }
-
-  public async addOpening(
-    leader: KeyringPair,
-    opening: WorkingGroupOpening,
-    module: WorkingGroups,
-    expectFailure: boolean
-  ): Promise<void> {
-    return this.sender.signAndSend(this.createAddOpeningTransaction(opening, module), leader, expectFailure)
-  }
-
-  public async sudoAddOpening(sudo: KeyringPair, opening: WorkingGroupOpening, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.createAddOpeningTransaction(opening, module)),
-      sudo,
-      false
-    )
-  }
-
-  public async proposeCreateWorkingGroupLeaderOpening(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    opening: WorkingGroupOpening,
-    workingGroup: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createAddWorkingGroupLeaderOpeningProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        opening.getAddOpeningParameters(workingGroup)
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeFillLeaderOpening(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    fillOpeningParameters: FillOpeningParameters
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createFillWorkingGroupLeaderOpeningProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        fillOpeningParameters.getFillOpeningParameters()
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeTerminateLeaderRole(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    leadWorkerId: BN,
-    rationale: string,
-    slash: boolean,
-    workingGroup: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createTerminateWorkingGroupLeaderRoleProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        {
-          'worker_id': leadWorkerId,
-          rationale,
-          slash,
-          'working_group': workingGroup,
-        }
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeLeaderReward(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    workerId: BN,
-    rewardAmount: BN,
-    workingGroup: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetWorkingGroupLeaderRewardProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        workerId,
-        rewardAmount,
-        workingGroup
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeDecreaseLeaderStake(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    workerId: BN,
-    rewardAmount: BN,
-    workingGroup: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createDecreaseWorkingGroupLeaderStakeProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        workerId,
-        rewardAmount,
-        workingGroup
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeSlashLeaderStake(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    workerId: BN,
-    rewardAmount: BN,
-    workingGroup: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSlashWorkingGroupLeaderStakeProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        workerId,
-        rewardAmount,
-        workingGroup
-      ),
-      account,
-      false
-    )
-  }
-
-  public async proposeWorkingGroupMintCapacity(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    proposalStake: BN,
-    mintCapacity: BN,
-    workingGroup: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetWorkingGroupMintCapacityProposal(
-        memberId,
-        title,
-        description,
-        proposalStake,
-        mintCapacity,
-        workingGroup
-      ),
-      account,
-      false
-    )
-  }
-
-  private createAddOpeningTransaction(
-    opening: WorkingGroupOpening,
-    module: WorkingGroups
-  ): SubmittableExtrinsic<'promise'> {
-    return this.api.tx[module].addOpening(
-      opening.getActivateAt(),
-      opening.getCommitment(),
-      opening.getText(),
-      opening.getOpeningType()
-    )
-  }
-
-  public async acceptApplications(leader: KeyringPair, openingId: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].acceptApplications(openingId), leader, false)
-  }
-
-  public async beginApplicantReview(leader: KeyringPair, openingId: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].beginApplicantReview(openingId), leader, false)
-  }
-
-  public async sudoBeginApplicantReview(sudo: KeyringPair, openingId: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx[module].beginApplicantReview(openingId)),
-      sudo,
-      false
-    )
-  }
-
-  public async applyOnOpening(
-    account: KeyringPair,
-    roleAccountAddress: string,
-    openingId: BN,
-    roleStake: BN,
-    applicantStake: BN,
-    text: string,
-    expectFailure: boolean,
-    module: WorkingGroups
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0]
-    return this.sender.signAndSend(
-      this.api.tx[module].applyOnOpening(memberId, openingId, roleAccountAddress, roleStake, applicantStake, text),
-      account,
-      expectFailure
-    )
-  }
-
-  public async batchApplyOnOpening(
-    accounts: KeyringPair[],
-    openingId: BN,
-    roleStake: BN,
-    applicantStake: BN,
-    text: string,
-    module: WorkingGroups,
-    expectFailure: boolean
-  ): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair) => {
-        await this.applyOnOpening(
-          keyPair,
-          keyPair.address,
-          openingId,
-          roleStake,
-          applicantStake,
-          text,
-          expectFailure,
-          module
-        )
-      })
-    )
-  }
-
-  public async fillOpening(
-    leader: KeyringPair,
-    openingId: BN,
-    applicationId: BN[],
-    amountPerPayout: BN,
-    nextPaymentBlock: BN,
-    payoutInterval: BN,
-    module: WorkingGroups
-  ): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx[module].fillOpening(openingId, applicationId, {
-        'amount_per_payout': amountPerPayout,
-        'next_payment_at_block': nextPaymentBlock,
-        'payout_interval': payoutInterval,
-      }),
-      leader,
-      false
-    )
-  }
-
-  public async sudoFillOpening(
-    sudo: KeyringPair,
-    openingId: BN,
-    applicationId: BN[],
-    amountPerPayout: BN,
-    nextPaymentBlock: BN,
-    payoutInterval: BN,
-    module: WorkingGroups
-  ): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(
-        this.api.tx[module].fillOpening(openingId, applicationId, {
-          'amount_per_payout': amountPerPayout,
-          'next_payment_at_block': nextPaymentBlock,
-          'payout_interval': payoutInterval,
-        })
-      ),
-      sudo,
-      false
-    )
-  }
-
-  public async increaseStake(worker: KeyringPair, workerId: BN, stake: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].increaseStake(workerId, stake), worker, false)
-  }
-
-  public async decreaseStake(
-    leader: KeyringPair,
-    workerId: BN,
-    stake: BN,
-    module: WorkingGroups,
-    expectFailure: boolean
-  ): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].decreaseStake(workerId, stake), leader, expectFailure)
-  }
-
-  public async slashStake(
-    leader: KeyringPair,
-    workerId: BN,
-    stake: BN,
-    module: WorkingGroups,
-    expectFailure: boolean
-  ): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].slashStake(workerId, stake), leader, expectFailure)
-  }
-
-  public async updateRoleAccount(
-    worker: KeyringPair,
-    workerId: BN,
-    newRoleAccount: string,
-    module: WorkingGroups
-  ): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].updateRoleAccount(workerId, newRoleAccount), worker, false)
-  }
-
-  public async updateRewardAccount(
-    worker: KeyringPair,
-    workerId: BN,
-    newRewardAccount: string,
-    module: WorkingGroups
-  ): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].updateRewardAccount(workerId, newRewardAccount), worker, false)
-  }
-
-  public async withdrawApplication(account: KeyringPair, workerId: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].withdrawApplication(workerId), account, false)
-  }
-
-  public async batchWithdrawApplication(accounts: KeyringPair[], module: WorkingGroups): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair) => {
-        const applicationIds: BN[] = await this.getApplicationsIdsByRoleAccount(keyPair.address, module)
-        await this.withdrawApplication(keyPair, applicationIds[0], module)
-      })
-    )
-  }
-
-  public async terminateApplication(leader: KeyringPair, applicationId: BN, module: WorkingGroups): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].terminateApplication(applicationId), leader, false)
-  }
-
-  public async batchTerminateApplication(
-    leader: KeyringPair,
-    roleAccounts: KeyringPair[],
-    module: WorkingGroups
-  ): Promise<void[]> {
-    return Promise.all(
-      roleAccounts.map(async (keyPair) => {
-        const applicationIds: BN[] = await this.getActiveApplicationsIdsByRoleAccount(keyPair.address, module)
-        await this.terminateApplication(leader, applicationIds[0], module)
-      })
-    )
-  }
-
-  public async terminateRole(
-    leader: KeyringPair,
-    applicationId: BN,
-    text: string,
-    module: WorkingGroups,
-    expectFailure: boolean
-  ): Promise<void> {
-    return this.sender.signAndSend(this.api.tx[module].terminateRole(applicationId, text, false), leader, expectFailure)
-  }
-
-  public async leaveRole(
-    account: KeyringPair,
-    text: string,
-    expectFailure: boolean,
-    module: WorkingGroups
-  ): Promise<void> {
-    const workerId: BN = await this.getWorkerIdByRoleAccount(account.address, module)
-    return this.sender.signAndSend(this.api.tx[module].leaveRole(workerId, text), account, expectFailure)
-  }
-
-  public async batchLeaveRole(
-    roleAccounts: KeyringPair[],
-    text: string,
-    expectFailure: boolean,
-    module: WorkingGroups
-  ): Promise<void[]> {
-    return Promise.all(
-      roleAccounts.map(async (keyPair) => {
-        await this.leaveRole(keyPair, text, expectFailure, module)
-      })
-    )
-  }
-
-  public async getStorageRoleParameters(): Promise<RoleParameters> {
-    return (await this.api.query.actors.parameters<Option<RoleParameters>>('StorageProvider')).unwrap()
-  }
-
-  public async getAnnouncingPeriod(): Promise<BN> {
-    return this.api.query.councilElection.announcingPeriod<BlockNumber>()
-  }
-
-  public async getVotingPeriod(): Promise<BN> {
-    return this.api.query.councilElection.votingPeriod<BlockNumber>()
-  }
-
-  public async getRevealingPeriod(): Promise<BN> {
-    return this.api.query.councilElection.revealingPeriod<BlockNumber>()
-  }
-
-  public async getCouncilSize(): Promise<BN> {
-    return this.api.query.councilElection.councilSize<u32>()
-  }
-
-  public async getCandidacyLimit(): Promise<BN> {
-    return this.api.query.councilElection.candidacyLimit<u32>()
-  }
-
-  public async getNewTermDuration(): Promise<BN> {
-    return this.api.query.councilElection.newTermDuration<BlockNumber>()
-  }
-
-  public async getMinCouncilStake(): Promise<BN> {
-    return this.api.query.councilElection.minCouncilStake<BalanceOf>()
-  }
-
-  public async getMinVotingStake(): Promise<BN> {
-    return this.api.query.councilElection.minVotingStake<BalanceOf>()
-  }
-
-  public async getNextOpeningId(module: WorkingGroups): Promise<BN> {
-    return this.api.query[module].nextOpeningId<u32>()
-  }
-
-  public async getNextApplicationId(module: WorkingGroups): Promise<BN> {
-    return this.api.query[module].nextApplicationId<u32>()
-  }
-
-  public async getOpening(id: BN, module: WorkingGroups): Promise<Opening> {
-    return ((await this.api.query[module].openingById<Codec[]>(id))[0] as unknown) as Opening
-  }
-
-  public async getHiringOpening(id: BN): Promise<HiringOpening> {
-    return ((await this.api.query.hiring.openingById<Codec[]>(id))[0] as unknown) as HiringOpening
-  }
-
-  public async getWorkers(module: WorkingGroups): Promise<Worker[]> {
-    return ((await this.api.query[module].workerById<Codec[]>())[1] as unknown) as Worker[]
-  }
-
-  public async getWorkerById(id: BN, module: WorkingGroups): Promise<Worker> {
-    return ((await this.api.query[module].workerById<Codec[]>(id))[0] as unknown) as Worker
-  }
-
-  public async getWorkerIdByRoleAccount(address: string, module: WorkingGroups): Promise<BN> {
-    const workersAndIds = await this.api.query[module].workerById<Codec[]>()
-    const workers: Worker[] = (workersAndIds[1] as unknown) as Worker[]
-    const ids: WorkerId[] = (workersAndIds[0] as unknown) as WorkerId[]
-    const index: number = workers.findIndex((worker) => worker.role_account_id.toString() === address)
-    return ids[index]
-  }
-
-  public async getApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<BN[]> {
-    const applicationsAndIds = await this.api.query[module].applicationById<Codec[]>()
-    const applications: Application[] = (applicationsAndIds[1] as unknown) as Application[]
-    const ids: ApplicationId[] = (applicationsAndIds[0] as unknown) as ApplicationId[]
-    return applications
-      .map((application, index) => (application.role_account_id.toString() === address ? ids[index] : undefined))
-      .filter((id) => id !== undefined) as BN[]
-  }
-
-  public async getHiringApplicationById(id: BN): Promise<HiringApplication> {
-    return ((await this.api.query.hiring.applicationById<Codec[]>(id))[0] as unknown) as HiringApplication
-  }
-
-  public async getApplicationById(id: BN, module: WorkingGroups): Promise<Application> {
-    return ((await this.api.query[module].applicationById<Codec[]>(id))[0] as unknown) as Application
-  }
-
-  public async getActiveApplicationsIdsByRoleAccount(address: string, module: WorkingGroups): Promise<BN[]> {
-    const applicationsAndIds = await this.api.query[module].applicationById<Codec[]>()
-    const applications: Application[] = (applicationsAndIds[1] as unknown) as Application[]
-    const ids: ApplicationId[] = (applicationsAndIds[0] as unknown) as ApplicationId[]
-    return (
-      await Promise.all(
-        applications.map(async (application, index) => {
-          if (
-            application.role_account_id.toString() === address &&
-            (await this.getHiringApplicationById(application.application_id)).stage.type === 'Active'
-          ) {
-            return ids[index]
-          } else {
-            return undefined
-          }
-        })
-      )
-    ).filter((index) => index !== undefined) as BN[]
-  }
-
-  public async getStake(id: BN): Promise<Stake> {
-    return ((await this.api.query.stake.stakes<Codec[]>(id))[0] as unknown) as Stake
-  }
-
-  public async getWorkerStakeAmount(workerId: BN, module: WorkingGroups): Promise<BN> {
-    const stakeId: BN = (await this.getWorkerById(workerId, module)).role_stake_profile.unwrap().stake_id
-    return (((await this.getStake(stakeId)).staking_status.value as unknown) as StakedState).staked_amount
-  }
-
-  public async getRewardRelationship(id: BN): Promise<RewardRelationship> {
-    return ((
-      await this.api.query.recurringRewards.rewardRelationships<Codec[]>(id)
-    )[0] as unknown) as RewardRelationship
-  }
-
-  public async getWorkerRewardAccount(workerId: BN, module: WorkingGroups): Promise<string> {
-    const rewardRelationshipId: BN = (await this.getWorkerById(workerId, module)).reward_relationship.unwrap()
-    return (await this.getRewardRelationship(rewardRelationshipId)).getField('account').toString()
-  }
-
-  public async getLeadWorkerId(module: WorkingGroups): Promise<BN | undefined> {
-    return (await this.api.query[module].currentLead<Option<WorkerId>>()).unwrapOr(undefined)
-  }
-}

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

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

+ 0 - 66
tests/network-tests/src/nicaea/utils/sender.ts

@@ -1,66 +0,0 @@
-import BN from 'bn.js'
-import { ApiPromise } from '@polkadot/api'
-import { Index } from '@polkadot/types/interfaces'
-import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-
-export class Sender {
-  private readonly api: ApiPromise
-  private static nonceMap: Map<string, BN> = new Map()
-
-  constructor(api: ApiPromise) {
-    this.api = api
-  }
-
-  private async getNonce(address: string): Promise<BN> {
-    let oncahinNonce: BN = new BN(0)
-    if (!Sender.nonceMap.get(address)) {
-      oncahinNonce = await this.api.query.system.accountNonce<Index>(address)
-    }
-    let nonce: BN | undefined = Sender.nonceMap.get(address)
-    if (!nonce) {
-      nonce = oncahinNonce
-    }
-    const nextNonce: BN = nonce.addn(1)
-    Sender.nonceMap.set(address, nextNonce)
-    return nonce
-  }
-
-  private clearNonce(address: string): void {
-    Sender.nonceMap.delete(address)
-  }
-
-  public async signAndSend(
-    tx: SubmittableExtrinsic<'promise'>,
-    account: KeyringPair,
-    expectFailure = false
-  ): Promise<void> {
-    return new Promise(async (resolve, reject) => {
-      const nonce: BN = await this.getNonce(account.address)
-      const signedTx = tx.sign(account, { nonce })
-      await signedTx
-        .send(async (result) => {
-          if (result.status.isFinalized === true && result.events !== undefined) {
-            result.events.forEach((event) => {
-              if (event.event.method === 'ExtrinsicFailed') {
-                if (expectFailure) {
-                  resolve()
-                } else {
-                  reject(new Error('Extrinsic failed unexpectedly'))
-                }
-              }
-            })
-            resolve()
-          }
-          if (result.status.isFuture) {
-            console.log('nonce ' + nonce + ' for account ' + account.address + ' is in future')
-            this.clearNonce(account.address)
-            reject(new Error('Extrinsic nonce is in future'))
-          }
-        })
-        .catch((error) => {
-          reject(error)
-        })
-    })
-  }
-}

+ 0 - 7
tests/network-tests/src/nicaea/utils/setTestTimeout.ts

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

+ 0 - 53
tests/network-tests/src/nicaea/utils/utils.ts

@@ -1,53 +0,0 @@
-import { IExtrinsic } from '@polkadot/types/types'
-import { compactToU8a, stringToU8a } from '@polkadot/util'
-import { blake2AsHex } from '@polkadot/util-crypto'
-import BN from 'bn.js'
-import fs from 'fs'
-import { decodeAddress } from '@polkadot/keyring'
-import { Seat } from '@nicaea/types/council'
-
-export class Utils {
-  private static LENGTH_ADDRESS = 32 + 1 // publicKey + prefix
-  private static LENGTH_ERA = 2 // assuming mortals
-  private static LENGTH_SIGNATURE = 64 // assuming ed25519 or sr25519
-  private static LENGTH_VERSION = 1 // 0x80 & version
-
-  public static calcTxLength = (extrinsic?: IExtrinsic | null, nonce?: BN): BN => {
-    return new BN(
-      Utils.LENGTH_VERSION +
-        Utils.LENGTH_ADDRESS +
-        Utils.LENGTH_SIGNATURE +
-        Utils.LENGTH_ERA +
-        compactToU8a(nonce || 0).length +
-        (extrinsic ? extrinsic.encodedLength : 0)
-    )
-  }
-
-  /** hash(accountId + salt) */
-  public static hashVote(accountId: string, salt: string): string {
-    const accountU8a = decodeAddress(accountId)
-    const saltU8a = stringToU8a(salt)
-    const voteU8a = new Uint8Array(accountU8a.length + saltU8a.length)
-    voteU8a.set(accountU8a)
-    voteU8a.set(saltU8a, accountU8a.length)
-
-    const hash = blake2AsHex(voteU8a, 256)
-    return hash
-  }
-
-  public static wait(ms: number): Promise<void> {
-    return new Promise((resolve) => setTimeout(resolve, ms))
-  }
-
-  public static getTotalStake(seat: Seat): BN {
-    return new BN(+seat.stake.toString() + seat.backers.reduce((a, baker) => a + +baker.stake.toString(), 0))
-  }
-
-  public static readRuntimeFromFile(path: string): string {
-    return '0x' + fs.readFileSync(path).toString('hex')
-  }
-
-  public static camelToSnakeCase(key: string): string {
-    return key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)
-  }
-}

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


+ 0 - 27
tests/network-tests/src/rome/tests/electingCouncilTest.ts

@@ -1,27 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { councilTest } from './impl/electingCouncil'
-import { initConfig } from '../utils/config'
-import { Keyring } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTimeout } from './impl/setTimeout'
-
-initConfig()
-
-const m1KeyPairs: KeyringPair[] = []
-const m2KeyPairs: KeyringPair[] = []
-
-const keyring = new Keyring({ type: 'sr25519' })
-const N: number = +process.env.MEMBERSHIP_CREATION_N!
-const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-const nodeUrl: string = process.env.NODE_URL!
-const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-const K: number = +process.env.COUNCIL_ELECTION_K!
-const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-const durationInBlocks = 25
-
-setTimeout(nodeUrl, durationInBlocks)
-membershipTest(m1KeyPairs, keyring, N, paidTerms, nodeUrl, sudoUri)
-membershipTest(m2KeyPairs, keyring, N, paidTerms, nodeUrl, sudoUri)
-councilTest(m1KeyPairs, m2KeyPairs, keyring, K, nodeUrl, sudoUri, greaterStake, lesserStake)

+ 0 - 111
tests/network-tests/src/rome/tests/impl/electingCouncil.ts

@@ -1,111 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { WsProvider, Keyring } from '@polkadot/api'
-import BN from 'bn.js'
-import { registerJoystreamTypes, Seat } from '@rome/types'
-import { assert } from 'chai'
-import { v4 as uuid } from 'uuid'
-import { Utils } from '../../utils/utils'
-import tap from 'tap'
-
-export function councilTest(
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  k: number,
-  nodeUrl: string,
-  sudoUri: string,
-  greaterStake: BN,
-  lesserStake: BN
-) {
-  let sudo: KeyringPair
-  let apiWrapper: ApiWrapper
-
-  tap.test('Electing council test setup', async () => {
-    registerJoystreamTypes()
-    const provider = new WsProvider(nodeUrl)
-    apiWrapper = await ApiWrapper.create(provider)
-  })
-
-  tap.test('Electing a council test', async () => {
-    // Setup goes here because M keypairs are generated after before() function
-    sudo = keyring.addFromUri(sudoUri)
-    let now = await apiWrapper.getBestBlock()
-    const applyForCouncilFee: BN = apiWrapper.estimateApplyForCouncilFee(greaterStake)
-    const voteForCouncilFee: BN = apiWrapper.estimateVoteForCouncilFee(sudo.address, sudo.address, greaterStake)
-    const salt: string[] = []
-    m1KeyPairs.forEach(() => {
-      salt.push(''.concat(uuid().replace(/-/g, '')))
-    })
-    const revealVoteFee: BN = apiWrapper.estimateRevealVoteFee(sudo.address, salt[0])
-
-    // Topping the balances
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, applyForCouncilFee.add(greaterStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m1KeyPairs, voteForCouncilFee.add(revealVoteFee).add(greaterStake))
-
-    // First K members stake more
-    await apiWrapper.sudoStartAnnouncingPerion(sudo, now.addn(100))
-    await apiWrapper.batchApplyForCouncilElection(m2KeyPairs.slice(0, k), greaterStake)
-    m2KeyPairs.slice(0, k).forEach((keyPair) =>
-      apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
-        assert(
-          stake.eq(greaterStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${greaterStake}`
-        )
-      })
-    )
-
-    // Last members stake less
-    await apiWrapper.batchApplyForCouncilElection(m2KeyPairs.slice(k), lesserStake)
-    m2KeyPairs.slice(k).forEach((keyPair) =>
-      apiWrapper.getCouncilElectionStake(keyPair.address).then((stake) => {
-        assert(
-          stake.eq(lesserStake),
-          `${keyPair.address} not applied correctrly for council election with stake ${stake} versus expected ${lesserStake}`
-        )
-      })
-    )
-
-    // Voting
-    await apiWrapper.sudoStartVotingPerion(sudo, now.addn(100))
-    await apiWrapper.batchVoteForCouncilMember(
-      m1KeyPairs.slice(0, k),
-      m2KeyPairs.slice(0, k),
-      salt.slice(0, k),
-      lesserStake
-    )
-    await apiWrapper.batchVoteForCouncilMember(m1KeyPairs.slice(k), m2KeyPairs.slice(k), salt.slice(k), greaterStake)
-
-    // Revealing
-    await apiWrapper.sudoStartRevealingPerion(sudo, now.addn(100))
-    await apiWrapper.batchRevealVote(m1KeyPairs.slice(0, k), m2KeyPairs.slice(0, k), salt.slice(0, k))
-    await apiWrapper.batchRevealVote(m1KeyPairs.slice(k), m2KeyPairs.slice(k), salt.slice(k))
-    now = await apiWrapper.getBestBlock()
-
-    // Resolving election
-    // 3 is to ensure the revealing block is in future
-    await apiWrapper.sudoStartRevealingPerion(sudo, now.addn(3))
-    await Utils.wait(apiWrapper.getBlockDuration().muln(2.5).toNumber())
-    const seats: Seat[] = await apiWrapper.getCouncil()
-
-    // Preparing collections to increase assertion readability
-    const m2addresses: string[] = m2KeyPairs.map((keyPair) => keyPair.address)
-    const m1addresses: string[] = m1KeyPairs.map((keyPair) => keyPair.address)
-    const members: string[] = seats.map((seat) => seat.member.toString())
-    const bakers: string[] = seats.map((seat) => seat.backers.map((baker) => baker.member.toString())).flat()
-
-    // Assertions
-    m2addresses.forEach((address) => assert(members.includes(address), `Account ${address} is not in the council`))
-    m1addresses.forEach((address) => assert(bakers.includes(address), `Account ${address} is not in the voters`))
-    seats.forEach((seat) =>
-      assert(
-        Utils.getTotalStake(seat).eq(greaterStake.add(lesserStake)),
-        `Member ${seat.member} has unexpected stake ${Utils.getTotalStake(seat)}`
-      )
-    )
-  })
-
-  tap.teardown(() => {
-    apiWrapper.close()
-  })
-}

+ 0 - 88
tests/network-tests/src/rome/tests/impl/membershipCreation.ts

@@ -1,88 +0,0 @@
-import { WsProvider } from '@polkadot/api'
-import { registerJoystreamTypes } from '@rome/types'
-import { Keyring } from '@polkadot/keyring'
-import { assert } from 'chai'
-import { KeyringPair } from '@polkadot/keyring/types'
-import BN from 'bn.js'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { v4 as uuid } from 'uuid'
-import tap from 'tap'
-
-export function membershipTest(
-  nKeyPairs: KeyringPair[],
-  keyring: Keyring,
-  n: number,
-  paidTerms: number,
-  nodeUrl: string,
-  sudoUri: string
-) {
-  let apiWrapper: ApiWrapper
-  let sudo: KeyringPair
-  let aKeyPair: KeyringPair
-  let membershipFee: BN
-  let membershipTransactionFee: BN
-
-  tap.test('Membership creation test setup', async () => {
-    registerJoystreamTypes()
-    const provider = new WsProvider(nodeUrl)
-    apiWrapper = await ApiWrapper.create(provider)
-    sudo = keyring.addFromUri(sudoUri)
-    for (let i = 0; i < n; i++) {
-      nKeyPairs.push(keyring.addFromUri(i + uuid().substring(0, 8)))
-    }
-    aKeyPair = keyring.addFromUri(uuid().substring(0, 8))
-    membershipFee = await apiWrapper.getMembershipFee(paidTerms)
-    membershipTransactionFee = apiWrapper.estimateBuyMembershipFee(
-      sudo,
-      paidTerms,
-      'member_name_which_is_longer_than_expected'
-    )
-    await apiWrapper.transferBalanceToAccounts(sudo, nKeyPairs, membershipTransactionFee.add(new BN(membershipFee)))
-    await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipTransactionFee)
-  })
-
-  tap.test('Buy membeship is accepted with sufficient funds', async () => {
-    await Promise.all(
-      nKeyPairs.map(async (keyPair, index) => {
-        await apiWrapper.buyMembership(keyPair, paidTerms, `new_member_${index}${keyPair.address.substring(0, 8)}`)
-      })
-    )
-    nKeyPairs.forEach((keyPair, index) =>
-      apiWrapper
-        .getMemberIds(keyPair.address)
-        .then((membership) => assert(membership.length > 0, `Account ${keyPair.address} is not a member`))
-    )
-  })
-
-  tap.test('Account A can not buy the membership with insufficient funds', async () => {
-    await apiWrapper
-      .getBalance(aKeyPair.address)
-      .then((balance) =>
-        assert(
-          balance.toBn() < membershipFee.add(membershipTransactionFee),
-          'Account A already have sufficient balance to purchase membership'
-        )
-      )
-    await apiWrapper.buyMembership(aKeyPair, paidTerms, `late_member_${aKeyPair.address.substring(0, 8)}`, true)
-    apiWrapper
-      .getMemberIds(aKeyPair.address)
-      .then((membership) => assert(membership.length === 0, 'Account A is a member'))
-  })
-
-  tap.test('Account A was able to buy the membership with sufficient funds', async () => {
-    await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipFee.add(membershipTransactionFee))
-    apiWrapper
-      .getBalance(aKeyPair.address)
-      .then((balance) =>
-        assert(balance.toBn() >= membershipFee, 'The account balance is insufficient to purchase membership')
-      )
-    await apiWrapper.buyMembership(aKeyPair, paidTerms, `late_member_${aKeyPair.address.substring(0, 8)}`)
-    apiWrapper
-      .getMemberIds(aKeyPair.address)
-      .then((membership) => assert(membership.length > 0, 'Account A is a not member'))
-  })
-
-  tap.teardown(() => {
-    apiWrapper.close()
-  })
-}

+ 0 - 64
tests/network-tests/src/rome/tests/impl/romeRuntimeUpgrade.ts

@@ -1,64 +0,0 @@
-import { Keyring, WsProvider } from '@polkadot/api'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { registerJoystreamTypes } from '@rome/types'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import BN from 'bn.js'
-import { Utils } from '../../utils/utils'
-import tap from 'tap'
-
-export function romeRuntimeUpgradeTest(
-  m1KeyPairs: KeyringPair[],
-  m2KeyPairs: KeyringPair[],
-  keyring: Keyring,
-  nodeUrl: string,
-  sudoUri: string,
-  proposalStake: BN,
-  runtimePath: string
-) {
-  let apiWrapper: ApiWrapper
-  let sudo: KeyringPair
-
-  tap.test('Rome runtime upgrade test setup', async () => {
-    registerJoystreamTypes()
-    const provider = new WsProvider(nodeUrl)
-    apiWrapper = await ApiWrapper.create(provider)
-  })
-
-  tap.test('Upgrading the runtime test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri)
-    const runtime: string = Utils.readRuntimeFromFile(runtimePath)
-    const description = 'runtime upgrade proposal which is used for API integration testing'
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeRuntimeUpgradeFee(
-      proposalStake,
-      description,
-      description,
-      runtime
-    )
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForRuntimeProposalFee()
-
-    // Topping the balances
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake))
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee)
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated()
-    await apiWrapper.proposeRuntime(
-      m1KeyPairs[0],
-      proposalStake,
-      'testing runtime',
-      'runtime to test proposal functionality',
-      runtime
-    )
-    const proposalNumber = await proposalPromise
-
-    // Approving runtime update proposal
-    const runtimePromise = apiWrapper.expectRuntimeUpgraded()
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber)
-    await runtimePromise
-  })
-
-  tap.teardown(() => {
-    apiWrapper.close()
-  })
-}

+ 0 - 20
tests/network-tests/src/rome/tests/impl/setTimeout.ts

@@ -1,20 +0,0 @@
-import tap from 'tap'
-import { ApiWrapper } from '../../utils/apiWrapper'
-import { WsProvider } from '@polkadot/api'
-import { registerJoystreamTypes } from '@rome/types'
-
-export function setTimeout(nodeUrl: string, durationInBlocks: number) {
-  let apiWrapper: ApiWrapper
-  registerJoystreamTypes()
-
-  tap.test('retrieving time necessary for the test', async () => {
-    const provider = new WsProvider(nodeUrl)
-    apiWrapper = await ApiWrapper.create(provider)
-    const durationInMillis = (await apiWrapper.getBlockDuration()).muln(durationInBlocks).toNumber()
-    tap.setTimeout(durationInMillis)
-  })
-
-  tap.teardown(() => {
-    apiWrapper.close()
-  })
-}

+ 0 - 19
tests/network-tests/src/rome/tests/membershipCreationTest.ts

@@ -1,19 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { Keyring } from '@polkadot/api'
-import { initConfig } from '../utils/config'
-import { setTimeout } from './impl/setTimeout'
-
-initConfig()
-
-const nKeyPairs: KeyringPair[] = []
-
-const keyring = new Keyring({ type: 'sr25519' })
-const N: number = +process.env.MEMBERSHIP_CREATION_N!
-const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-const nodeUrl: string = process.env.NODE_URL!
-const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-const durationInBlocks = 7
-
-setTimeout(nodeUrl, durationInBlocks)
-membershipTest(nKeyPairs, keyring, N, paidTerms, nodeUrl, sudoUri)

+ 0 - 31
tests/network-tests/src/rome/tests/romeRuntimeUpgradeTest.ts

@@ -1,31 +0,0 @@
-import { KeyringPair } from '@polkadot/keyring/types'
-import { membershipTest } from './impl/membershipCreation'
-import { councilTest } from './impl/electingCouncil'
-import { romeRuntimeUpgradeTest } from './impl/romeRuntimeUpgrade'
-import { initConfig } from '../utils/config'
-import { Keyring } from '@polkadot/api'
-import BN from 'bn.js'
-import { setTimeout } from './impl/setTimeout'
-
-initConfig()
-
-const m1KeyPairs: KeyringPair[] = []
-const m2KeyPairs: KeyringPair[] = []
-
-const keyring = new Keyring({ type: 'sr25519' })
-const N: number = +process.env.MEMBERSHIP_CREATION_N!
-const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!
-const nodeUrl: string = process.env.NODE_URL!
-const sudoUri: string = process.env.SUDO_ACCOUNT_URI!
-const K: number = +process.env.COUNCIL_ELECTION_K!
-const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!)
-const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!)
-const proposalStake: BN = new BN(+process.env.RUNTIME_UPGRADE_PROPOSAL_STAKE!)
-const runtimePath: string = process.env.RUNTIME_WASM_PATH!
-const durationInBlocks = 30
-
-setTimeout(nodeUrl, durationInBlocks)
-membershipTest(m1KeyPairs, keyring, N, paidTerms, nodeUrl, sudoUri)
-membershipTest(m2KeyPairs, keyring, N, paidTerms, nodeUrl, sudoUri)
-councilTest(m1KeyPairs, m2KeyPairs, keyring, K, nodeUrl, sudoUri, greaterStake, lesserStake)
-romeRuntimeUpgradeTest(m1KeyPairs, m2KeyPairs, keyring, nodeUrl, sudoUri, proposalStake, runtimePath)

+ 0 - 370
tests/network-tests/src/rome/utils/apiWrapper.ts

@@ -1,370 +0,0 @@
-import { ApiPromise, WsProvider } from '@polkadot/api'
-import { Option, Vec, Bytes, u32 } from '@polkadot/types'
-import { Codec } from '@polkadot/types/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-import { UserInfo, PaidMembershipTerms, MemberId } from '@rome/types/lib/members'
-import { Seat, VoteKind } from '@rome/types'
-import { Balance, EventRecord } from '@polkadot/types/interfaces'
-import BN from 'bn.js'
-import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { Sender } from './sender'
-import { Utils } from './utils'
-
-export class ApiWrapper {
-  private readonly api: ApiPromise
-  private readonly sender: Sender
-
-  public static async create(provider: WsProvider): Promise<ApiWrapper> {
-    const api = await ApiPromise.create({ provider })
-    return new ApiWrapper(api)
-  }
-
-  constructor(api: ApiPromise) {
-    this.api = api
-    this.sender = new Sender(api)
-  }
-
-  public close() {
-    this.api.disconnect()
-  }
-
-  public async buyMembership(
-    account: KeyringPair,
-    paidTermsId: number,
-    name: string,
-    expectFailure = false
-  ): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' })),
-      account,
-      expectFailure
-    )
-  }
-
-  public getMemberIds(address: string): Promise<MemberId[]> {
-    return this.api.query.members.memberIdsByControllerAccountId<Vec<MemberId>>(address)
-  }
-
-  public getBalance(address: string): Promise<Balance> {
-    return this.api.query.balances.freeBalance<Balance>(address)
-  }
-
-  public async transferBalance(from: KeyringPair, to: string, amount: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.balances.transfer(to, amount), from)
-  }
-
-  public getPaidMembershipTerms(paidTermsId: number): Promise<Option<PaidMembershipTerms>> {
-    return this.api.query.members.paidMembershipTermsById<Option<PaidMembershipTerms>>(paidTermsId)
-  }
-
-  public getMembershipFee(paidTermsId: number): Promise<BN> {
-    return this.getPaidMembershipTerms(paidTermsId).then((terms) => terms.unwrap().fee.toBn())
-  }
-
-  public async transferBalanceToAccounts(from: KeyringPair, to: KeyringPair[], amount: BN): Promise<void[]> {
-    return Promise.all(
-      to.map(async (keyPair) => {
-        await this.transferBalance(from, keyPair.address, amount)
-      })
-    )
-  }
-
-  private getBaseTxFee(): BN {
-    return this.api.createType('BalanceOf', this.api.consts.transactionPayment.transactionBaseFee).toBn()
-  }
-
-  private estimateTxFee(tx: SubmittableExtrinsic<'promise'>): BN {
-    const baseFee: BN = this.getBaseTxFee()
-    const byteFee: BN = this.api.createType('BalanceOf', this.api.consts.transactionPayment.transactionByteFee).toBn()
-    return Utils.calcTxLength(tx).mul(byteFee).add(baseFee)
-  }
-
-  public estimateBuyMembershipFee(account: KeyringPair, paidTermsId: number, name: string): BN {
-    return this.estimateTxFee(
-      this.api.tx.members.buyMembership(paidTermsId, new UserInfo({ 'handle': name, 'avatar_uri': '', 'about': '' }))
-    )
-  }
-
-  public estimateApplyForCouncilFee(amount: BN): BN {
-    return this.estimateTxFee(this.api.tx.councilElection.apply(amount))
-  }
-
-  public estimateVoteForCouncilFee(nominee: string, salt: string, stake: BN): BN {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.estimateTxFee(this.api.tx.councilElection.vote(hashedVote, stake))
-  }
-
-  public estimateRevealVoteFee(nominee: string, salt: string): BN {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.estimateTxFee(this.api.tx.councilElection.reveal(hashedVote, nominee, salt))
-  }
-
-  public estimateProposeRuntimeUpgradeFee(stake: BN, name: string, description: string, runtime: string): BN {
-    return this.estimateTxFee(this.api.tx.proposals.createProposal(stake, name, description, runtime))
-  }
-
-  public estimateProposeTextFee(stake: BN, name: string, description: string, text: string): BN {
-    return this.estimateTxFee(this.api.tx.proposalsCodex.createTextProposal(stake, name, description, stake, text))
-  }
-
-  public estimateProposeSpendingFee(
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN,
-    destination: string
-  ): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSpendingProposal(stake, title, description, stake, balance, destination)
-    )
-  }
-
-  public estimateProposeWorkingGroupMintCapacityFee(title: string, description: string, stake: BN, balance: BN): BN {
-    return this.estimateTxFee(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        stake,
-        title,
-        description,
-        stake,
-        balance
-      )
-    )
-  }
-
-  public estimateVoteForRuntimeProposalFee(): BN {
-    return this.estimateTxFee(this.api.tx.proposals.voteOnProposal(0, 'Approve'))
-  }
-
-  public newEstimate(): BN {
-    return new BN(100)
-  }
-
-  private applyForCouncilElection(account: KeyringPair, amount: BN): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.councilElection.apply(amount), account, false)
-  }
-
-  public batchApplyForCouncilElection(accounts: KeyringPair[], amount: BN): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair) => {
-        await this.applyForCouncilElection(keyPair, amount)
-      })
-    )
-  }
-
-  public async getCouncilElectionStake(address: string): Promise<BN> {
-    // TODO alter then `applicantStake` type will be introduced
-    return this.api.query.councilElection.applicantStakes(address).then((stake) => {
-      const parsed = JSON.parse(stake.toString())
-      return new BN(parsed.new)
-    })
-  }
-
-  private voteForCouncilMember(account: KeyringPair, nominee: string, salt: string, stake: BN): Promise<void> {
-    const hashedVote: string = Utils.hashVote(nominee, salt)
-    return this.sender.signAndSend(this.api.tx.councilElection.vote(hashedVote, stake), account, false)
-  }
-
-  public batchVoteForCouncilMember(
-    accounts: KeyringPair[],
-    nominees: KeyringPair[],
-    salt: string[],
-    stake: BN
-  ): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair, index) => {
-        await this.voteForCouncilMember(keyPair, nominees[index].address, salt[index], stake)
-      })
-    )
-  }
-
-  private revealVote(account: KeyringPair, commitment: string, nominee: string, salt: string): Promise<void> {
-    return this.sender.signAndSend(this.api.tx.councilElection.reveal(commitment, nominee, salt), account, false)
-  }
-
-  public batchRevealVote(accounts: KeyringPair[], nominees: KeyringPair[], salt: string[]): Promise<void[]> {
-    return Promise.all(
-      accounts.map(async (keyPair, index) => {
-        const commitment = Utils.hashVote(nominees[index].address, salt[index])
-        await this.revealVote(keyPair, commitment, nominees[index].address, salt[index])
-      })
-    )
-  }
-
-  // TODO consider using configurable genesis instead
-  public sudoStartAnnouncingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageAnnouncing(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoStartVotingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageVoting(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public sudoStartRevealingPerion(sudo: KeyringPair, endsAtBlock: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.sudo.sudo(this.api.tx.councilElection.setStageRevealing(endsAtBlock)),
-      sudo,
-      false
-    )
-  }
-
-  public getBestBlock(): Promise<BN> {
-    return this.api.derive.chain.bestNumber()
-  }
-
-  public getCouncil(): Promise<Seat[]> {
-    return this.api.query.council.activeCouncil<Vec<Codec>>().then((seats) => {
-      return JSON.parse(seats.toString())
-    })
-  }
-
-  public getRuntime(): Promise<Bytes> {
-    return this.api.query.substrate.code<Bytes>()
-  }
-
-  public proposeRuntime(
-    account: KeyringPair,
-    stake: BN,
-    name: string,
-    description: string,
-    runtime: string
-  ): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.proposals.createProposal(stake, name, description, runtime),
-      account,
-      false
-    )
-  }
-
-  public async proposeText(
-    account: KeyringPair,
-    stake: BN,
-    name: string,
-    description: string,
-    text: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createTextProposal(memberId, name, description, stake, text),
-      account,
-      false
-    )
-  }
-
-  public async proposeSpending(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN,
-    destination: string
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSpendingProposal(memberId, title, description, stake, balance, destination),
-      account,
-      false
-    )
-  }
-
-  public async proposeWorkingGroupMintCapacity(
-    account: KeyringPair,
-    title: string,
-    description: string,
-    stake: BN,
-    balance: BN
-  ): Promise<void> {
-    const memberId: BN = (await this.getMemberIds(account.address))[0].toBn()
-    return this.sender.signAndSend(
-      this.api.tx.proposalsCodex.createSetContentWorkingGroupMintCapacityProposal(
-        memberId,
-        title,
-        description,
-        stake,
-        balance
-      ),
-      account,
-      false
-    )
-  }
-
-  public approveProposal(account: KeyringPair, proposal: BN): Promise<void> {
-    return this.sender.signAndSend(
-      this.api.tx.proposals.voteOnProposal(proposal, new VoteKind('Approve')),
-      account,
-      false
-    )
-  }
-
-  public batchApproveProposal(council: KeyringPair[], proposal: BN): Promise<void[]> {
-    return Promise.all(
-      council.map(async (keyPair) => {
-        await this.approveProposal(keyPair, proposal)
-      })
-    )
-  }
-
-  public getBlockDuration(): BN {
-    return this.api.createType('Moment', this.api.consts.babe.expectedBlockTime).toBn()
-  }
-
-  public expectProposalCreated(): Promise<BN> {
-    return new Promise(async (resolve) => {
-      await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method.toString() === 'ProposalCreated') {
-            resolve(new BN(record.event.data[1].toString()))
-          }
-        })
-      })
-    })
-  }
-
-  public expectRuntimeUpgraded(): Promise<void> {
-    return new Promise(async (resolve) => {
-      await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (record.event.method.toString() === 'RuntimeUpdated') {
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public expectProposalFinalized(): Promise<void> {
-    return new Promise(async (resolve) => {
-      await this.api.query.system.events<Vec<EventRecord>>((events) => {
-        events.forEach((record) => {
-          if (
-            record.event.method.toString() === 'ProposalStatusUpdated' &&
-            record.event.data[1].toString().includes('Finalized')
-          ) {
-            resolve()
-          }
-        })
-      })
-    })
-  }
-
-  public getTotalIssuance(): Promise<BN> {
-    return this.api.query.balances.totalIssuance<Balance>()
-  }
-
-  public async getRequiredProposalStake(numerator: number, denominator: number): Promise<BN> {
-    const issuance: number = await (await this.getTotalIssuance()).toNumber()
-    const stake = (issuance * numerator) / denominator
-    return new BN(stake.toFixed(0))
-  }
-
-  public getProposalCount(): Promise<BN> {
-    return this.api.query.proposalsEngine.proposalCount<u32>()
-  }
-}

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

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

+ 0 - 66
tests/network-tests/src/rome/utils/sender.ts

@@ -1,66 +0,0 @@
-import BN from 'bn.js'
-import { ApiPromise } from '@polkadot/api'
-import { Index } from '@polkadot/types/interfaces'
-import { SubmittableExtrinsic } from '@polkadot/api/types'
-import { KeyringPair } from '@polkadot/keyring/types'
-
-export class Sender {
-  private readonly api: ApiPromise
-  private static nonceMap: Map<string, BN> = new Map()
-
-  constructor(api: ApiPromise) {
-    this.api = api
-  }
-
-  private async getNonce(address: string): Promise<BN> {
-    let oncahinNonce: BN = new BN(0)
-    if (!Sender.nonceMap.get(address)) {
-      oncahinNonce = await this.api.query.system.accountNonce<Index>(address)
-    }
-    let nonce: BN | undefined = Sender.nonceMap.get(address)
-    if (!nonce) {
-      nonce = oncahinNonce
-    }
-    const nextNonce: BN = nonce.addn(1)
-    Sender.nonceMap.set(address, nextNonce)
-    return nonce
-  }
-
-  private clearNonce(address: string): void {
-    Sender.nonceMap.delete(address)
-  }
-
-  public async signAndSend(
-    tx: SubmittableExtrinsic<'promise'>,
-    account: KeyringPair,
-    expectFailure = false
-  ): Promise<void> {
-    return new Promise(async (resolve, reject) => {
-      const nonce: BN = await this.getNonce(account.address)
-      const signedTx = tx.sign(account, { nonce })
-      await signedTx
-        .send(async (result) => {
-          if (result.status.isFinalized === true && result.events !== undefined) {
-            result.events.forEach((event) => {
-              if (event.event.method === 'ExtrinsicFailed') {
-                if (expectFailure) {
-                  resolve()
-                } else {
-                  reject(new Error('Extrinsic failed unexpectedly'))
-                }
-              }
-            })
-            resolve()
-          }
-          if (result.status.isFuture) {
-            console.log('nonce ' + nonce + ' for account ' + account.address + ' is in future')
-            this.clearNonce(account.address)
-            reject(new Error('Extrinsic nonce is in future'))
-          }
-        })
-        .catch((error) => {
-          reject(error)
-        })
-    })
-  }
-}

+ 0 - 50
tests/network-tests/src/rome/utils/utils.ts

@@ -1,50 +0,0 @@
-import { IExtrinsic } from '@polkadot/types/types'
-import { compactToU8a, stringToU8a, u8aToHex } from '@polkadot/util'
-import { blake2AsHex } from '@polkadot/util-crypto'
-import BN from 'bn.js'
-import fs from 'fs'
-import { decodeAddress } from '@polkadot/keyring'
-import { Seat } from '@rome/types'
-
-export class Utils {
-  private static LENGTH_ADDRESS = 32 + 1 // publicKey + prefix
-  private static LENGTH_ERA = 2 // assuming mortals
-  private static LENGTH_SIGNATURE = 64 // assuming ed25519 or sr25519
-  private static LENGTH_VERSION = 1 // 0x80 & version
-
-  public static calcTxLength = (extrinsic?: IExtrinsic | null, nonce?: BN): BN => {
-    return new BN(
-      Utils.LENGTH_VERSION +
-        Utils.LENGTH_ADDRESS +
-        Utils.LENGTH_SIGNATURE +
-        Utils.LENGTH_ERA +
-        compactToU8a(nonce || 0).length +
-        (extrinsic ? extrinsic.encodedLength : 0)
-    )
-  }
-
-  /** hash(accountId + salt) */
-  public static hashVote(accountId: string, salt: string): string {
-    const accountU8a = decodeAddress(accountId)
-    const saltU8a = stringToU8a(salt)
-    const voteU8a = new Uint8Array(accountU8a.length + saltU8a.length)
-    voteU8a.set(accountU8a)
-    voteU8a.set(saltU8a, accountU8a.length)
-
-    const hash = blake2AsHex(voteU8a, 256)
-    // console.log('Vote hash:', hash, 'for', { accountId, salt });
-    return hash
-  }
-
-  public static wait(ms: number): Promise<void> {
-    return new Promise((resolve) => setTimeout(resolve, ms))
-  }
-
-  public static getTotalStake(seat: Seat): BN {
-    return new BN(+seat.stake.toString() + seat.backers.reduce((a, baker) => a + +baker.stake.toString(), 0))
-  }
-
-  public static readRuntimeFromFile(path: string): string {
-    return u8aToHex(fs.readFileSync(path))
-  }
-}

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


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


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

@@ -9,7 +9,7 @@ import { closeApi } from '../../utils/closeApi'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { ElectCouncilFixture } from '../fixtures/councilElectionModule'
 import { Utils } from '../../utils/utils'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 
 tap.mocha.describe('Electing council scenario', async () => {
   initConfig()

+ 1 - 1
tests/network-tests/src/iznik/tests/councilSetup.ts → tests/network-tests/src/tests/councilSetup.ts

@@ -2,7 +2,7 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import { Keyring, WsProvider } from '@polkadot/api'
 import BN from 'bn.js'
 import tap from 'tap'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { DbService } from '../services/dbService'
 import { initConfig } from '../utils/config'
 import { ApiWrapper } from '../utils/apiWrapper'

+ 1 - 1
tests/network-tests/src/iznik/tests/fixtures/councilElectionHappyCase.ts → tests/network-tests/src/tests/fixtures/councilElectionHappyCase.ts

@@ -4,7 +4,7 @@ import tap from 'tap'
 import { ElectCouncilFixture } from './councilElectionModule'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 
 export class CouncilElectionHappyCaseFixture implements Fixture {

+ 1 - 1
tests/network-tests/src/iznik/tests/fixtures/councilElectionModule.ts → tests/network-tests/src/tests/fixtures/councilElectionModule.ts

@@ -2,7 +2,7 @@ import { ApiWrapper } from '../../utils/apiWrapper'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'
-import { Seat } from '@alexandria/types/council'
+import { Seat } from '@joystream/types/council'
 import { v4 as uuid } from 'uuid'
 import { Utils } from '../../utils/utils'
 import { Fixture } from './interfaces/fixture'

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


+ 2 - 2
tests/network-tests/src/iznik/tests/fixtures/leaderHiringHappyCase.ts → tests/network-tests/src/tests/fixtures/leaderHiringHappyCase.ts

@@ -8,9 +8,9 @@ import {
 } from './workingGroupModule'
 import { BuyMembershipHappyCaseFixture } from './membershipModule'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
-import { OpeningId } from '@alexandria/types/hiring'
+import { OpeningId } from '@joystream/types/hiring'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 
 export class LeaderHiringHappyCaseFixture implements Fixture {

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

@@ -3,7 +3,7 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
 import { assert } from 'chai'
 import { Fixture } from './interfaces/fixture'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 
 export class BuyMembershipHappyCaseFixture implements Fixture {
   private apiWrapper: ApiWrapper

+ 3 - 3
tests/network-tests/src/iznik/tests/fixtures/proposalsModule.ts → tests/network-tests/src/tests/fixtures/proposalsModule.ts

@@ -2,11 +2,11 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { v4 as uuid } from 'uuid'
 import BN from 'bn.js'
-import { ProposalId } from '@alexandria/types/proposals'
+import { ProposalId } from '@joystream/types/proposals'
 import { Fixture } from './interfaces/fixture'
 import { assert } from 'chai'
-import { ApplicationId, OpeningId } from '@alexandria/types/hiring'
-import { WorkerId } from '@alexandria/types/working-group'
+import { ApplicationId, OpeningId } from '@joystream/types/hiring'
+import { WorkerId } from '@joystream/types/working-group'
 import { Utils } from '../../utils/utils'
 
 export class CreateWorkingGroupLeaderOpeningFixture implements Fixture {

+ 3 - 3
tests/network-tests/src/iznik/tests/fixtures/workingGroupModule.ts → tests/network-tests/src/tests/fixtures/workingGroupModule.ts

@@ -5,10 +5,10 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import { Event } from '@polkadot/types/interfaces'
 import { Keyring } from '@polkadot/api'
 import { v4 as uuid } from 'uuid'
-import { RewardRelationship } from '@alexandria/types/recurring-rewards'
-import { Application, ApplicationIdToWorkerIdMap, Worker, WorkerId } from '@alexandria/types/working-group'
+import { RewardRelationship } from '@joystream/types/recurring-rewards'
+import { Application, ApplicationIdToWorkerIdMap, Worker, WorkerId } from '@joystream/types/working-group'
 import { Utils } from '../../utils/utils'
-import { ApplicationId, Opening as HiringOpening, OpeningId } from '@alexandria/types/hiring'
+import { ApplicationId, Opening as HiringOpening, OpeningId } from '@joystream/types/hiring'
 import { Fixture } from './interfaces/fixture'
 
 export class AddWorkerOpeningFixture implements Fixture {

+ 1 - 1
tests/network-tests/src/iznik/tests/leaderSetup.ts → tests/network-tests/src/tests/leaderSetup.ts

@@ -7,7 +7,7 @@ import { setTestTimeout } from '../utils/setTestTimeout'
 import BN from 'bn.js'
 import tap from 'tap'
 import { Utils } from '../utils/utils'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { DbService } from '../services/dbService'
 import { LeaderHiringHappyCaseFixture } from './fixtures/leaderHiringHappyCase'
 

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

@@ -7,7 +7,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 '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 
 tap.mocha.describe('Membership creation scenario', async () => {

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

@@ -8,7 +8,7 @@ import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { ContentWorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
 import { Utils } from '../../utils/utils'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

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

@@ -8,7 +8,7 @@ import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { ElectionParametersProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

+ 3 - 3
tests/network-tests/src/iznik/tests/proposals/manageLeaderRoleTest.ts → tests/network-tests/src/tests/proposals/manageLeaderRoleTest.ts

@@ -28,9 +28,9 @@ import {
   ExpectLeadOpeningAddedFixture,
 } from '../fixtures/workingGroupModule'
 import { Utils } from '../../utils/utils'
-import { PaidTermId } from '@alexandria/types/members'
-import { OpeningId } from '@alexandria/types/hiring'
-import { ProposalId } from '@alexandria/types/proposals'
+import { PaidTermId } from '@joystream/types/members'
+import { OpeningId } from '@joystream/types/hiring'
+import { ProposalId } from '@joystream/types/proposals'
 import { DbService } from '../../services/dbService'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 

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

@@ -8,7 +8,7 @@ import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { SetLeadProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

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

@@ -8,7 +8,7 @@ import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { SpendingProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

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

@@ -8,7 +8,7 @@ import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { TextProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

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

@@ -9,7 +9,7 @@ import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { BuyMembershipHappyCaseFixture } from '../fixtures/membershipModule'
 import { UpdateRuntimeFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

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

@@ -8,7 +8,7 @@ import { closeApi } from '../../utils/closeApi'
 import { ApiWrapper } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { ValidatorCountProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

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

@@ -9,8 +9,8 @@ import { ApiWrapper, WorkingGroups } from '../../utils/apiWrapper'
 import { Utils } from '../../utils/utils'
 import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
 import { ExpectMintCapacityChangedFixture } from '../fixtures/workingGroupModule'
-import { PaidTermId } from '@alexandria/types/members'
-import { ProposalId } from '@alexandria/types/proposals'
+import { PaidTermId } from '@joystream/types/members'
+import { ProposalId } from '@joystream/types/proposals'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { DbService } from '../../services/dbService'
 

+ 1 - 1
tests/network-tests/src/iznik/tests/workingGroup/atLeastValueBugTest.ts → tests/network-tests/src/tests/workingGroup/atLeastValueBugTest.ts

@@ -8,7 +8,7 @@ import { AddWorkerOpeningFixture, LeaveRoleFixture } from '../fixtures/workingGr
 import BN from 'bn.js'
 import tap from 'tap'
 import { Utils } from '../../utils/utils'
-import { PaidTermId } from '@alexandria/types/members'
+import { PaidTermId } from '@joystream/types/members'
 import { DbService } from '../../services/dbService'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 

+ 2 - 2
tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsLeadTest.ts → tests/network-tests/src/tests/workingGroup/manageWorkerAsLeadTest.ts

@@ -20,8 +20,8 @@ import {
 import { Utils } from '../../utils/utils'
 import BN from 'bn.js'
 import tap from 'tap'
-import { PaidTermId } from '@alexandria/types/members'
-import { OpeningId } from '@alexandria/types/hiring'
+import { PaidTermId } from '@joystream/types/members'
+import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 

+ 2 - 2
tests/network-tests/src/iznik/tests/workingGroup/manageWorkerAsWorkerTest.ts → tests/network-tests/src/tests/workingGroup/manageWorkerAsWorkerTest.ts

@@ -16,8 +16,8 @@ import {
 import { Utils } from '../../utils/utils'
 import BN from 'bn.js'
 import tap from 'tap'
-import { PaidTermId } from '@alexandria/types/members'
-import { OpeningId } from '@alexandria/types/hiring'
+import { PaidTermId } from '@joystream/types/members'
+import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 

+ 2 - 2
tests/network-tests/src/iznik/tests/workingGroup/workerApplicationHappyCaseTest.ts → tests/network-tests/src/tests/workingGroup/workerApplicationHappyCaseTest.ts

@@ -15,8 +15,8 @@ import {
   LeaveRoleFixture,
   WithdrawApplicationFixture,
 } from '../fixtures/workingGroupModule'
-import { PaidTermId } from '@alexandria/types/members'
-import { OpeningId } from '@alexandria/types/hiring'
+import { PaidTermId } from '@joystream/types/members'
+import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 

+ 2 - 2
tests/network-tests/src/iznik/tests/workingGroup/workerApplicationRejectionCaseTest.ts → tests/network-tests/src/tests/workingGroup/workerApplicationRejectionCaseTest.ts

@@ -14,8 +14,8 @@ import {
   LeaveRoleFixture,
   TerminateApplicationsFixture,
 } from '../fixtures/workingGroupModule'
-import { PaidTermId } from '@alexandria/types/members'
-import { OpeningId } from '@alexandria/types/hiring'
+import { PaidTermId } from '@joystream/types/members'
+import { OpeningId } from '@joystream/types/hiring'
 import { DbService } from '../../services/dbService'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'
 

+ 3 - 3
tests/network-tests/src/iznik/tests/workingGroup/workerPayoutTest.ts → tests/network-tests/src/tests/workingGroup/workerPayoutTest.ts

@@ -17,9 +17,9 @@ import BN from 'bn.js'
 import tap from 'tap'
 import { Utils } from '../../utils/utils'
 import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../fixtures/proposalsModule'
-import { PaidTermId } from '@alexandria/types/members'
-import { OpeningId } from '@alexandria/types/hiring'
-import { ProposalId } from '@alexandria/types/proposals'
+import { PaidTermId } from '@joystream/types/members'
+import { OpeningId } from '@joystream/types/hiring'
+import { ProposalId } from '@joystream/types/proposals'
 import { DbService } from '../../services/dbService'
 import { CouncilElectionHappyCaseFixture } from '../fixtures/councilElectionHappyCase'
 import { LeaderHiringHappyCaseFixture } from '../fixtures/leaderHiringHappyCase'

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

@@ -2,33 +2,33 @@ import { ApiPromise, WsProvider } from '@polkadot/api'
 import { Bytes, Option, u32, Vec, StorageKey } from '@polkadot/types'
 import { Codec } from '@polkadot/types/types'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { MemberId, PaidMembershipTerms, PaidTermId } from '@alexandria/types/members'
-import { Mint, MintId } from '@alexandria/types/mint'
-import { Lead, LeadId } from '@alexandria/types/content-working-group'
+import { MemberId, PaidMembershipTerms, PaidTermId } from '@joystream/types/members'
+import { Mint, MintId } from '@joystream/types/mint'
+import { Lead, LeadId } from '@joystream/types/content-working-group'
 import {
   Application,
   ApplicationIdToWorkerIdMap,
   Worker,
   WorkerId,
   WorkingGroupOpeningPolicyCommitment,
-} from '@alexandria/types/working-group'
-import { ElectionStake, Seat } from '@alexandria/types/council'
+} from '@joystream/types/working-group'
+import { ElectionStake, Seat } from '@joystream/types/council'
 import { AccountId, AccountInfo, Balance, BalanceOf, BlockNumber, Event, EventRecord } from '@polkadot/types/interfaces'
 import BN from 'bn.js'
 import { SubmittableExtrinsic } from '@polkadot/api/types'
 import { Sender } from './sender'
 import { Utils } from './utils'
-import { Stake, StakedState, StakeId } from '@alexandria/types/stake'
-import { RewardRelationship, RewardRelationshipId } from '@alexandria/types/recurring-rewards'
-import { types } from '@alexandria/types'
+import { Stake, StakedState, StakeId } from '@joystream/types/stake'
+import { RewardRelationship, RewardRelationshipId } from '@joystream/types/recurring-rewards'
+import { types } from '@joystream/types'
 import {
   ActivateOpeningAt,
   Application as HiringApplication,
   ApplicationId,
   Opening as HiringOpening,
   OpeningId,
-} from '@alexandria/types/hiring'
-import { FillOpeningParameters, ProposalId } from '@alexandria/types/proposals'
+} from '@joystream/types/hiring'
+import { FillOpeningParameters, ProposalId } from '@joystream/types/proposals'
 
 export enum WorkingGroups {
   StorageWorkingGroup = 'storageWorkingGroup',

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


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


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


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


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.