ignazio 3 年 前
コミット
85803e0ff6

+ 9 - 9
tests/network-tests/.eslintrc.js

@@ -1,12 +1,12 @@
 module.exports = {
-    env: {
-        node: true,
-    },
+  env: {
+    node: true,
+  },
   rules: {
-      'no-async-promise-executor': 'off',
-      'no-useless-return': 'off',
-      'new-cap': 'off',
-      // Disabled because of the false positive bug: https://github.com/eslint/eslint/issues/11899
-      'require-atomic-updates': 'off',
-  }
+    'no-async-promise-executor': 'off',
+    'no-useless-return': 'off',
+    'new-cap': 'off',
+    // Disabled because of the false positive bug: https://github.com/eslint/eslint/issues/11899
+    'require-atomic-updates': 'off',
+  },
 }

+ 1 - 1
tests/network-tests/package.json

@@ -2,7 +2,7 @@
   "name": "network-tests",
   "version": "0.1.0",
   "license": "GPL-3.0-only",
-    "scripts": {
+  "scripts": {
     "build": "tsc --noEmit",
     "test": "./run-tests.sh",
     "run-test-scenario": "./run-test-scenario.sh",

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

@@ -32,7 +32,7 @@ import { FillOpeningParameters, ProposalId } from '@joystream/types/proposals'
 // import { v4 as uuid } from 'uuid'
 import { extendDebug } from './Debugger'
 import { InvertedPromise } from './InvertedPromise'
-import { VideoId, VideoCategoryId, } from '@joystream/types/content'
+import { VideoId, VideoCategoryId } from '@joystream/types/content'
 import { ChannelId } from '@joystream/types/common'
 import { ChannelCategoryMetadata, VideoCategoryMetadata } from '@joystream/metadata-protobuf'
 import { metadataToBytes } from '../../../cli/lib/helpers/serialization'
@@ -1789,19 +1789,18 @@ export class Api {
   async getMemberControllerAccount(memberId: number): Promise<string | undefined> {
     return (await this.api.query.members.membershipById(memberId))?.controller_account.toString()
   }
-    
+
   public async getNumberOfOutstandingVideos(): Promise<number> {
-      return (await this.api.query.content.videoById.entries<VideoId>()).length
+    return (await this.api.query.content.videoById.entries<VideoId>()).length
   }
 
   public async getNumberOfOutstandingChannels(): Promise<number> {
-      return (await this.api.query.content.channelById.entries<ChannelId>()).length
+    return (await this.api.query.content.channelById.entries<ChannelId>()).length
   }
 
   public async getNumberOfOutstandingVideoCategories(): Promise<number> {
-      return (await this.api.query.content.videoCategoryById.entries<VideoCategoryId>()).length
+    return (await this.api.query.content.videoCategoryById.entries<VideoCategoryId>()).length
   }
-    
 
   // Create a mock channel, throws on failure
   async createMockChannel(memberId: number, memberControllerAccount?: string): Promise<ChannelId> {

+ 51 - 49
tests/network-tests/src/misc/postMigrationAssertionsFlow.ts

@@ -1,66 +1,68 @@
 import { assert } from 'chai'
 import { FlowProps } from '../Flow'
 import { extendDebug } from '../Debugger'
-import { Utils } from '../../utils'
+import { Utils } from '../utils'
 
 export default async function postMigrationAssertions({ api }: FlowProps): Promise<void> {
-    const debug = extendDebug('flow:postMigrationAssertions')
-    debug('Started')
-
-    debug('Ensure migration is done')
-
-    let channel_migration = await api.query.content.channelMigration();
-    let video_migration = await api.query.content.videoMigration();
-
-    // wait for migration to be done and checking that index do actually change
-    while (channel_migration.current_id.toNumber() < channel_migration.final_id.toNumber() ||
-        video_migration.current_id.toNumber() < video_migration.final_id.toNumber()) {
-        let channel_migration_new = await api.query.content.channelMigration();
-        let video_migration_new = await api.query.content.videoMigration();
-
-        // assert invariant in order to prevent infinite loop
-        if (channel_migration_new.current_id.toNumber() > channel_migration.current_id.toNumber() &&
-            video_migration_new.current_id.toNumber() > video_migration.current_id.toNumber()) {
-
-            // update migration variables
-            channel_migration = channel_migration_new;
-            video_migration = video_migration_new;
-
-            // wait 6 seconds
-            await Utils.wait(6000)
-        } else {
-            throw "Migration indices not updating";
-        }
-
+  const debug = extendDebug('flow:postMigrationAssertions')
+  debug('Started')
+
+  debug('Ensure migration is done')
+
+  let channelMigration = await api.query.content.channelMigration()
+  let videoMigration = await api.query.content.videoMigration()
+
+  // wait for migration to be done and checking that index do actually change
+  while (
+    channelMigration.current_id.toNumber() < channelMigration.final_id.toNumber() ||
+    videoMigration.current_id.toNumber() < videoMigration.final_id.toNumber()
+  ) {
+    const channelMigrationNew = await api.query.content.channelMigration()
+    const videoMigrationNew = await api.query.content.videoMigration()
+
+    // assert invariant in order to prevent infinite loop
+    if (
+      channelMigrationNew.current_id.toNumber() > channelMigration.current_id.toNumber() &&
+      videoMigrationNew.current_id.toNumber() > videoMigration.current_id.toNumber()
+    ) {
+      // update migration variables
+      channelMigration = channelMigrationNew
+      videoMigration = videoMigrationNew
+
+      // wait 6 seconds
+      await Utils.wait(6000)
+    } else {
+      throw new Error('Unable to connect to chain')
     }
+  }
 
-    debug('Check all new  working groups have been correctly initialized')
+  debug('Check all new  working groups have been correctly initialized')
 
-    const wg_beta = await api.query.operationsWorkingGroupBeta.activeWorkerCount();
-    const wg_gamma = await api.query.operationsWorkingGroupGamma.activeWorkerCount();
-    const wg_gateway = await api.query.gatewayWorkingGroup.activeWorkerCount();
+  const wgBeta = await api.query.operationsWorkingGroupBeta.activeWorkerCount()
+  const wgGamma = await api.query.operationsWorkingGroupGamma.activeWorkerCount()
+  const wgGateway = await api.query.gatewayWorkingGroup.activeWorkerCount()
 
-    assert.equal(wg_beta.toNumber(), 0);
-    assert.equal(wg_gamma.toNumber(), 0);
-    assert.equal(wg_gateway.toNumber(), 0);
+  assert.equal(wgBeta.toNumber(), 0)
+  assert.equal(wgGamma.toNumber(), 0)
+  assert.equal(wgGateway.toNumber(), 0)
 
-    debug('Checking that Video, Channel, Categories  counters have not been re-set')
+  debug('Checking that Video, Channel, Categories  counters have not been re-set')
 
-    const nextVideoCategoryId = await api.query.content.nextVideoCategoryId()
-    const nextVideoId = await api.query.content.nextVideoId()
-    const nextChannelId = await api.query.content.nextChannelId()
+  const nextVideoCategoryId = await api.query.content.nextVideoCategoryId()
+  const nextVideoId = await api.query.content.nextVideoId()
+  const nextChannelId = await api.query.content.nextChannelId()
 
-    assert(nextVideoCategoryId.toNumber() > 1);
-    assert(nextVideoId.toNumber() > 1);
-    assert(nextChannelId.toNumber() > 1);
+  assert(nextVideoCategoryId.toNumber() > 1)
+  assert(nextVideoId.toNumber() > 1)
+  assert(nextChannelId.toNumber() > 1)
 
-    debug('Checking that number of outstanding channels & videos == 0');
+  debug('Checking that number of outstanding channels & videos == 0')
 
-    const num_channels = await api.getNumberOfOutstandingChannels()
-    const num_videos = await api.getNumberOfOutstandingVideos()
+  const numChannels = await api.getNumberOfOutstandingChannels()
+  const numVideos = await api.getNumberOfOutstandingVideos()
 
-    assert.equal(num_channels, 0);
-    assert.equal(num_videos, 0);
+  assert.equal(numChannels, 0)
+  assert.equal(numVideos, 0)
 
-    debug('Done')
+  debug('Done')
 }

+ 1 - 4
tests/network-tests/src/scenarios/post-migration.ts

@@ -2,8 +2,5 @@ import postMigrationAssertions from '../misc/postMigrationAssertionsFlow'
 import { scenario } from '../Scenario'
 
 scenario(async ({ job }) => {
-    job(
-        'Verify post-migration chain state',
-        postMigrationAssertions
-    )
+  job('Verify post-migration chain state', postMigrationAssertions)
 })

+ 1 - 1
tests/network-tests/tsconfig.json

@@ -12,7 +12,7 @@
     "resolveJsonModule": true,
     "paths": {
       "@polkadot/types/augment": ["../../types/augment-codec/augment-types.ts"],
-      "@polkadot/api/augment": [ "../../types/augment-codec/augment-api.ts"]
+      "@polkadot/api/augment": ["../../types/augment-codec/augment-api.ts"]
     }
   }
 }