leaderSetup.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { Api, WorkingGroups } from '../../Api'
  2. import BN from 'bn.js'
  3. import { PaidTermId } from '@joystream/types/members'
  4. import { SudoHireLeadFixture } from '../../fixtures/sudoHireLead'
  5. import { assert } from 'chai'
  6. import { KeyringPair } from '@polkadot/keyring/types'
  7. // Worker application happy case scenario
  8. export default async function leaderSetup(
  9. api: Api,
  10. env: NodeJS.ProcessEnv,
  11. group: WorkingGroups
  12. ): Promise<KeyringPair> {
  13. const lead = await api.getGroupLead(group)
  14. assert(!lead, `Lead is already set`)
  15. const leadKeyPair = api.createKeyPairs(1)[0]
  16. const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
  17. const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
  18. const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
  19. const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
  20. const rewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
  21. const payoutAmount: BN = new BN(env.PAYOUT_AMOUNT!)
  22. const openingActivationDelay: BN = new BN(0)
  23. const leaderHiringHappyCaseFixture = new SudoHireLeadFixture(
  24. api,
  25. leadKeyPair.address,
  26. paidTerms,
  27. applicationStake,
  28. roleStake,
  29. openingActivationDelay,
  30. rewardInterval,
  31. firstRewardInterval,
  32. payoutAmount,
  33. group
  34. )
  35. await leaderHiringHappyCaseFixture.runner(false)
  36. const hiredLead = await api.getGroupLead(group)
  37. assert(hiredLead, `${group} group Lead was not hired!`)
  38. assert(hiredLead!.role_account_id.eq(leadKeyPair.address))
  39. return leadKeyPair
  40. }