Browse Source

fix faucet init flow after merge conflict fixes

Mokhtar Naamani 3 years ago
parent
commit
cbd90198d1

+ 17 - 0
tests/network-tests/src/Api.ts

@@ -24,6 +24,7 @@ import {
   KeyGenInfo,
   WorkingGroupModuleName,
   ProposalType,
+  FaucetInfo,
 } from './types'
 
 import { ProposalParameters } from '@joystream/types/proposals'
@@ -57,6 +58,9 @@ export class ApiFactory {
   // source of funds for all new accounts
   private readonly treasuryAccount: string
 
+  // faucet details
+  public faucetInfo: FaucetInfo
+
   public static async create(
     provider: WsProvider,
     treasuryAccountUri: string,
@@ -97,12 +101,17 @@ export class ApiFactory {
     this.addressesToKeyId = new Map()
     this.addressesToSuri = new Map()
     this.keyId = 0
+    this.faucetInfo = { suri: '', memberId: 0 }
   }
 
   public getApi(label: string): Api {
     return new Api(this, this.api, this.treasuryAccount, this.keyring, label)
   }
 
+  public setFaucetInfo(info: FaucetInfo): void {
+    this.faucetInfo = info
+  }
+
   public createKeyPairs(n: number): { key: KeyringPair; id: number }[] {
     const keys: { key: KeyringPair; id: number }[] = []
     for (let i = 0; i < n; i++) {
@@ -1013,4 +1022,12 @@ export class Api {
       accountFrom
     )
   }
+
+  public setFaucetInfo(info: FaucetInfo): void {
+    this.factory.setFaucetInfo(info)
+  }
+
+  public getFaucetInfo(): FaucetInfo {
+    return this.factory.faucetInfo
+  }
 }

+ 5 - 1
tests/network-tests/src/Scenario.ts

@@ -10,7 +10,7 @@ import { JobManager } from './JobManager'
 import { ResourceManager } from './Resources'
 import fetch from 'cross-fetch'
 import fs, { existsSync, readFileSync } from 'fs'
-import { KeyGenInfo } from './types'
+import { KeyGenInfo, FaucetInfo } from './types'
 
 export type ScenarioProps = {
   env: NodeJS.ProcessEnv
@@ -24,6 +24,7 @@ type TestsOutput = {
   accounts: { [k: string]: number }
   keyIds: KeyGenInfo
   miniSecret: string
+  faucet: FaucetInfo
 }
 
 function writeOutput(api: Api, miniSecret: string) {
@@ -34,10 +35,13 @@ function writeOutput(api: Api, miniSecret: string) {
   // first and last key id used to generate keys in this scenario
   const keyIds = api.keyGenInfo()
 
+  const faucet = api.getFaucetInfo()
+
   const output: TestsOutput = {
     accounts,
     keyIds,
     miniSecret,
+    faucet,
   }
 
   fs.writeFileSync(OUTPUT_FILE_PATH, JSON.stringify(output, undefined, 2))

+ 1 - 9
tests/network-tests/src/fixtures/workingGroups/SetLeaderInvitationQuotaFixture.ts

@@ -1,17 +1,9 @@
-import BN from 'bn.js'
-import { assert } from 'chai'
 import { Api } from '../../Api'
 import { QueryNodeApi } from '../../QueryNodeApi'
 import { EventDetails, WorkingGroupModuleName } from '../../types'
 import { BaseWorkingGroupFixture } from './BaseWorkingGroupFixture'
 import { SubmittableExtrinsic } from '@polkadot/api/types'
 import { ISubmittableResult } from '@polkadot/types/types/'
-import { Utils } from '../../utils'
-import {
-  ProposalFieldsFragment,
-  BudgetSetEventFieldsFragment,
-  WorkingGroupFieldsFragment,
-} from '../../graphql/generated/queries'
 
 export class SetLeaderInvitationQuotaFixture extends BaseWorkingGroupFixture {
   protected group: WorkingGroupModuleName
@@ -33,7 +25,7 @@ export class SetLeaderInvitationQuotaFixture extends BaseWorkingGroupFixture {
   }
 
   protected async getEventFromResult(result: ISubmittableResult): Promise<EventDetails> {
-    return await this.api.retrieveMembershipEventDetails(result, 'LeaderInvitationQuotaUpdated')
+    return await this.api.getEventDetails(result, 'members', 'LeaderInvitationQuotaUpdated')
   }
 
   protected assertQueryNodeEventIsValid(qEvent: unknown, i: number): void {

+ 6 - 0
tests/network-tests/src/types.ts

@@ -78,3 +78,9 @@ export type PostPath = {
   threadId: ThreadId
   postId: PostId
 }
+
+// Forum init
+export type FaucetInfo = {
+  suri: string
+  memberId: number
+}