Quellcode durchsuchen

Query node integration tests: move apollo-client dependency to the right place

iorveth vor 4 Jahren
Ursprung
Commit
68ecab08a3

+ 0 - 3
package.json

@@ -50,8 +50,5 @@
   "engines": {
     "node": ">=12.18.0",
     "yarn": "^1.22.0"
-  },
-  "dependencies": {
-    "@apollo/client": "^3.2.5"
   }
 }

+ 2 - 2
query-node/.env

@@ -5,7 +5,7 @@ PROJECT_NAME=query_node
 #     Common settings     #
 ###########################
 
-# The env variables below are by default used by all services and should be 
+# The env variables below are by default used by all services and should be
 # overriden in local env files (e.g. ./generated/indexer) if needed
 # DB config
 DB_NAME=query_node
@@ -46,7 +46,7 @@ TYPES_JSON=../../typedefs.json
 # Indexer GraphQL API endpoint to fetch indexed events
 INDEXER_ENDPOINT_URL=http://localhost:4100/graphql
 
-# Block height from which the processor starts. Note that if 
+# Block height from which the processor starts. Note that if
 # there are already processed events in the database, this setting is ignored
 BLOCK_HEIGHT=0
 

+ 1 - 4
query-node/indexer-tsconfig.json

@@ -13,10 +13,7 @@
     "strictPropertyInitialization": false,
     "baseUrl": ".",
     "paths": {
-      "@polkadot/types/augment": [
-        "../../../types/augment/all",
-        "../../../types/augment-codec/augment-types.ts"
-      ]
+      "@polkadot/types/augment": ["../../../types/augment-codec/augment-types.ts"]
     }
   },
   "exclude": ["node_modules"]

+ 4 - 4
query-node/mappings/content-directory/content-dir-consts.ts

@@ -18,13 +18,13 @@ export enum ContentDirectoryKnownClasses {
 export const contentDirectoryClassNamesWithId: { classId: number; name: string }[] = [
   { name: ContentDirectoryKnownClasses.CHANNEL, classId: 1 },
   { name: ContentDirectoryKnownClasses.CATEGORY, classId: 2 },
-  { name: ContentDirectoryKnownClasses.HTTPMEDIALOCATION, classId: 3 },
-  { name: ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION, classId: 4 },
   { name: ContentDirectoryKnownClasses.KNOWNLICENSE, classId: 5 },
-  { name: ContentDirectoryKnownClasses.LANGUAGE, classId: 6 },
   { name: ContentDirectoryKnownClasses.USERDEFINEDLICENSE, classId: 9 },
-  { name: ContentDirectoryKnownClasses.VIDEO, classId: 10 },
+  { name: ContentDirectoryKnownClasses.LANGUAGE, classId: 6 },
+  { name: ContentDirectoryKnownClasses.JOYSTREAMMEDIALOCATION, classId: 4 },
+  { name: ContentDirectoryKnownClasses.HTTPMEDIALOCATION, classId: 3 },
   { name: ContentDirectoryKnownClasses.VIDEOMEDIA, classId: 11 },
+  { name: ContentDirectoryKnownClasses.VIDEO, classId: 10 },
   { name: ContentDirectoryKnownClasses.VIDEOMEDIAENCODING, classId: 12 },
 ]
 

+ 7 - 17
query-node/mappings/content-directory/decode.ts

@@ -8,14 +8,7 @@ import {
   IEntity,
 } from '../types'
 
-import {
-  ParametrizedClassPropertyValue,
-  ParametrizedPropertyValue,
-  ParameterizedEntity,
-  UpdatePropertyValuesOperation,
-  InputPropertyValue,
-  OperationType,
-} from '@joystream/types/content-directory'
+import { ParametrizedClassPropertyValue, UpdatePropertyValuesOperation } from '@joystream/types/content-directory'
 import { createType } from '@joystream/types'
 
 function stringIfyEntityId(event: SubstrateEvent): string {
@@ -31,7 +24,7 @@ function setProperties<T>({ extrinsic, blockNumber }: SubstrateEvent, propNamesW
 
   for (const [k, v] of Object.entries(newPropertyValues.value)) {
     const propertyName = propNamesWithId[k]
-    const propertyValue = (createType('InputPropertyValue' as never, v as never) as InputPropertyValue)
+    const propertyValue = createType('InputPropertyValue', v as any)
       .asType('Single')
       .value.toJSON()
     properties[propertyName] = propertyValue
@@ -71,13 +64,10 @@ function setEntityPropertyValues<T>(properties: IProperty[], propertyNamesWithId
 // Decode entity property values
 function getEntityProperties(propertyValues: ParametrizedClassPropertyValue[]): IProperty[] {
   const properties: IProperty[] = []
-  const entityPropertyValues = createType(
-    'Vec<ParametrizedClassPropertyValue>' as never,
-    propertyValues as never
-  ) as ParametrizedClassPropertyValue[]
+  const entityPropertyValues = createType('Vec<ParametrizedClassPropertyValue>', propertyValues)
 
   entityPropertyValues.map((pv: ParametrizedClassPropertyValue) => {
-    const v = createType('ParametrizedPropertyValue' as never, pv.value as never) as ParametrizedPropertyValue
+    const v = createType('ParametrizedPropertyValue', pv.value)
     const propertyId = pv.in_class_index.toJSON()
 
     let value
@@ -99,7 +89,7 @@ function getEntityProperties(propertyValues: ParametrizedClassPropertyValue[]):
 }
 
 function getOperations({ extrinsic }: SubstrateEvent): IBatchOperation {
-  const operations = createType('Vec<OperationType>' as never, extrinsic!.args[1].value as never) as OperationType[]
+  const operations = createType('Vec<OperationType>', extrinsic!.args[1].value as any)
 
   const updatePropertyValuesOperations: IEntity[] = []
   const addSchemaSupportToEntityOperations: IEntity[] = []
@@ -111,7 +101,7 @@ function getOperations({ extrinsic }: SubstrateEvent): IBatchOperation {
       createEntityOperations.push({ classId: cep.class_id.toJSON() })
     } else if (operation.isOfType('AddSchemaSupportToEntity')) {
       const op = operation.asType('AddSchemaSupportToEntity')
-      const pe = createType('ParameterizedEntity' as never, op.entity_id as never) as ParameterizedEntity
+      const pe = createType('ParameterizedEntity', op.entity_id)
       const entity: IEntity = {
         properties: getEntityProperties(op.parametrized_property_values),
       }
@@ -136,7 +126,7 @@ function makeEntity(upv: UpdatePropertyValuesOperation): IEntity {
   const entity: IEntity = {
     properties: getEntityProperties(upv.new_parametrized_property_values),
   }
-  const pe = createType('ParameterizedEntity' as never, upv.entity_id as never) as ParameterizedEntity
+  const pe = createType('ParameterizedEntity', upv.entity_id)
   if (pe.isOfType('InternalEntityJustAdded')) {
     entity.indexOf = pe.asType('InternalEntityJustAdded').toJSON()
   } else {

+ 1 - 1
query-node/mappings/types.ts

@@ -1,4 +1,4 @@
-import * as BN from 'bn.js'
+import BN from 'bn.js'
 import { EntityId, SchemaId, ParametrizedClassPropertyValue, ClassId } from '@joystream/types/content-directory'
 import { DB } from '../generated/indexer'
 

+ 3 - 5
query-node/tsconfig.json

@@ -14,11 +14,9 @@
     "inlineSources": false,
     "baseUrl": ".",
     "paths": {
-      "@polkadot/types/augment": [
-        "../types/augment/all",
-        "../types/augment-codec/augment-types.ts"
-      ]
-    }
+      "@polkadot/types/augment": ["../types/augment-codec/augment-types.ts"]
+    },
+    "esModuleInterop": true
   },
   "include": ["mappings/**/*"],
   "exclude": ["node_modules"]

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

@@ -21,7 +21,8 @@
     "bn.js": "^4.11.8",
     "dotenv": "^8.2.0",
     "fs": "^0.0.1-security",
-    "uuid": "^7.0.3"
+    "uuid": "^7.0.3",
+    "@apollo/client": "^3.2.5"
   },
   "devDependencies": {
     "@polkadot/ts": "^0.3.14",

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

@@ -31,9 +31,8 @@ export default async function channelCreation(api: QueryNodeApi, pair: KeyringPa
   // Temporary solution (wait 10 minutes)
   await delay(600000)
 
-  await api
-    .getChannelbyTitle(createChannelHappyCaseFixture.channelEntity.title)
-    .then((result) => console.log(result.data))
+  const result = await api.getChannelbyTitle(createChannelHappyCaseFixture.channelEntity.title)
+  console.log(result.data)
 
   // assert(data.title === createChannelHappyCaseFixture.channelEntity.title, 'Should be equal')
   // assert(data.description === createChannelHappyCaseFixture.channelEntity.description, 'Should be equal')

+ 7 - 2
yarn.lock

@@ -10529,7 +10529,7 @@ date-utils@*:
   resolved "https://registry.yarnpkg.com/date-utils/-/date-utils-1.2.21.tgz#61fb16cdc1274b3c9acaaffe9fc69df8720a2b64"
   integrity sha1-YfsWzcEnSzyayq/+n8ad+HIKK2Q=
 
-dateformat@^3.0.0:
+dateformat@^3.0.0, dateformat@^3.0.2:
   version "3.0.3"
   resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae"
   integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==
@@ -10542,6 +10542,11 @@ dateformat@~1.0.4-1.2.3:
     get-stdin "^4.0.1"
     meow "^3.3.0"
 
+datejs@^1.0.0-rc3:
+  version "1.0.0-rc3"
+  resolved "https://registry.yarnpkg.com/datejs/-/datejs-1.0.0-rc3.tgz#bffa1efedefeb41fdd8a242af55afa01fb58de57"
+  integrity sha1-v/oe/t7+tB/diiQq9Vr6AftY3lc=
+
 de-indent@^1.0.2:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
@@ -19248,7 +19253,7 @@ lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
   integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
 
-lodash@^4.17.20:
+lodash@^4.17.20, lodash@^4.3.0:
   version "4.17.20"
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
   integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==