Browse Source

fixed checks

ignazio 3 years ago
parent
commit
545d1a42c3

+ 3 - 3
tests/network-tests/run-migration-tests.sh

@@ -47,7 +47,7 @@ function fork_off_init() {
 
 function export_chainspec_file_to_disk() {
     if ! [[ -f ${DATA_PATH}/exported-state.json ]]; then
-   # write the initial genesis state to db, in order to wait arbitrary amount of time 
+    # write the initial genesis state to db, in order to aviod waiting for an arbitrary amount of time 
     docker-compose -f ../../docker-compose.yml run \
 		   -v ${DATA_PATH}:/spec joystream-node export-state \
 		   --chain /spec/chain-spec-raw.json \
@@ -69,13 +69,13 @@ function main {
     fork_off_init
 
     # export chain-spec BEFORE starting the node
-    export_chainspec_file_to_disk
+#    export_chainspec_file_to_disk
     
     echo "***** STARTING NODE WITH FORKED STATE *****"
     export JOYSTREAM_NODE_TAG=$RUNTIME_TAG
     CONTAINER_ID=$(start_node)
     
-    sleep 30
+    sleep 120
     
     if ( $POST_MIGRATION_ASYNC_ASSERTIONS ); then
 	# verify assertion using typsecript

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

@@ -4,65 +4,66 @@ import { extendDebug } from '../Debugger'
 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 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()
+    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()
     ) {
-      // update migration variables
-      channelMigration = channelMigrationNew
-      videoMigration = videoMigrationNew
-
-      // wait 6 seconds
-      await Utils.wait(6000)
-    } else {
-      throw new Error('Unable to connect to chain')
+        // wait 6 seconds until next block is produced
+        await Utils.wait(6000)
+
+        const channelMigrationNew = await api.query.content.channelMigration()
+        const videoMigrationNew = await api.query.content.videoMigration()
+
+        // check 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
+
+        } else {
+            throw new Error('Migration status not changing')
+        }
     }
-  }
 
-  debug('Check all new  working groups have been correctly initialized')
+    debug('Check all new  working groups have been correctly initialized')
 
-  const wgBeta = await api.query.operationsWorkingGroupBeta.activeWorkerCount()
-  const wgGamma = await api.query.operationsWorkingGroupGamma.activeWorkerCount()
-  const wgGateway = 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(wgBeta.toNumber(), 0)
-  assert.equal(wgGamma.toNumber(), 0)
-  assert.equal(wgGateway.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 numChannels = await api.getNumberOfOutstandingChannels()
-  const numVideos = await api.getNumberOfOutstandingVideos()
+    const numChannels = await api.getNumberOfOutstandingChannels()
+    const numVideos = await api.getNumberOfOutstandingVideos()
 
-  assert.equal(numChannels, 0)
-  assert.equal(numVideos, 0)
+    assert.equal(numChannels, 0)
+    assert.equal(numVideos, 0)
 
-  debug('Done')
+    debug('Done')
 }