Browse Source

integration-tests: more logs

Mokhtar Naamani 4 years ago
parent
commit
da94ae70bc
27 changed files with 143 additions and 94 deletions
  1. 26 5
      tests/network-tests/src/Api.ts
  2. 2 2
      tests/network-tests/src/Flow.ts
  3. 14 3
      tests/network-tests/src/Job.ts
  4. 20 6
      tests/network-tests/src/JobManager.ts
  5. 19 18
      tests/network-tests/src/Scenario.ts
  6. 1 1
      tests/network-tests/src/fixtures/membershipModule.ts
  7. 2 2
      tests/network-tests/src/flows/contentDirectory/contentDirectoryInitialization.ts
  8. 2 2
      tests/network-tests/src/flows/contentDirectory/creatingChannel.ts
  9. 2 2
      tests/network-tests/src/flows/contentDirectory/creatingVideo.ts
  10. 2 2
      tests/network-tests/src/flows/contentDirectory/updatingChannel.ts
  11. 3 2
      tests/network-tests/src/flows/membership/creatingMemberships.ts
  12. 2 2
      tests/network-tests/src/flows/proposals/councilSetup.ts
  13. 3 3
      tests/network-tests/src/flows/proposals/electionParametersProposal.ts
  14. 3 3
      tests/network-tests/src/flows/proposals/manageLeaderRole.ts
  15. 2 2
      tests/network-tests/src/flows/proposals/spendingProposal.ts
  16. 2 2
      tests/network-tests/src/flows/proposals/textProposal.ts
  17. 2 2
      tests/network-tests/src/flows/proposals/updateRuntime.ts
  18. 2 2
      tests/network-tests/src/flows/proposals/validatorCountProposal.ts
  19. 3 3
      tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts
  20. 2 2
      tests/network-tests/src/flows/storageNode/getContentFromStorageNode.ts
  21. 4 2
      tests/network-tests/src/flows/workingGroup/atLeastValueBug.ts
  22. 3 3
      tests/network-tests/src/flows/workingGroup/leaderSetup.ts
  23. 4 4
      tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts
  24. 4 4
      tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts
  25. 3 3
      tests/network-tests/src/flows/workingGroup/workerPayout.ts
  26. 1 4
      tests/network-tests/src/scenarios/full.ts
  27. 10 8
      tests/network-tests/src/sender.ts

+ 26 - 5
tests/network-tests/src/Api.ts

@@ -44,14 +44,17 @@ export enum WorkingGroups {
   ContentDirectoryWorkingGroup = 'contentDirectoryWorkingGroup',
   ContentDirectoryWorkingGroup = 'contentDirectoryWorkingGroup',
 }
 }
 
 
-export class Api {
+export class ApiFactory {
   private readonly api: ApiPromise
   private readonly api: ApiPromise
-  private readonly sender: Sender
   private readonly keyring: Keyring
   private readonly keyring: Keyring
   // source of funds for all new accounts
   // source of funds for all new accounts
   private readonly treasuryAccount: string
   private readonly treasuryAccount: string
 
 
-  public static async create(provider: WsProvider, treasuryAccountUri: string, sudoAccountUri: string): Promise<Api> {
+  public static async create(
+    provider: WsProvider,
+    treasuryAccountUri: string,
+    sudoAccountUri: string
+  ): Promise<ApiFactory> {
     let connectAttempts = 0
     let connectAttempts = 0
     while (true) {
     while (true) {
       connectAttempts++
       connectAttempts++
@@ -66,7 +69,7 @@ export class Api {
         // Give it a few seconds to be ready.
         // Give it a few seconds to be ready.
         await Utils.wait(5000)
         await Utils.wait(5000)
 
 
-        return new Api(api, treasuryAccountUri, sudoAccountUri)
+        return new ApiFactory(api, treasuryAccountUri, sudoAccountUri)
       } catch (err) {
       } catch (err) {
         if (connectAttempts === 3) {
         if (connectAttempts === 3) {
           throw new Error('Unable to connect to chain')
           throw new Error('Unable to connect to chain')
@@ -81,12 +84,30 @@ export class Api {
     this.keyring = new Keyring({ type: 'sr25519' })
     this.keyring = new Keyring({ type: 'sr25519' })
     this.treasuryAccount = this.keyring.addFromUri(treasuryAccountUri).address
     this.treasuryAccount = this.keyring.addFromUri(treasuryAccountUri).address
     this.keyring.addFromUri(sudoAccountUri)
     this.keyring.addFromUri(sudoAccountUri)
-    this.sender = new Sender(api, this.keyring)
+  }
+
+  public getApi(label: string): Api {
+    return new Api(this.api, this.treasuryAccount, this.keyring, label)
   }
   }
 
 
   public close(): void {
   public close(): void {
     this.api.disconnect()
     this.api.disconnect()
   }
   }
+}
+
+export class Api {
+  private readonly api: ApiPromise
+  private readonly sender: Sender
+  private readonly keyring: Keyring
+  // source of funds for all new accounts
+  private readonly treasuryAccount: string
+
+  constructor(api: ApiPromise, treasuryAccount: string, keyring: Keyring, label: string) {
+    this.api = api
+    this.keyring = keyring
+    this.treasuryAccount = treasuryAccount
+    this.sender = new Sender(api, keyring, label)
+  }
 
 
   public enableTxLogs(): void {
   public enableTxLogs(): void {
     this.sender.enableLogs()
     this.sender.enableLogs()

+ 2 - 2
tests/network-tests/src/Flow.ts

@@ -1,5 +1,5 @@
 import { Api } from './Api'
 import { Api } from './Api'
 import { QueryNodeApi } from './QueryNodeApi'
 import { QueryNodeApi } from './QueryNodeApi'
 
 
-export type FlowArgs = { api: Api; env: NodeJS.ProcessEnv; query: QueryNodeApi }
-export type Flow = (args: FlowArgs) => Promise<void>
+export type FlowProps = { api: Api; env: NodeJS.ProcessEnv; query: QueryNodeApi }
+export type Flow = (args: FlowProps) => Promise<void>

+ 14 - 3
tests/network-tests/src/Job.ts

@@ -1,7 +1,10 @@
 import Debugger from 'debug'
 import Debugger from 'debug'
 import { EventEmitter } from 'events'
 import { EventEmitter } from 'events'
+import { ApiFactory } from './Api'
+import { QueryNodeApi } from './QueryNodeApi'
+import { Flow } from './Flow'
 
 
-import { Flow, FlowArgs } from './Flow'
+export type JobProps = { apiFactory: ApiFactory; env: NodeJS.ProcessEnv; query: QueryNodeApi }
 
 
 function noop() {
 function noop() {
   // No-Op
   // No-Op
@@ -89,7 +92,7 @@ export class Job {
     return this._label
     return this._label
   }
   }
 
 
-  private async run(flowArgs: FlowArgs): Promise<void> {
+  private async run(jobProps: JobProps): Promise<void> {
     // prevent any additional changes to configuration
     // prevent any additional changes to configuration
     this._locked = true
     this._locked = true
 
 
@@ -104,7 +107,15 @@ export class Job {
     await Promise.all(this._after.map((job) => job.outcome))
     await Promise.all(this._after.map((job) => job.outcome))
 
 
     this.debug('Running')
     this.debug('Running')
-    const flowRunResults = await Promise.allSettled(this._flows.map((flow) => flow(flowArgs)))
+    const flowRunResults = await Promise.allSettled(
+      this._flows.map((flow) =>
+        flow({
+          api: jobProps.apiFactory.getApi(`${this.label}:${flow.name}`),
+          env: jobProps.env,
+          query: jobProps.query,
+        })
+      )
+    )
 
 
     flowRunResults.forEach((result, ix) => {
     flowRunResults.forEach((result, ix) => {
       if (result.status === 'rejected') {
       if (result.status === 'rejected') {

+ 20 - 6
tests/network-tests/src/FlowManager.ts → tests/network-tests/src/JobManager.ts

@@ -1,14 +1,20 @@
 import { EventEmitter } from 'events'
 import { EventEmitter } from 'events'
-import { Flow, FlowArgs } from './Flow'
+import { Flow } from './Flow'
 import { Job, JobOutcome } from './Job'
 import { Job, JobOutcome } from './Job'
+import { ApiFactory } from './Api'
+import { QueryNodeApi } from './QueryNodeApi'
 
 
-export class FlowManager extends EventEmitter {
-  private readonly flowArgs: FlowArgs
+export class JobManager extends EventEmitter {
   private _jobs: Job[] = []
   private _jobs: Job[] = []
+  private readonly _apiFactory: ApiFactory
+  private readonly _env: NodeJS.ProcessEnv
+  private readonly _query: QueryNodeApi
 
 
-  constructor(flowArgs: FlowArgs) {
+  constructor({ apiFactory, env, query }: { apiFactory: ApiFactory; env: NodeJS.ProcessEnv; query: QueryNodeApi }) {
     super()
     super()
-    this.flowArgs = flowArgs
+    this._apiFactory = apiFactory
+    this._env = env
+    this._query = query
   }
   }
 
 
   public createJob(label: string, flows: Flow[] | Flow): Job {
   public createJob(label: string, flows: Flow[] | Flow): Job {
@@ -20,8 +26,16 @@ export class FlowManager extends EventEmitter {
     return job
     return job
   }
   }
 
 
+  private getJobProps() {
+    return {
+      env: this._env,
+      query: this._query,
+      apiFactory: this._apiFactory,
+    }
+  }
+
   public async run(): Promise<void> {
   public async run(): Promise<void> {
-    this.emit('run', this.flowArgs)
+    this.emit('run', this.getJobProps())
 
 
     const outcomes = await Promise.all(this._jobs.map((job) => job.outcome))
     const outcomes = await Promise.all(this._jobs.map((job) => job.outcome))
 
 

+ 19 - 18
tests/network-tests/src/Scenario.ts

@@ -1,22 +1,20 @@
 import { WsProvider } from '@polkadot/api'
 import { WsProvider } from '@polkadot/api'
-import { Api } from './Api'
+import { ApiFactory } from './Api'
 import { QueryNodeApi } from './QueryNodeApi'
 import { QueryNodeApi } from './QueryNodeApi'
 import { config } from 'dotenv'
 import { config } from 'dotenv'
 import { ApolloClient, InMemoryCache } from '@apollo/client'
 import { ApolloClient, InMemoryCache } from '@apollo/client'
 import Debugger from 'debug'
 import Debugger from 'debug'
 import { Flow } from './Flow'
 import { Flow } from './Flow'
 import { Job } from './Job'
 import { Job } from './Job'
-import { FlowManager } from './FlowManager'
-
-export async function scenario(
-  fn: (cfg: {
-    api: Api
-    query: QueryNodeApi
-    env: NodeJS.ProcessEnv
-    debug: Debugger.Debugger
-    job: (label: string, flows: Flow[] | Flow) => Job
-  }) => Promise<void>
-): Promise<void> {
+import { JobManager } from './JobManager'
+
+export type ScenarioProps = {
+  env: NodeJS.ProcessEnv
+  debug: Debugger.Debugger
+  job: (label: string, flows: Flow[] | Flow) => Job
+}
+
+export async function scenario(scene: (props: ScenarioProps) => Promise<void>): Promise<void> {
   // Load env variables
   // Load env variables
   config()
   config()
   const env = process.env
   const env = process.env
@@ -25,7 +23,11 @@ export async function scenario(
   const nodeUrl: string = env.NODE_URL || 'ws://127.0.0.1:9944'
   const nodeUrl: string = env.NODE_URL || 'ws://127.0.0.1:9944'
   const provider = new WsProvider(nodeUrl)
   const provider = new WsProvider(nodeUrl)
 
 
-  const api = await Api.create(provider, env.TREASURY_ACCOUNT_URI || '//Alice', env.SUDO_ACCOUNT_URI || '//Alice')
+  const apiFactory = await ApiFactory.create(
+    provider,
+    env.TREASURY_ACCOUNT_URI || '//Alice',
+    env.SUDO_ACCOUNT_URI || '//Alice'
+  )
 
 
   const queryNodeUrl: string = env.QUERY_NODE_URL || 'http://127.0.0.1:8081/graphql'
   const queryNodeUrl: string = env.QUERY_NODE_URL || 'http://127.0.0.1:8081/graphql'
 
 
@@ -39,13 +41,12 @@ export async function scenario(
 
 
   const debug = Debugger('scenario')
   const debug = Debugger('scenario')
 
 
-  const flowManager = new FlowManager({ api, query, env })
+  const jobs = new JobManager({ apiFactory, query, env })
 
 
-  // Does the scenario really need the flow args?
-  await fn({ api, query, env, debug, job: flowManager.createJob.bind(flowManager) })
+  await scene({ env, debug, job: jobs.createJob.bind(jobs) })
 
 
   try {
   try {
-    await flowManager.run()
+    await jobs.run()
   } catch (err) {
   } catch (err) {
     console.error(err)
     console.error(err)
     process.exit(-1)
     process.exit(-1)
@@ -53,5 +54,5 @@ export async function scenario(
 
 
   // Note: disconnecting and then reconnecting to the chain in the same process
   // Note: disconnecting and then reconnecting to the chain in the same process
   // doesn't seem to work!
   // doesn't seem to work!
-  api.close()
+  apiFactory.close()
 }
 }

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

@@ -45,7 +45,7 @@ export class BuyMembershipHappyCaseFixture extends BaseFixture {
 
 
     this.debug(`Registered ${this.memberIds.length} new members`)
     this.debug(`Registered ${this.memberIds.length} new members`)
 
 
-    assert.equal(this.accounts.length, this.memberIds.length)
+    assert.equal(this.memberIds.length, this.accounts.length)
   }
   }
 }
 }
 
 

+ 2 - 2
tests/network-tests/src/flows/contentDirectory/contentDirectoryInitialization.ts

@@ -1,8 +1,8 @@
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import Debugger from 'debug'
 import Debugger from 'debug'
 const debug = Debugger('initializeContentDirectory')
 const debug = Debugger('initializeContentDirectory')
 
 
-export default async function initializeContentDirectory({ api }: FlowArgs): Promise<void> {
+export default async function initializeContentDirectory({ api }: FlowProps): Promise<void> {
   debug('Started')
   debug('Started')
   await api.initializeContentDirectory()
   await api.initializeContentDirectory()
   debug('Done')
   debug('Done')

+ 2 - 2
tests/network-tests/src/flows/contentDirectory/creatingChannel.ts

@@ -1,5 +1,5 @@
 import { Api } from '../../Api'
 import { Api } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { Utils } from '../../utils'
 import { Utils } from '../../utils'
 import { CreateChannelFixture } from '../../fixtures/contentDirectoryModule'
 import { CreateChannelFixture } from '../../fixtures/contentDirectoryModule'
 import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
 import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
@@ -30,7 +30,7 @@ function assertChannelMatchQueriedResult(queriedChannel: any, channel: ChannelEn
   assert.equal(queriedChannel.isPublic, channel.isPublic, 'Should be equal')
   assert.equal(queriedChannel.isPublic, channel.isPublic, 'Should be equal')
 }
 }
 
 
-export default async function channelCreation({ api, query }: FlowArgs): Promise<void> {
+export default async function channelCreation({ api, query }: FlowProps): Promise<void> {
   const debug = Debugger('flow:creatingChannel')
   const debug = Debugger('flow:creatingChannel')
   debug('Started')
   debug('Started')
 
 

+ 2 - 2
tests/network-tests/src/flows/contentDirectory/creatingVideo.ts

@@ -1,5 +1,5 @@
 import { Api } from '../../Api'
 import { Api } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { CreateVideoFixture } from '../../fixtures/contentDirectoryModule'
 import { CreateVideoFixture } from '../../fixtures/contentDirectoryModule'
 import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
 import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
 import { assert } from 'chai'
 import { assert } from 'chai'
@@ -55,7 +55,7 @@ function assertVideoMatchQueriedResult(queriedVideo: any, video: VideoEntity) {
   assert.equal(queriedVideo.isPublic, video.isPublic, 'Should be equal')
   assert.equal(queriedVideo.isPublic, video.isPublic, 'Should be equal')
 }
 }
 
 
-export default async function createVideo({ api, query }: FlowArgs): Promise<void> {
+export default async function createVideo({ api, query }: FlowProps): Promise<void> {
   const debug = Debugger('flow:creatingVideo')
   const debug = Debugger('flow:creatingVideo')
   debug('Started')
   debug('Started')
 
 

+ 2 - 2
tests/network-tests/src/flows/contentDirectory/updatingChannel.ts

@@ -1,5 +1,5 @@
 import { Api } from '../../Api'
 import { Api } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { UpdateChannelFixture } from '../../fixtures/contentDirectoryModule'
 import { UpdateChannelFixture } from '../../fixtures/contentDirectoryModule'
 import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
 import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
 import { assert } from 'chai'
 import { assert } from 'chai'
@@ -18,7 +18,7 @@ export function createUpdateChannelHandleFixture(api: Api, handle: string, descr
   return new UpdateChannelFixture(api, channelUpdateInput, uniquePropVal)
   return new UpdateChannelFixture(api, channelUpdateInput, uniquePropVal)
 }
 }
 
 
-export default async function updateChannel({ api, query }: FlowArgs): Promise<void> {
+export default async function updateChannel({ api, query }: FlowProps): Promise<void> {
   const debug = Debugger('flow:updateChannel')
   const debug = Debugger('flow:updateChannel')
   debug('Started')
   debug('Started')
 
 

+ 3 - 2
tests/network-tests/src/flows/membership/creatingMemberships.ts

@@ -1,4 +1,4 @@
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import {
 import {
   BuyMembershipHappyCaseFixture,
   BuyMembershipHappyCaseFixture,
   BuyMembershipWithInsufficienFundsFixture,
   BuyMembershipWithInsufficienFundsFixture,
@@ -9,9 +9,10 @@ import Debugger from 'debug'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 import { assert } from 'chai'
 import { assert } from 'chai'
 
 
-export default async function membershipCreation({ api, env }: FlowArgs): Promise<void> {
+export default async function membershipCreation({ api, env }: FlowProps): Promise<void> {
   const debug = Debugger('flow:memberships')
   const debug = Debugger('flow:memberships')
   debug('Started')
   debug('Started')
+  api.enableTxLogs()
 
 
   const N: number = +env.MEMBERSHIP_CREATION_N!
   const N: number = +env.MEMBERSHIP_CREATION_N!
   assert(N > 0)
   assert(N > 0)

+ 2 - 2
tests/network-tests/src/flows/proposals/councilSetup.ts

@@ -1,12 +1,12 @@
 import BN from 'bn.js'
 import BN from 'bn.js'
 import { PaidTermId } from '@joystream/types/members'
 import { PaidTermId } from '@joystream/types/members'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { ElectCouncilFixture } from '../../fixtures/councilElectionModule'
 import { ElectCouncilFixture } from '../../fixtures/councilElectionModule'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import Debugger from 'debug'
 import Debugger from 'debug'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 
 
-export default async function councilSetup({ api, env }: FlowArgs): Promise<void> {
+export default async function councilSetup({ api, env }: FlowProps): Promise<void> {
   const label = 'councilSetup'
   const label = 'councilSetup'
   const debug = Debugger(`flow:${label}`)
   const debug = Debugger(`flow:${label}`)
 
 

+ 3 - 3
tests/network-tests/src/flows/proposals/electionParametersProposal.ts

@@ -1,12 +1,12 @@
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { ElectionParametersProposalFixture } from '../../fixtures/proposalsModule'
 import { ElectionParametersProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
 // Election parameters proposal scenario
 // Election parameters proposal scenario
-export default async function electionParametersProposal({ api }: FlowArgs): Promise<void> {
-  const debug = Debugger('electionParametersProposal')
+export default async function electionParametersProposal({ api }: FlowProps): Promise<void> {
+  const debug = Debugger('flow:electionParametersProposal')
   debug('Started')
   debug('Started')
 
 
   // Pre-Conditions: some members and an elected council
   // Pre-Conditions: some members and an elected council

+ 3 - 3
tests/network-tests/src/flows/proposals/manageLeaderRole.ts

@@ -1,6 +1,6 @@
 import BN from 'bn.js'
 import BN from 'bn.js'
 import { Api, WorkingGroups } from '../../Api'
 import { Api, WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import {
 import {
   BeginWorkingGroupLeaderApplicationReviewFixture,
   BeginWorkingGroupLeaderApplicationReviewFixture,
@@ -22,10 +22,10 @@ import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
 export default {
 export default {
-  storage: async function ({ api, env }: FlowArgs): Promise<void> {
+  storage: async function ({ api, env }: FlowProps): Promise<void> {
     return manageLeaderRole(api, env, WorkingGroups.StorageWorkingGroup)
     return manageLeaderRole(api, env, WorkingGroups.StorageWorkingGroup)
   },
   },
-  content: async function ({ api, env }: FlowArgs): Promise<void> {
+  content: async function ({ api, env }: FlowProps): Promise<void> {
     return manageLeaderRole(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
     return manageLeaderRole(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
   },
   },
 }
 }

+ 2 - 2
tests/network-tests/src/flows/proposals/spendingProposal.ts

@@ -1,11 +1,11 @@
 import BN from 'bn.js'
 import BN from 'bn.js'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { SpendingProposalFixture } from '../../fixtures/proposalsModule'
 import { SpendingProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
-export default async function spendingProposal({ api, env }: FlowArgs): Promise<void> {
+export default async function spendingProposal({ api, env }: FlowProps): Promise<void> {
   const debug = Debugger('flow:spendingProposals')
   const debug = Debugger('flow:spendingProposals')
   debug('Started')
   debug('Started')
 
 

+ 2 - 2
tests/network-tests/src/flows/proposals/textProposal.ts

@@ -1,10 +1,10 @@
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { TextProposalFixture } from '../../fixtures/proposalsModule'
 import { TextProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
-export default async function textProposal({ api }: FlowArgs): Promise<void> {
+export default async function textProposal({ api }: FlowProps): Promise<void> {
   const debug = Debugger('flow:textProposal')
   const debug = Debugger('flow:textProposal')
   debug('Started')
   debug('Started')
 
 

+ 2 - 2
tests/network-tests/src/flows/proposals/updateRuntime.ts

@@ -1,5 +1,5 @@
 import BN from 'bn.js'
 import BN from 'bn.js'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import { UpdateRuntimeFixture } from '../../fixtures/proposalsModule'
 import { UpdateRuntimeFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { PaidTermId } from '@joystream/types/members'
@@ -7,7 +7,7 @@ import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
-export default async function updateRuntime({ api, env }: FlowArgs): Promise<void> {
+export default async function updateRuntime({ api, env }: FlowProps): Promise<void> {
   const debug = Debugger('flow:updateRuntime')
   const debug = Debugger('flow:updateRuntime')
   debug('Started')
   debug('Started')
 
 

+ 2 - 2
tests/network-tests/src/flows/proposals/validatorCountProposal.ts

@@ -1,11 +1,11 @@
 import BN from 'bn.js'
 import BN from 'bn.js'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { ValidatorCountProposalFixture } from '../../fixtures/proposalsModule'
 import { ValidatorCountProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
-export default async function validatorCount({ api, env }: FlowArgs): Promise<void> {
+export default async function validatorCount({ api, env }: FlowProps): Promise<void> {
   const debug = Debugger('flow:validatorCountProposal')
   const debug = Debugger('flow:validatorCountProposal')
   debug('Started')
   debug('Started')
 
 

+ 3 - 3
tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts

@@ -1,6 +1,6 @@
 import BN from 'bn.js'
 import BN from 'bn.js'
 import { Api, WorkingGroups } from '../../Api'
 import { Api, WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../../fixtures/proposalsModule'
 import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from '../../fixtures/proposalsModule'
 import { ProposalId } from '@joystream/types/proposals'
 import { ProposalId } from '@joystream/types/proposals'
 import { assert } from 'chai'
 import { assert } from 'chai'
@@ -8,11 +8,11 @@ import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
 export default {
 export default {
-  storage: async function ({ api, env }: FlowArgs): Promise<void> {
+  storage: async function ({ api, env }: FlowProps): Promise<void> {
     return workingGroupMintCapactiy(api, env, WorkingGroups.StorageWorkingGroup)
     return workingGroupMintCapactiy(api, env, WorkingGroups.StorageWorkingGroup)
   },
   },
 
 
-  content: async function ({ api, env }: FlowArgs): Promise<void> {
+  content: async function ({ api, env }: FlowProps): Promise<void> {
     return workingGroupMintCapactiy(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
     return workingGroupMintCapactiy(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
   },
   },
 }
 }

+ 2 - 2
tests/network-tests/src/flows/storageNode/getContentFromStorageNode.ts

@@ -3,11 +3,11 @@ import { assert } from 'chai'
 import { ContentId } from '@joystream/types/media'
 import { ContentId } from '@joystream/types/media'
 import { registry } from '@joystream/types'
 import { registry } from '@joystream/types'
 
 
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { Utils } from '../../utils'
 import { Utils } from '../../utils'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
-export default async function getContentFromStorageNode({ api, query }: FlowArgs): Promise<void> {
+export default async function getContentFromStorageNode({ api, query }: FlowProps): Promise<void> {
   const debug = Debugger('flow:getContentFromStorageNode')
   const debug = Debugger('flow:getContentFromStorageNode')
   debug('Started')
   debug('Started')
 
 

+ 4 - 2
tests/network-tests/src/flows/workingGroup/atLeastValueBug.ts

@@ -1,5 +1,5 @@
 import { WorkingGroups } from '../../Api'
 import { WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import { AddWorkerOpeningFixture } from '../../fixtures/workingGroupModule'
 import { AddWorkerOpeningFixture } from '../../fixtures/workingGroupModule'
 import BN from 'bn.js'
 import BN from 'bn.js'
 import { assert } from 'chai'
 import { assert } from 'chai'
@@ -7,9 +7,11 @@ import Debugger from 'debug'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 
 
 // Zero at least value bug scenario
 // Zero at least value bug scenario
-export default async function zeroAtLeastValueBug({ api, env }: FlowArgs): Promise<void> {
+export default async function zeroAtLeastValueBug({ api, env }: FlowProps): Promise<void> {
   const debug = Debugger('flow:atLeastValueBug')
   const debug = Debugger('flow:atLeastValueBug')
   debug('Started')
   debug('Started')
+  api.enableTxLogs()
+
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
   const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
   const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)
   const unstakingPeriod: BN = new BN(env.STORAGE_WORKING_GROUP_UNSTAKING_PERIOD!)

+ 3 - 3
tests/network-tests/src/flows/workingGroup/leaderSetup.ts

@@ -1,5 +1,5 @@
 import { Api, WorkingGroups } from '../../Api'
 import { Api, WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import BN from 'bn.js'
 import BN from 'bn.js'
 import { PaidTermId } from '@joystream/types/members'
 import { PaidTermId } from '@joystream/types/members'
 import { SudoHireLeadFixture } from '../../fixtures/sudoHireLead'
 import { SudoHireLeadFixture } from '../../fixtures/sudoHireLead'
@@ -9,10 +9,10 @@ import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
 export default {
 export default {
-  storage: async function ({ api, env }: FlowArgs): Promise<void> {
+  storage: async function ({ api, env }: FlowProps): Promise<void> {
     return leaderSetup(api, env, WorkingGroups.StorageWorkingGroup)
     return leaderSetup(api, env, WorkingGroups.StorageWorkingGroup)
   },
   },
-  content: async function ({ api, env }: FlowArgs): Promise<void> {
+  content: async function ({ api, env }: FlowProps): Promise<void> {
     return leaderSetup(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
     return leaderSetup(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
   },
   },
 }
 }

+ 4 - 4
tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts

@@ -1,5 +1,5 @@
 import { Api, WorkingGroups } from '../../Api'
 import { Api, WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import {
 import {
   ApplyForOpeningFixture,
   ApplyForOpeningFixture,
   AddWorkerOpeningFixture,
   AddWorkerOpeningFixture,
@@ -17,16 +17,16 @@ import Debugger from 'debug'
 import { FixtureRunner } from '../../Fixture'
 import { FixtureRunner } from '../../Fixture'
 
 
 export default {
 export default {
-  storage: async function ({ api, env }: FlowArgs): Promise<void> {
+  storage: async function ({ api, env }: FlowProps): Promise<void> {
     return manageWorkerAsLead(api, env, WorkingGroups.StorageWorkingGroup)
     return manageWorkerAsLead(api, env, WorkingGroups.StorageWorkingGroup)
   },
   },
-  content: async function ({ api, env }: FlowArgs): Promise<void> {
+  content: async function ({ api, env }: FlowProps): Promise<void> {
     return manageWorkerAsLead(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
     return manageWorkerAsLead(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
   },
   },
 }
 }
 
 
 async function manageWorkerAsLead(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups): Promise<void> {
 async function manageWorkerAsLead(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups): Promise<void> {
-  const debug = Debugger(`manageWorkerAsLead:${group}`)
+  const debug = Debugger(`flow:manageWorkerAsLead:${group}`)
   debug('Started')
   debug('Started')
 
 
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)

+ 4 - 4
tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts

@@ -1,5 +1,5 @@
 import { Api, WorkingGroups } from '../../Api'
 import { Api, WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import {
 import {
   AddWorkerOpeningFixture,
   AddWorkerOpeningFixture,
   ApplyForOpeningFixture,
   ApplyForOpeningFixture,
@@ -16,17 +16,17 @@ import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
 export default {
 export default {
-  storage: async function ({ api, env }: FlowArgs): Promise<void> {
+  storage: async function ({ api, env }: FlowProps): Promise<void> {
     return manageWorkerAsWorker(api, env, WorkingGroups.StorageWorkingGroup)
     return manageWorkerAsWorker(api, env, WorkingGroups.StorageWorkingGroup)
   },
   },
-  content: async function ({ api, env }: FlowArgs): Promise<void> {
+  content: async function ({ api, env }: FlowProps): Promise<void> {
     return manageWorkerAsWorker(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
     return manageWorkerAsWorker(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
   },
   },
 }
 }
 
 
 // Manage worker as worker
 // Manage worker as worker
 async function manageWorkerAsWorker(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
 async function manageWorkerAsWorker(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
-  const debug = Debugger(`manageWorkerAsWorker:${group}`)
+  const debug = Debugger(`flow:manageWorkerAsWorker:${group}`)
   debug('Started')
   debug('Started')
 
 
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)

+ 3 - 3
tests/network-tests/src/flows/workingGroup/workerPayout.ts

@@ -1,5 +1,5 @@
 import { Api, WorkingGroups } from '../../Api'
 import { Api, WorkingGroups } from '../../Api'
-import { FlowArgs } from '../../Flow'
+import { FlowProps } from '../../Flow'
 import {
 import {
   AddWorkerOpeningFixture,
   AddWorkerOpeningFixture,
   ApplyForOpeningFixture,
   ApplyForOpeningFixture,
@@ -18,10 +18,10 @@ import { FixtureRunner } from '../../Fixture'
 import Debugger from 'debug'
 import Debugger from 'debug'
 
 
 export default {
 export default {
-  storage: async function ({ api, env }: FlowArgs): Promise<void> {
+  storage: async function ({ api, env }: FlowProps): Promise<void> {
     return workerPayouts(api, env, WorkingGroups.StorageWorkingGroup)
     return workerPayouts(api, env, WorkingGroups.StorageWorkingGroup)
   },
   },
-  content: async function ({ api, env }: FlowArgs): Promise<void> {
+  content: async function ({ api, env }: FlowProps): Promise<void> {
     return workerPayouts(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
     return workerPayouts(api, env, WorkingGroups.ContentDirectoryWorkingGroup)
   },
   },
 }
 }

+ 1 - 4
tests/network-tests/src/scenarios/full.ts

@@ -13,10 +13,7 @@ import manageWorkerAsWorker from '../flows/workingGroup/manageWorkerAsWorker'
 import workerPayout from '../flows/workingGroup/workerPayout'
 import workerPayout from '../flows/workingGroup/workerPayout'
 import { scenario } from '../Scenario'
 import { scenario } from '../Scenario'
 
 
-scenario(async ({ api, debug, job }) => {
-  debug('Enabling failed tx logs')
-  api.enableTxLogs()
-
+scenario(async ({ job }) => {
   job('creating members', creatingMemberships)
   job('creating members', creatingMemberships)
 
 
   const councilJob = job('council setup', councilSetup)
   const councilJob = job('council setup', councilSetup)

+ 10 - 8
tests/network-tests/src/sender.ts

@@ -11,16 +11,16 @@ import { assert } from 'chai'
 
 
 export class Sender {
 export class Sender {
   private readonly api: ApiPromise
   private readonly api: ApiPromise
-  private readonly asyncLock: AsyncLock
+  private static readonly asyncLock: AsyncLock = new AsyncLock()
   private readonly keyring: Keyring
   private readonly keyring: Keyring
   private readonly debug: Debugger.Debugger
   private readonly debug: Debugger.Debugger
   private logFailedTransactions = false
   private logFailedTransactions = false
+  private static _count = 0
 
 
-  constructor(api: ApiPromise, keyring: Keyring) {
+  constructor(api: ApiPromise, keyring: Keyring, label: string) {
     this.api = api
     this.api = api
-    this.asyncLock = new AsyncLock()
     this.keyring = keyring
     this.keyring = keyring
-    this.debug = Debugger('sender')
+    this.debug = Debugger(`Sender:${Sender._count++}:${label}`)
   }
   }
 
 
   // Synchronize all sending of transactions into mempool, so we can always safely read
   // Synchronize all sending of transactions into mempool, so we can always safely read
@@ -29,11 +29,11 @@ export class Sender {
   // The promise resolves on tx finalization (For both Dispatch success and failure)
   // The promise resolves on tx finalization (For both Dispatch success and failure)
   // The promise is rejected if transaction is rejected by node.
   // The promise is rejected if transaction is rejected by node.
 
 
-  public enableLogs() {
+  public enableLogs(): void {
     this.logFailedTransactions = true
     this.logFailedTransactions = true
   }
   }
 
 
-  public disableLogs() {
+  public disableLogs(): void {
     this.logFailedTransactions = false
     this.logFailedTransactions = false
   }
   }
 
 
@@ -108,14 +108,16 @@ export class Sender {
       if (success || failed) finalized(result)
       if (success || failed) finalized(result)
     }
     }
 
 
-    await this.asyncLock.acquire(`${senderKeyPair.address}`, async () => {
+    await Sender.asyncLock.acquire(`${senderKeyPair.address}`, async () => {
       const nonce = await this.api.rpc.system.accountNextIndex(senderKeyPair.address)
       const nonce = await this.api.rpc.system.accountNextIndex(senderKeyPair.address)
       const signedTx = tx.sign(senderKeyPair, { nonce })
       const signedTx = tx.sign(senderKeyPair, { nonce })
       sentTx = signedTx.toHuman()
       sentTx = signedTx.toHuman()
+      const { method, section } = signedTx.method
       try {
       try {
         await signedTx.send(handleEvents)
         await signedTx.send(handleEvents)
+        this.debug('Submitted tx:', `${section}.${method}`)
       } catch (err) {
       } catch (err) {
-        this.debug('Submitting Tx failed:', sentTx)
+        this.debug('Submitting tx failed:', sentTx)
         throw err
         throw err
       }
       }
     })
     })