Browse Source

integration-tests: basic logs start and end of flow

Mokhtar Naamani 4 years ago
parent
commit
aec99383c3

+ 5 - 1
tests/network-tests/src/flows/contentDirectory/contentDirectoryInitialization.ts

@@ -1,6 +1,10 @@
 import { Api } from '../../Api'
 import { KeyringPair } from '@polkadot/keyring/types'
+import Debugger from 'debug'
+const debug = Debugger('initializeContentDirectory')
 
 export default async function initializeContentDirectory(api: Api, leadKeyPair: KeyringPair): Promise<void> {
-  return api.initializeContentDirectory(leadKeyPair)
+  debug('Started')
+  await api.initializeContentDirectory(leadKeyPair)
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/contentDirectory/creatingChannel.ts

@@ -5,6 +5,7 @@ import { CreateChannelFixture } from '../../fixtures/contentDirectoryModule'
 import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export function createSimpleChannelFixture(api: Api): CreateChannelFixture {
   const channelEntity: ChannelEntity = {
@@ -30,6 +31,9 @@ function assertChannelMatchQueriedResult(queriedChannel: any, channel: ChannelEn
 }
 
 export default async function channelCreation(api: Api, query: QueryNodeApi): Promise<void> {
+  const debug = Debugger('flow:creatingChannel')
+  debug('Started')
+
   const createChannelHappyCaseFixture = createSimpleChannelFixture(api)
 
   await new FixtureRunner(createChannelHappyCaseFixture).run()
@@ -41,4 +45,6 @@ export default async function channelCreation(api: Api, query: QueryNodeApi): Pr
   const result = await query.getChannelbyHandle(createChannelHappyCaseFixture.channelEntity.handle)
 
   assertChannelMatchQueriedResult(result.data.channels[0], createChannelHappyCaseFixture.channelEntity)
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/contentDirectory/creatingVideo.ts

@@ -5,6 +5,7 @@ import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
 import { assert } from 'chai'
 import { Utils } from '../../utils'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export function createVideoReferencingChannelFixture(api: Api, handle: string): CreateVideoFixture {
   const videoEntity: VideoEntity = {
@@ -55,6 +56,9 @@ function assertVideoMatchQueriedResult(queriedVideo: any, video: VideoEntity) {
 }
 
 export default async function createVideo(api: Api, query: QueryNodeApi): Promise<void> {
+  const debug = Debugger('flow:creatingVideo')
+  debug('Started')
+
   const channelTitle = 'New channel example'
   const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api, channelTitle)
 
@@ -106,4 +110,6 @@ export default async function createVideo(api: Api, query: QueryNodeApi): Promis
   videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('MediaVideo')
 
   assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/contentDirectory/updatingChannel.ts

@@ -5,6 +5,7 @@ import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntit
 import { assert } from 'chai'
 import { Utils } from '../../utils'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export function createUpdateChannelHandleFixture(api: Api, handle: string, description: string): UpdateChannelFixture {
   // Create partial channel entity, only containing the fields we wish to update
@@ -18,6 +19,9 @@ export function createUpdateChannelHandleFixture(api: Api, handle: string, descr
 }
 
 export default async function updateChannel(api: Api, query: QueryNodeApi): Promise<void> {
+  const debug = Debugger('flow:updateChannel')
+  debug('Started')
+
   const handle = 'New channel example'
   const channelResult = await query.getChannelbyHandle(handle)
   const channel = channelResult.data.channels[0]
@@ -40,4 +44,6 @@ export default async function updateChannel(api: Api, query: QueryNodeApi): Prom
   assert.equal(channelAfterUpdate.coverPhotoUrl, channel.coverPhotoUrl, 'Should be equal')
   assert.equal(channelAfterUpdate.avatarPhotoUrl, channel.avatarPhotoUrl, 'Should be equal')
   assert.equal(channelAfterUpdate.isPublic, channel.isPublic, 'Should be equal')
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/electionParametersProposal.ts

@@ -2,9 +2,13 @@ import { Api } from '../../Api'
 import { ElectionParametersProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 // Election parameters proposal scenario
 export default async function electionParametersProposal(api: Api, env: NodeJS.ProcessEnv) {
+  const debug = Debugger('electionParametersProposal')
+  debug('Started')
+
   // Pre-Conditions: some members and an elected council
   const council = await api.getCouncil()
   assert.notEqual(council.length, 0)
@@ -13,4 +17,6 @@ export default async function electionParametersProposal(api: Api, env: NodeJS.P
 
   const electionParametersProposalFixture = new ElectionParametersProposalFixture(api, proposer)
   await new FixtureRunner(electionParametersProposalFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/manageLeaderRole.ts

@@ -18,8 +18,12 @@ import { ProposalId } from '@joystream/types/proposals'
 import { WorkerId } from '@joystream/types/working-group'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export default async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
+  const debug = Debugger(`flow:managerLeaderRole:${group}`)
+  debug('Started')
+
   const leaderAccount = api.createKeyPairs(1)[0].address
 
   const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
@@ -180,4 +184,6 @@ export default async function manageLeaderRole(api: Api, env: NodeJS.ProcessEnv,
 
   const maybeLead = await api.getGroupLead(group)
   assert(!maybeLead)
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/spendingProposal.ts

@@ -3,8 +3,12 @@ import { Api } from '../../Api'
 import { SpendingProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export default async function spendingProposal(api: Api, env: NodeJS.ProcessEnv) {
+  const debug = Debugger('flow:spendingProposals')
+  debug('Started')
+
   const spendingBalance: BN = new BN(+env.SPENDING_BALANCE!)
   const mintCapacity: BN = new BN(+env.COUNCIL_MINTING_CAPACITY!)
 
@@ -18,4 +22,6 @@ export default async function spendingProposal(api: Api, env: NodeJS.ProcessEnv)
 
   // Spending proposal test
   await new FixtureRunner(spendingProposalFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/textProposal.ts

@@ -2,8 +2,12 @@ import { Api } from '../../Api'
 import { TextProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export default async function textProposal(api: Api, env: NodeJS.ProcessEnv) {
+  const debug = Debugger('flow:textProposal')
+  debug('Started')
+
   // Pre-conditions: members and council
   const council = await api.getCouncil()
   assert(council.length)
@@ -12,4 +16,6 @@ export default async function textProposal(api: Api, env: NodeJS.ProcessEnv) {
 
   const textProposalFixture: TextProposalFixture = new TextProposalFixture(api, proposer)
   await new FixtureRunner(textProposalFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/updateRuntime.ts

@@ -5,8 +5,12 @@ import { UpdateRuntimeFixture } from '../../fixtures/proposalsModule'
 import { PaidTermId } from '@joystream/types/members'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export default async function updateRuntime(api: Api, env: NodeJS.ProcessEnv) {
+  const debug = Debugger('flow:updateRuntime')
+  debug('Started')
+
   const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
   const runtimePath: string = env.RUNTIME_WASM_PATH!
 
@@ -26,4 +30,6 @@ export default async function updateRuntime(api: Api, env: NodeJS.ProcessEnv) {
     paidTerms
   )
   await new FixtureRunner(createMembershipsFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/validatorCountProposal.ts

@@ -3,8 +3,12 @@ import { Api } from '../../Api'
 import { ValidatorCountProposalFixture } from '../../fixtures/proposalsModule'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export default async function validatorCount(api: Api, env: NodeJS.ProcessEnv) {
+  const debug = Debugger('flow:validatorCountProposal')
+  debug('Started')
+
   // Pre-conditions: members and council
   const council = await api.getCouncil()
   assert(council.length)
@@ -19,4 +23,6 @@ export default async function validatorCount(api: Api, env: NodeJS.ProcessEnv) {
     validatorCountIncrement
   )
   await new FixtureRunner(validatorCountProposalFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/proposals/workingGroupMintCapacityProposal.ts

@@ -4,8 +4,12 @@ import { VoteForProposalFixture, WorkingGroupMintCapacityProposalFixture } from
 import { ProposalId } from '@joystream/types/proposals'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 export default async function workingGroupMintCapactiy(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
+  const debug = Debugger(`flow:workingGroupMintCapacityProposal:${group}`)
+  debug('Started')
+
   const mintCapacityIncrement: BN = new BN(env.MINT_CAPACITY_INCREMENT!)
 
   // Pre-conditions: members and council
@@ -30,4 +34,6 @@ export default async function workingGroupMintCapactiy(api: Api, env: NodeJS.Pro
 
   // Approve mint capacity
   await new FixtureRunner(voteForProposalFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/storageNode/getContentFromStorageNode.ts

@@ -6,8 +6,12 @@ import { registry } from '@joystream/types'
 import { Api } from '../../Api'
 import { QueryNodeApi } from '../../QueryNodeApi'
 import { Utils } from '../../utils'
+import Debugger from 'debug'
 
 export default async function getContentFromStorageNode(api: Api, query: QueryNodeApi): Promise<void> {
+  const debug = Debugger('flow:getContentFromStorageNode')
+  debug('Started')
+
   const videoTitle = 'Storage node test'
 
   // Temporary solution (wait 2 minutes)
@@ -37,4 +41,6 @@ export default async function getContentFromStorageNode(api: Api, query: QueryNo
   const contentLenght = Number.parseInt(response.headers['content-length'])
 
   assert.equal(contentLenght, dataObject!.size_in_bytes.toJSON(), 'Content should be same size')
+
+  debug('Done')
 }

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

@@ -5,10 +5,9 @@ import { assert } from 'chai'
 import Debugger from 'debug'
 import { FixtureRunner } from '../../Fixture'
 
-const debug = Debugger('flow:atLeastValueBug')
-
 // Zero at least value bug scenario
 export default async function zeroAtLeastValueBug(api: Api, env: NodeJS.ProcessEnv) {
+  const debug = Debugger('flow:atLeastValueBug')
   debug('Started')
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
@@ -18,7 +17,7 @@ export default async function zeroAtLeastValueBug(api: Api, env: NodeJS.ProcessE
   // Pre-conditions
   // A hired lead
   const lead = await api.getGroupLead(WorkingGroups.StorageWorkingGroup)
-  assert(lead)
+  assert.notEqual(lead, undefined)
 
   const addWorkerOpeningWithoutStakeFixture = new AddWorkerOpeningFixture(
     api,
@@ -31,6 +30,7 @@ export default async function zeroAtLeastValueBug(api: Api, env: NodeJS.ProcessE
 
   // Add worker opening with 0 stake, expect failure!
   await new FixtureRunner(addWorkerOpeningWithoutStakeFixture).run()
+
   assert.equal(
     addWorkerOpeningWithoutStakeFixture.getCreatedOpeningId(),
     undefined,
@@ -48,6 +48,7 @@ export default async function zeroAtLeastValueBug(api: Api, env: NodeJS.ProcessE
 
   // Add worker opening with 0 unstaking period, expect failure!
   await new FixtureRunner(addWorkerOpeningWithoutUnstakingPeriodFixture).run()
+
   assert.equal(
     addWorkerOpeningWithoutUnstakingPeriodFixture.getCreatedOpeningId(),
     undefined,

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

@@ -5,6 +5,7 @@ import { SudoHireLeadFixture } from '../../fixtures/sudoHireLead'
 import { assert } from 'chai'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 // Worker application happy case scenario
 export default async function leaderSetup(
@@ -12,9 +13,11 @@ export default async function leaderSetup(
   env: NodeJS.ProcessEnv,
   group: WorkingGroups
 ): Promise<KeyringPair> {
-  const lead = await api.getGroupLead(group)
+  const debug = Debugger(`flow:leaderSetup:${group}`)
+  debug('Started')
 
-  assert(!lead, `Lead is already set`)
+  const existingLead = await api.getGroupLead(group)
+  assert.equal(existingLead, undefined, 'Lead is already set')
 
   const leadKeyPair = api.createKeyPairs(1)[0]
   const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
@@ -40,8 +43,10 @@ export default async function leaderSetup(
   await new FixtureRunner(leaderHiringHappyCaseFixture).run()
 
   const hiredLead = await api.getGroupLead(group)
-  assert(hiredLead, `${group} group Lead was not hired!`)
+  assert.notEqual(hiredLead, undefined, `${group} group Lead was not hired!`)
   assert(hiredLead!.role_account_id.eq(leadKeyPair.address))
 
+  debug('Done')
+
   return leadKeyPair
 }

+ 14 - 3
tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts

@@ -16,8 +16,14 @@ import Debugger from 'debug'
 import { FixtureRunner } from '../../Fixture'
 
 // Manage worker as lead scenario
-export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
-  const debug = Debugger(`manageWorker:${group}`)
+export default async function manageWorkerAsLead(
+  api: Api,
+  env: NodeJS.ProcessEnv,
+  group: WorkingGroups
+): Promise<void> {
+  const debug = Debugger(`manageWorkerAsLead:${group}`)
+  debug('Started')
+
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
@@ -44,6 +50,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, gro
   )
   // Add worker opening
   await new FixtureRunner(addWorkerOpeningFixture).run()
+  assert(addWorkerOpeningFixture.getCreatedOpeningId())
 
   // First apply for worker opening
   const applyForWorkerOpeningFixture = new ApplyForOpeningFixture(
@@ -55,8 +62,10 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, gro
     group
   )
   await new FixtureRunner(applyForWorkerOpeningFixture).run()
+  const applicationIds = applyForWorkerOpeningFixture.getApplicationIds()
+  assert.equal(applicants.length, applicationIds.length)
 
-  const applicationIdsToHire = applyForWorkerOpeningFixture.getApplicationIds().slice(0, 2)
+  const applicationIdsToHire = applicationIds.slice(0, 2)
 
   // Begin application review
   const beginApplicationReviewFixture = new BeginApplicationReviewFixture(
@@ -92,4 +101,6 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, gro
 
   // Terminate workers
   await new FixtureRunner(terminateRoleFixture).run()
+
+  debug('Done')
 }

+ 6 - 0
tests/network-tests/src/flows/workingGroup/manageWorkerAsWorker.ts

@@ -12,9 +12,13 @@ import { OpeningId } from '@joystream/types/hiring'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 // Manage worker as worker
 export default async function manageWorkerAsWorker(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
+  const debug = Debugger(`manageWorkerAsWorker:${group}`)
+  debug('Started')
+
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
   const firstRewardInterval: BN = new BN(env.LONG_REWARD_INTERVAL!)
@@ -88,4 +92,6 @@ export default async function manageWorkerAsWorker(api: Api, env: NodeJS.Process
   const updateRoleAccountFixture: UpdateRewardAccountFixture = new UpdateRewardAccountFixture(api, workerId, group)
   // Update role account
   await new FixtureRunner(updateRoleAccountFixture).run()
+
+  debug('Done')
 }

+ 8 - 0
tests/network-tests/src/flows/workingGroup/workerPayout.ts

@@ -14,9 +14,13 @@ import { ProposalId } from '@joystream/types/proposals'
 import { BuyMembershipHappyCaseFixture } from '../../fixtures/membershipModule'
 import { assert } from 'chai'
 import { FixtureRunner } from '../../Fixture'
+import Debugger from 'debug'
 
 // Worker payout scenario
 export default async function workerPayouts(api: Api, env: NodeJS.ProcessEnv, group: WorkingGroups) {
+  const debug = Debugger(`flow:workerPayout:${group}`)
+  debug('Started')
+
   const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
   const applicationStake: BN = new BN(env.WORKING_GROUP_APPLICATION_STAKE!)
   const roleStake: BN = new BN(env.WORKING_GROUP_ROLE_STAKE!)
@@ -28,6 +32,8 @@ export default async function workerPayouts(api: Api, env: NodeJS.ProcessEnv, gr
   const openingActivationDelay: BN = new BN(0)
 
   const lead = await api.getGroupLead(group)
+  assert(lead)
+
   const newMembers = api.createKeyPairs(5).map((key) => key.address)
 
   const memberSetFixture = new BuyMembershipHappyCaseFixture(api, newMembers, paidTerms)
@@ -96,4 +102,6 @@ export default async function workerPayouts(api: Api, env: NodeJS.ProcessEnv, gr
   const awaitPayoutFixture: AwaitPayoutFixture = new AwaitPayoutFixture(api, workerId, group)
   // Await worker payout
   await new FixtureRunner(awaitPayoutFixture).run()
+
+  debug('Done')
 }