Browse Source

query node + cli + tests - active video counters improvements II

ondratra 3 years ago
parent
commit
02f473468c

+ 1 - 1
query-node/mappings/content/utils.ts

@@ -527,7 +527,7 @@ export async function unsetAssetRelations(store: DatabaseManager, dataObject: St
     await store.save<Video>(video)
 
     // update video active counters
-    await updateVideoActiveCounters(store, wasFullyActive as IVideoActiveStatus, undefined)
+    await updateVideoActiveCounters(store, wasFullyActive, undefined)
 
     // emit log event
     logger.info('Content has been disconnected from Video', {

+ 7 - 10
tests/network-tests/src/Api.ts

@@ -38,6 +38,7 @@ import { ChannelCategoryMetadata, VideoCategoryMetadata } from '@joystream/metad
 import { metadataToBytes } from '../../../cli/lib/helpers/serialization'
 import { assert } from 'chai'
 import { WorkingGroups } from './WorkingGroups'
+import { v4 as uuid } from 'uuid'
 
 const workingGroupNameByGroup: { [key in WorkingGroups]: string } = {
   'distributionWorkingGroup': 'Distribution',
@@ -142,7 +143,7 @@ export class ApiFactory {
     if (isCustom) {
       this.customKeys.push(suriPath)
     }
-    const uri = `${this.miniSecret}//testing//${suriPath}`
+    const uri = `${this.miniSecret}//testing//${suriPath}//${uuid().substring(0, 8)}`
     const pair = this.keyring.addFromUri(uri)
     this.addressesToSuri.set(pair.address, uri)
     return pair
@@ -1960,16 +1961,12 @@ export class Api {
     channelId: string,
     addStorageBuckets: StorageBucketId[]
   ) {
-    const bagId = { Dynamic: { Channel: channelId } }
-    const encodedStorageBucketIds = new BTreeSet<StorageBucketId>(
-      this.api.registry,
-      'StorageBucketId',
-      addStorageBuckets.map((item) => item.toString())
-    )
-    const noBucketsToRemove = new BTreeSet<StorageBucketId>(this.api.registry, 'StorageBucketId', [])
-
     return this.sender.signAndSend(
-      this.api.tx.storage.updateStorageBucketsForBag(bagId, encodedStorageBucketIds, noBucketsToRemove),
+      this.api.tx.storage.updateStorageBucketsForBag(
+        this.api.createType('BagId', { Dynamic: { Channel: channelId } }),
+        this.api.createType('BTreeSet<StorageBucketId>', [addStorageBuckets.map((item) => item.toString())]),
+        this.api.createType('BTreeSet<StorageBucketId>', [])
+      ),
       accountFrom
     )
   }

+ 1 - 1
tests/network-tests/src/consts.ts

@@ -1,2 +1,2 @@
 // Test chain blocktime
-export const BLOCKTIME = 1000
+export const BLOCKTIME = 6000

+ 2 - 13
tests/network-tests/src/fixtures/content/activeVideoCounters.ts

@@ -28,14 +28,7 @@ interface IMember {
   memberId: MemberId
 }
 
-// QN connection paramaters
-const qnConnection = {
-  numberOfRepeats: 20, // QN can take some time to catch up with node - repeat until then
-  repeatDelay: 3000, // delay between failed QN requests
-}
-
 // settings
-const contentDirectoryWorkingGroupId = 1 // TODO: retrieve group id programmatically
 const sufficientTopupAmount = new BN(1000000) // some very big number to cover fees of all transactions
 
 /**
@@ -268,11 +261,9 @@ export class ActiveVideoCountersFixture extends BaseQueryNodeFixture {
     entityId: number,
     expectedCount: number
   ) {
-    const qnConnectionNumberOfRepeats = 10
-
-    const getterName = `get${entityName[0].toUpperCase()}${entityName.slice(1)}`
+    const getterName = `get${entityName[0].toUpperCase()}${entityName.slice(1)}` as 'getChannels' | 'getChannelCategories' | 'getVideoCategories'
     await this.query.tryQueryWithTimeout(
-      () => (this.query as any)[getterName](),
+      () => this.query[getterName](),
       (tmpEntity) => {
         const entities = (tmpEntity as any).data[entityName]
         assert(entities.length > 0) // some entities were loaded
@@ -282,8 +273,6 @@ export class ActiveVideoCountersFixture extends BaseQueryNodeFixture {
         // all videos created in this fixture should be active and belong to first entity
         assert(entity.activeVideosCounter === expectedCount)
       },
-      qnConnection.repeatDelay,
-      qnConnection.numberOfRepeats
     )
   }