Browse Source

Merge sumer

iorveth 4 years ago
parent
commit
1557c79c5d

+ 4 - 0
.dockerignore

@@ -5,3 +5,7 @@ target/
 query-node/generated
 query-node/**/dist
 query-node/lib
+# rm -f during image build instead of ignoring
+# pioneer/
+cli/
+tests/

+ 2 - 0
.github/workflows/joystream-cli.yml

@@ -17,6 +17,7 @@ jobs:
     - name: checks
       run: |
         yarn install --frozen-lockfile
+        yarn workspace @joystream/types build
         yarn workspace @joystream/cli checks --quiet
     - name: yarn pack test
       run: |
@@ -39,6 +40,7 @@ jobs:
     - name: checks
       run: |
         yarn install --frozen-lockfile --network-timeout 120000
+        yarn workspace @joystream/types build
         yarn workspace @joystream/cli checks --quiet
     - name: yarn pack test
       run: |

+ 2 - 0
.github/workflows/network-tests.yml

@@ -17,6 +17,7 @@ jobs:
     - name: checks
       run: |
         yarn install --frozen-lockfile
+        yarn workspace @joystream/types build
         yarn workspace network-tests checks --quiet
 
   network_build_osx:
@@ -34,4 +35,5 @@ jobs:
     - name: checks
       run: |
         yarn install --frozen-lockfile --network-timeout 120000
+        yarn workspace @joystream/types build
         yarn workspace network-tests checks --quiet

+ 4 - 0
.github/workflows/pioneer.yml

@@ -17,6 +17,7 @@ jobs:
     - name: build
       run: |
         yarn install --frozen-lockfile
+        yarn workspace @joystream/types build
         yarn workspace pioneer build
 
   pioneer_build_osx:
@@ -34,6 +35,7 @@ jobs:
     - name: build
       run: |
         yarn install --frozen-lockfile --network-timeout 120000
+        yarn workspace @joystream/types build
         yarn workspace pioneer build
 
   pioneer_lint_ubuntu:
@@ -51,6 +53,7 @@ jobs:
     - name: lint
       run: |
         yarn install --frozen-lockfile
+        yarn workspace @joystream/types build
         yarn workspace pioneer lint --quiet
 
   pioneer_lint_osx:
@@ -68,4 +71,5 @@ jobs:
     - name: lint
       run: |
         yarn install --frozen-lockfile --network-timeout 120000
+        yarn workspace @joystream/types build
         yarn workspace pioneer lint --quiet

+ 15 - 5
.github/workflows/run-network-tests.yml

@@ -96,7 +96,9 @@ jobs:
           docker load --input joystream-node-docker-image.tar.gz
           docker images
       - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
+        run: |
+          yarn install --frozen-lockfile
+          yarn workspace @joystream/types build
       - name: Ensure tests are runnable
         run: yarn workspace network-tests build
       - name: Execute network tests
@@ -120,7 +122,9 @@ jobs:
           docker load --input joystream-node-docker-image.tar.gz
           docker images
       - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
+        run: |
+          yarn install --frozen-lockfile
+          yarn workspace @joystream/types build
       - name: Ensure tests are runnable
         run: yarn workspace network-tests build
       - name: Execute network tests
@@ -144,7 +148,9 @@ jobs:
           docker load --input joystream-node-docker-image.tar.gz
           docker images
       - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
+        run: |
+          yarn install --frozen-lockfile
+          yarn workspace @joystream/types build
       - name: Start chain
         run: docker-compose up -d joystream-node
       - name: Initialize the content directory
@@ -168,7 +174,9 @@ jobs:
           docker load --input joystream-node-docker-image.tar.gz
           docker images
       - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
+        run: |
+          yarn install --frozen-lockfile
+          yarn workspace @joystream/types build
       - name: Ensure query-node builds
         run: yarn workspace query-node-root build
       - name: Ensure tests are runnable
@@ -196,7 +204,9 @@ jobs:
           docker load --input joystream-node-docker-image.tar.gz
           docker images
       - name: Install packages and dependencies
-        run: yarn install --frozen-lockfile
+        run: |
+          yarn install --frozen-lockfile
+          yarn workspace @joystream/types build
       - name: Build storage node
         run: yarn workspace storage-node build
       - name: Start Services

+ 5 - 5
README.md

@@ -25,12 +25,11 @@ After cloning the repo run the following initialization scripts:
 # Install rust toolchain
 ./setup.sh
 
-# Install npm package dependencies
-# Also good habit to run this when switching between branches
-yarn install
+# Install npm package dependencies, build packages and docker images
+yarn build
 
-# run some tests
-yarn cargo-checks
+# start a local development network
+yarn start
 ```
 
 ## Software
@@ -75,6 +74,7 @@ The HEAD of the master branch should always be used for the correct version of t
 ```sh
 git checkout master
 yarn install
+yarn build:packages
 yarn workspace pioneer start
 ```
 

+ 22 - 4
apps.Dockerfile

@@ -2,13 +2,31 @@ FROM node:12 as builder
 
 WORKDIR /joystream
 COPY . /joystream
+RUN  rm -fr /joystream/pioneer
 
 # Do not set NODE_ENV=production until after running yarn install
 # to ensure dev dependencies are installed.
-RUN yarn install --frozen-lockfile
-# Uncomment query-node build when mappings are fixed
-# RUN yarn workspace query-node-root build
-RUN yarn workspace pioneer build
+RUN yarn --forzen-lockfile
+
+RUN yarn workspace @joystream/types build
+RUN yarn workspace query-node-root build
 RUN yarn workspace storage-node build
 
+# Second stage to reduce image size, enable it when
+# all packages have correctly identified what is a devDependency and what is not.
+# It will reduce the image size by about 500MB (down from 2.2GB to 1.7GB)
+
+# # Remove files that are not needed after build.
+# # We will re-fetch only dependencies needed for running the apps.
+# RUN rm -fr node_modules/
+# RUN rm -fr .git/
+
+# FROM node:12
+# WORKDIR /joystream
+# COPY --from=builder /joystream/ /joystream/
+
+# # Skip installing devDependencies, since we have already built the packages.
+# ENV NODE_ENV=production
+# RUN yarn install --forzen-lockfile --production
+
 ENTRYPOINT [ "yarn" ]

+ 37 - 0
build-docker-images.sh

@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -e
+
+if ! command -v docker-compose &> /dev/null
+then
+  echo "docker-compose not found. Skipping docker image builds."
+  exit 0
+fi
+
+# Build or fetch cached joystream/node docker image
+if [[ "$SKIP_JOYSTREAM_NODE" = 1 || "$SKIP_JOYSTREAM_NODE" = "true" ]]; then
+  echo "Skipping build of joystream/node docker image."
+else
+  # Fetch a cached joystream/node image if one is found matching code shasum instead of building
+  CODE_HASH=`scripts/runtime-code-shasum.sh`
+  IMAGE=joystream/node:${CODE_HASH}
+  echo "Trying to fetch cashed ${IMAGE} image"
+  docker pull ${IMAGE} || :
+
+  if ! docker inspect ${IMAGE} > /dev/null;
+  then
+    echo "Fetch failed, building image locally"
+    docker-compose build joystream-node
+  else
+    echo "Tagging cached image as 'latest'"
+    docker image tag ${IMAGE} joystream/node:latest
+  fi
+fi
+
+# Build joystream/apps docker image
+echo "Building 'joystream/apps' docker image..."
+docker-compose build colossus
+
+# Build the pioneer docker image
+echo "Building pioneer docker image"
+docker-compose build pioneer

+ 11 - 0
build-npm-packages.sh

@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -e
+
+yarn
+yarn workspace @joystream/types build
+yarn workspace query-node-root build
+# For now cli build is broken.. proceed anyway
+yarn workspace @joystream/cli build || :
+yarn workspace storage-node build
+yarn workspace pioneer build

+ 0 - 53
build.sh

@@ -1,53 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-yarn
-yarn workspace @joystream/types build
-yarn workspace @joystream/cli build
-yarn workspace query-node-root build
-yarn workspace storage-node build
-# Not strictly needed during development, we run "yarn workspace pioneer start" to start
-# a dev instance, but will show highlight build issues
-yarn workspace pioneer build
-
-if ! command -v docker-compose &> /dev/null
-then
-  echo "docker-compose not found, skipping docker build!"
-else
-  # Build joystream/apps docker image
-  docker-compose build pioneer
-
-  # Optionally build joystream/node docker image
-  # TODO: Try to fetch a cached joystream/node image
-  # if one is found matching code shasum instead of building
-  while true
-  do
-    read -p "Rebuild joystream/node docker image? (y/N): " answer2
-
-    case $answer2 in
-    [yY]* ) docker-compose build joystream-node
-            break;;
-
-    [nN]* ) break;;
-
-    * )     break;;
-    esac
-  done
-fi
-
-# Build cargo crates: native binaries joystream/node, wasm runtime, and chainspec builder.
-while true
-do
-  read -p "Compile joystream node native binary? (y/N): " answer1
-
-  case $answer1 in
-   [yY]* ) yarn cargo-checks
-           yarn cargo-build
-           break;;
-
-   [nN]* ) break;;
-
-   * )     break;;
-  esac
-done

+ 8 - 9
docker-compose.yml

@@ -79,7 +79,7 @@ services:
       - "127.0.0.1:8081:${GRAPHQL_SERVER_PORT}"
     depends_on: 
       - db
-    command: ["workspace", "query-node-root", "server:start:prod"]
+    command: ["workspace", "query-node-root", "query-node:start:prod"]
 
   processor:
     image: joystream/apps
@@ -95,7 +95,8 @@ services:
       - TYPEORM_HOST=db
       - TYPEORM_DATABASE=${DB_NAME}
       - DEBUG=index-builder:*
-      - WS_PROVIDER_ENDPOINT_URI=ws://joystream-node:9944
+      - WS_PROVIDER_ENDPOINT_URI=${WS_PROVIDER_ENDPOINT_URI}
+      - PROCESSOR_POLL_INTERVAL=1000 # refresh every second
     depends_on:
       - hydra-indexer-gateway
     command: ["workspace", "query-node-root", "processor:start"]
@@ -110,16 +111,15 @@ services:
       - DB_HOST=db
       - DB_NAME=${INDEXER_DB_NAME}
       - INDEXER_WORKERS=5
-      - PROCESSOR_POLL_INTERVAL=1000 # refresh every second 
       - REDIS_URI=redis://redis:6379/0
       - DEBUG=index-builder:*
       - WS_PROVIDER_ENDPOINT_URI=${WS_PROVIDER_ENDPOINT_URI}
-      - TYPES_JSON=${TYPES_JSON}
+      - TYPES_JSON=types.json
     depends_on:
       - db
       - redis
     volumes:
-      - ${TYPES_JSON}:/home/hydra/packages/hydra-indexer/types/augment/all/defs.json
+      - ${TYPES_JSON}:/home/hydra/packages/hydra-indexer/types.json
     command: >
       sh -c "yarn db:bootstrap && yarn start:prod"
 
@@ -153,10 +153,9 @@ services:
       - "127.0.0.1:6379:6379"
 
   pioneer:
-    image: joystream/apps
+    image: joystream/pioneer
     build:
       context: .
-      dockerfile: apps.Dockerfile
+      dockerfile: pioneer.Dockerfile
     ports:
-      - "127.0.0.1:3000:3000"
-    command: workspace pioneer start
+      - "127.0.0.1:3000:80"

+ 4 - 2
package.json

@@ -4,8 +4,9 @@
   "version": "1.0.0",
   "license": "GPL-3.0-only",
   "scripts": {
-    "postinstall": "yarn workspace @joystream/types build",
-    "build": "./build.sh",
+    "build": "./build-npm-packages.sh && ./build-docker-images.sh",
+    "build:packages": "./build-npm-packages.sh",
+    "build:docker": "./build-docker-images.sh",
     "start": "./start.sh",
     "cargo-checks": "devops/git-hooks/pre-commit && devops/git-hooks/pre-push",
     "cargo-build": "scripts/cargo-build.sh"
@@ -36,6 +37,7 @@
     "@polkadot/wasm-crypto": "^1.2.1",
     "babel-core": "^7.0.0-bridge.0",
     "typescript": "^3.9.7",
+    "typeorm": "^0.2.31",
     "bn.js": "^5.1.2"
   },
   "devDependencies": {

+ 18 - 0
pioneer.Dockerfile

@@ -0,0 +1,18 @@
+FROM node:12 as builder
+
+WORKDIR /joystream
+COPY . /joystream
+
+RUN yarn
+RUN NODE_ENV=production yarn workspace @joystream/types build
+RUN NODE_ENV=production yarn workspace pioneer build
+
+FROM ubuntu:18.04
+
+RUN apt-get update && apt-get -y install nginx
+
+COPY --from=builder /joystream/pioneer/packages/apps/build /var/www/html
+
+EXPOSE 80
+
+CMD ["nginx", "-g", "daemon off;"]

+ 2 - 2
query-node/build.sh

@@ -13,8 +13,8 @@ yarn clean
 
 yarn codegen:noinstall
 
+yarn mappings:build
+
 # We run yarn again to ensure graphql-server dependencies are installed
 # and are inline with root workspace resolutions
 yarn
-
-ln -s ../../../../../node_modules/typeorm/cli.js generated/graphql-server/node_modules/.bin/typeorm || :

+ 3 - 3
query-node/package.json

@@ -36,11 +36,11 @@
   "dependencies": {
     "tslib": "^2.0.0",
     "@types/bn.js": "^4.11.6",
-    "bn.js": "^5.1.2"
+    "bn.js": "^5.1.2",
+    "@dzlzv/hydra-cli": "2.0.0-beta",
+    "@dzlzv/hydra-processor": "0.1.1"
   },
   "devDependencies": {
-    "@dzlzv/hydra-cli": "2.0.0-beta",
-    "@dzlzv/hydra-processor": "0.1.1",
     "@dzlzv/hydra-typegen": "0.0.3-1"
   },
   "volta": {

+ 2 - 4
query-node/run-tests.sh

@@ -7,10 +7,6 @@ cd $SCRIPT_PATH
 # Only run codegen if no generated files found
 [ ! -d "generated/" ] && yarn build
 
-# Make sure typeorm is available.. it get removed when yarn is run again
-# typeorm commandline is used by db:migrate step below.
-ln -s ../../../../../node_modules/typeorm/cli.js generated/graphql-server/node_modules/.bin/typeorm || :
-
 set -a
 . ../.env
 set +a
@@ -24,6 +20,7 @@ function cleanup() {
     (echo "## Processor Logs ##" && docker logs joystream_processor_1 --tail 50) || :
     (echo "## Indexer Logs ##" && docker logs joystream_indexer_1 --tail 50) || :
     (echo "## Indexer API Gateway Logs ##" && docker logs joystream_hydra-indexer-gateway_1 --tail 50) || :
+    (echo "## Graphql Server Logs ##" && docker logs joystream_graphql-server_1 --tail 50) || :
     docker-compose down -v
 }
 
@@ -33,6 +30,7 @@ trap cleanup EXIT
 docker-compose up -d db
 
 # Migrate the databases
+yarn workspace query-node-root db:prepare
 yarn workspace query-node-root db:migrate
 
 docker-compose up -d graphql-server

+ 27 - 15
setup.sh

@@ -2,8 +2,25 @@
 
 set -e
 
+if [[ "$OSTYPE" == "linux-gnu" ]]; then
+    # code build tools
+    sudo apt-get update
+    sudo apt-get install -y coreutils clang jq curl gcc xz-utils sudo pkg-config unzip clang libc6-dev-i386 make libssl-dev python
+    # docker
+    sudo apt-get install -y docker.io docker-compose containerd runc
+elif [[ "$OSTYPE" == "darwin"* ]]; then
+    # install brew package manager
+    if ! which brew >/dev/null 2>&1; then
+      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
+    fi
+    # install additional packages
+    brew update
+    brew install b2sum gnu-tar jq curl
+    echo "It is recommended to setup Docker desktop from: https://www.docker.com/products/docker-desktop"
+fi
+
 # If OS is supported will install build tools for rust and substrate.
-# Skips installing substrate itself and subkey
+# Skips installation of substrate and subkey
 curl https://getsubstrate.io -sSf | bash -s -- --fast
 
 source ~/.cargo/env
@@ -23,21 +40,16 @@ rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23
 rustup install 1.46.0
 rustup default 1.46.0
 
-if [[ "$OSTYPE" == "linux-gnu" ]]; then
-    sudo apt-get install -y coreutils clang jq curl gcc xz-utils sudo pkg-config unzip clang libc6-dev-i386
-    sudo apt-get install -y docker.io docker-compose
-elif [[ "$OSTYPE" == "darwin"* ]]; then
-    brew install b2sum gnu-tar jq curl
-    echo "It is recommended to setup Docker desktop from: https://www.docker.com/products/docker-desktop"
-fi
-
 # Volta nodejs, npm, yarn tools manager
 curl https://get.volta.sh | bash
 
-# After installing volta the .profile and .bash_profile are updated
-# to add it to the PATH, so we start new shell to use it
-env bash -c "volta install node@12"
-env bash -c "volta install yarn"
-env bash -c "volta install npx"
+# source env variables added by Volta
+source source ~/.bash_profile || ~/.profile || source ~/.bashrc || :
+
+volta install node@12
+volta install yarn
+volta install npx
+
+echo "Starting new terminal/shell session to make newly installed tools available."
 
-echo "Open a new terminal to start using newly installed tools"
+exec bash -l

+ 12 - 4
start.sh

@@ -2,7 +2,8 @@
 set -e
 
 # Run a complete joystream development network on your machine using docker.
-# Make sure to run build.sh prior to running this script.
+# Make sure to run build-docker-images.sh prior to running this script to use
+# the local build.
 
 set -a
 . .env
@@ -26,17 +27,24 @@ docker-compose up -d joystream-node
 # Configure a dev storage node and start storage node
 DEBUG=joystream:storage-cli:dev yarn storage-cli dev-init
 docker-compose up -d colossus
+# Create a new content directory lead
+yarn workspace api-scripts initialize-content-lead
 
 ## Query Node Infrastructure
 # Initialize a new database for the query node infrastructure
 docker-compose up -d db
+yarn workspace query-node-root db:prepare
 yarn workspace query-node-root db:migrate
 
 # Startup all query-node infrastructure services
+export WS_PROVIDER_ENDPOINT_URI=ws://joystream-node:9944
 docker-compose up -d graphql-server
 docker-compose up -d processor
 
-echo "press Ctrl+C to shutdown"
+docker-compose up -d pioneer
 
-# Start a dev instance of pioneer and wait for exit
-docker-compose up pioneer
+echo "use Ctrl+C to shutdown the development network."
+
+while true; do 
+  read
+done

+ 0 - 65
tests/network-tests/src/Api.ts

@@ -30,10 +30,6 @@ import {
 } from '@joystream/types/hiring'
 import { FillOpeningParameters, ProposalId } from '@joystream/types/proposals'
 import { v4 as uuid } from 'uuid'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
-import { InputParser } from '@joystream/cd-schemas'
-import { OperationType } from '@joystream/types/content-directory'
 import { ContentId, DataObject } from '@joystream/types/storage'
 import Debugger from 'debug'
 
@@ -1729,67 +1725,6 @@ export class Api {
     return this.api.createType('u32', this.api.consts[module].maxWorkerNumberLimit)
   }
 
-  async sendContentDirectoryTransaction(operations: OperationType[]): Promise<ISubmittableResult> {
-    const transaction = this.api.tx.content.transaction(
-      { Lead: null }, // We use member with id 0 as actor (in this case we assume this is Alice)
-      operations // We provide parsed operations as second argument
-    )
-    const lead = (await this.getGroupLead(WorkingGroups.ContentDirectoryWorkingGroup)) as Worker
-    return this.sender.signAndSend(transaction, lead.role_account_id)
-  }
-
-  public async createChannelEntity(channel: ChannelEntity): Promise<ISubmittableResult> {
-    // Create the parser with known entity schemas (the ones in content-directory-schemas/inputs)
-    const parser = InputParser.createWithKnownSchemas(
-      this.api,
-      // The second argument is an array of entity batches, following standard entity batch syntax ({ className, entries }):
-      [
-        {
-          className: 'Channel',
-          entries: [channel], // We could specify multiple entries here, but in this case we only need one
-        },
-      ]
-    )
-    // We parse the input into CreateEntity and AddSchemaSupportToEntity operations
-    const operations = await parser.getEntityBatchOperations()
-    return this.sendContentDirectoryTransaction(operations)
-  }
-
-  public async createVideoEntity(video: VideoEntity): Promise<ISubmittableResult> {
-    // Create the parser with known entity schemas (the ones in content-directory-schemas/inputs)
-    const parser = InputParser.createWithKnownSchemas(
-      this.api,
-      // The second argument is an array of entity batches, following standard entity batch syntax ({ className, entries }):
-      [
-        {
-          className: 'Video',
-          entries: [video], // We could specify multiple entries here, but in this case we only need one
-        },
-      ]
-    )
-    // We parse the input into CreateEntity and AddSchemaSupportToEntity operations
-    const operations = await parser.getEntityBatchOperations()
-    return this.sendContentDirectoryTransaction(operations)
-  }
-
-  public async updateChannelEntity(
-    channelUpdateInput: Record<string, any>,
-    uniquePropValue: Record<string, any>
-  ): Promise<ISubmittableResult> {
-    // Create the parser with known entity schemas (the ones in content-directory-schemas/inputs)
-    const parser = InputParser.createWithKnownSchemas(this.api)
-
-    // We can reuse InputParser's `findEntityIdByUniqueQuery` method to find entityId of the channel we
-    // created in ./createChannel.ts example (normally we would probably use some other way to do it, ie.: query node)
-    const CHANNEL_ID = await parser.findEntityIdByUniqueQuery(uniquePropValue, 'Channel') // Use getEntityUpdateOperations to parse the update input
-    const updateOperations = await parser.getEntityUpdateOperations(
-      channelUpdateInput,
-      'Channel', // Class name
-      CHANNEL_ID // Id of the entity we want to update
-    )
-    return this.sendContentDirectoryTransaction(updateOperations)
-  }
-
   async getDataByContentId(contentId: ContentId): Promise<DataObject | null> {
     const dataObject = await this.api.query.dataDirectory.dataByContentId<Option<DataObject>>(contentId)
     return dataObject.unwrapOr(null)

+ 0 - 51
tests/network-tests/src/fixtures/contentDirectoryModule.ts

@@ -1,51 +0,0 @@
-import { Api } from '../Api'
-import { BaseFixture } from '../Fixture'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
-
-export class CreateChannelFixture extends BaseFixture {
-  public channelEntity: ChannelEntity
-
-  public constructor(api: Api, channelEntity: ChannelEntity) {
-    super(api)
-    this.channelEntity = channelEntity
-  }
-
-  public async execute(): Promise<void> {
-    this.expectDispatchSuccess(
-      await this.api.createChannelEntity(this.channelEntity),
-      'Create Channel should have succeeded'
-    )
-  }
-}
-
-export class CreateVideoFixture extends BaseFixture {
-  public videoEntity: VideoEntity
-
-  public constructor(api: Api, videoEntity: VideoEntity) {
-    super(api)
-    this.videoEntity = videoEntity
-  }
-
-  public async execute(): Promise<void> {
-    this.expectDispatchSuccess(await this.api.createVideoEntity(this.videoEntity), 'Create Video should have succeeded')
-  }
-}
-
-export class UpdateChannelFixture extends BaseFixture {
-  private channelUpdateInput: Record<string, any>
-  private uniquePropValue: Record<string, any>
-
-  public constructor(api: Api, channelUpdateInput: Record<string, any>, uniquePropValue: Record<string, any>) {
-    super(api)
-    this.channelUpdateInput = channelUpdateInput
-    this.uniquePropValue = uniquePropValue
-  }
-
-  public async execute(): Promise<void> {
-    this.expectDispatchSuccess(
-      await this.api.updateChannelEntity(this.channelUpdateInput, this.uniquePropValue),
-      'Update Channel should have succeeded'
-    )
-  }
-}

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

@@ -1,50 +0,0 @@
-import { Api } from '../../Api'
-import { FlowProps } from '../../Flow'
-import { Utils } from '../../utils'
-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 = {
-    handle: 'New channel example',
-    description: 'This is an example channel',
-    // We can use "existing" syntax to reference either an on-chain entity or other entity that's part of the same batch.
-    // Here we reference language that we assume was added by initialization script (initialize:dev), as it is part of
-    // input/entityBatches/LanguageBatch.json
-    language: { existing: { code: 'EN' } },
-    coverPhotoUrl: '',
-    avatarPhotoUrl: '',
-    isPublic: true,
-  }
-  return new CreateChannelFixture(api, channelEntity)
-}
-
-function assertChannelMatchQueriedResult(queriedChannel: any, channel: ChannelEntity) {
-  assert.equal(queriedChannel.handle, channel.handle, 'Should be equal')
-  assert.equal(queriedChannel.description, channel.description, 'Should be equal')
-  assert.equal(queriedChannel.coverPhotoUrl, channel.coverPhotoUrl, 'Should be equal')
-  assert.equal(queriedChannel.avatarPhotoUrl, channel.avatarPhotoUrl, 'Should be equal')
-  assert.equal(queriedChannel.isPublic, channel.isPublic, 'Should be equal')
-}
-
-export default async function channelCreation({ api, query }: FlowProps): Promise<void> {
-  const debug = Debugger('flow:creatingChannel')
-  debug('Started')
-
-  const createChannelHappyCaseFixture = createSimpleChannelFixture(api)
-
-  await new FixtureRunner(createChannelHappyCaseFixture).run()
-
-  // Temporary solution (wait 2 minutes)
-  await Utils.wait(120000)
-
-  // Ensure newly created channel was parsed by query node
-  const result = await query.getChannelbyHandle(createChannelHappyCaseFixture.channelEntity.handle)
-
-  assertChannelMatchQueriedResult(result.data.channels[0], createChannelHappyCaseFixture.channelEntity)
-
-  debug('Done')
-}

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

@@ -1,115 +0,0 @@
-import { Api } from '../../Api'
-import { FlowProps } from '../../Flow'
-import { CreateVideoFixture } from '../../fixtures/contentDirectoryModule'
-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 = {
-    title: 'Example video',
-    description: 'This is an example video',
-    // We reference existing language and category by their unique properties with "existing" syntax
-    // (those referenced here are part of inputs/entityBatches)
-    language: { existing: { code: 'EN' } },
-    category: { existing: { name: 'Education' } },
-    // We use the same "existing" syntax to reference a channel by unique property (handle)
-    // In this case it's a channel that we created in createChannel example
-    channel: { existing: { handle } },
-    media: {
-      // We use "new" syntax to sygnalize we want to create a new VideoMedia entity that will be related to this Video entity
-      new: {
-        // We use "exisiting" enconding from inputs/entityBatches/VideoMediaEncodingBatch.json
-        encoding: { existing: { name: 'H.263_MP4' } },
-        pixelHeight: 600,
-        pixelWidth: 800,
-        // We create nested VideoMedia->MediaLocation->HttpMediaLocation relations using the "new" syntax
-        location: { new: { httpMediaLocation: { new: { url: 'https://testnet.joystream.org/' } } } },
-      },
-    },
-    // Here we use combined "new" and "existing" syntaxes to create Video->License->KnownLicense relations
-    license: {
-      new: {
-        knownLicense: {
-          // This license can be found in inputs/entityBatches/KnownLicenseBatch.json
-          existing: { code: 'CC_BY' },
-        },
-      },
-    },
-    duration: 3600,
-    thumbnailUrl: '',
-    isExplicit: false,
-    isPublic: true,
-  }
-  return new CreateVideoFixture(api, videoEntity)
-}
-
-function assertVideoMatchQueriedResult(queriedVideo: any, video: VideoEntity) {
-  assert.equal(queriedVideo.title, video.title, 'Should be equal')
-  assert.equal(queriedVideo.description, video.description, 'Should be equal')
-  assert.equal(queriedVideo.duration, video.duration, 'Should be equal')
-  assert.equal(queriedVideo.thumbnailUrl, video.thumbnailUrl, 'Should be equal')
-  assert.equal(queriedVideo.isExplicit, video.isExplicit, 'Should be equal')
-  assert.equal(queriedVideo.isPublic, video.isPublic, 'Should be equal')
-}
-
-export default async function createVideo({ api, query }: FlowProps): Promise<void> {
-  const debug = Debugger('flow:creatingVideo')
-  debug('Started')
-
-  const channelTitle = 'New channel example'
-  const createVideoHappyCaseFixture = createVideoReferencingChannelFixture(api, channelTitle)
-
-  await new FixtureRunner(createVideoHappyCaseFixture).run()
-
-  // Temporary solution (wait 2 minutes)
-  await Utils.wait(120000)
-
-  // Perform number of full text searches on Channel title, that is a slight variation on title that one expects would return the video.
-  let channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('video')
-
-  assert(channelFullTextSearchResult.data.search.length === 1, 'Should contain exactly one entry')
-
-  // Both channel and video title starts with `Example`
-  channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('Example')
-
-  assert(channelFullTextSearchResult.data.search.length === 2, 'Should contain two entries')
-
-  // Perform number full text searches on Channel title, that absolutely should NOT return the video.
-  channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('First')
-
-  assert(channelFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  channelFullTextSearchResult = await query.performFullTextSearchOnChannelTitle('vid')
-
-  assert(channelFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  // Ensure channel contains only one video with right data
-  const channelResult = await query.getChannelbyHandle(channelTitle)
-
-  assert(channelResult.data.channels[0].videos.length === 1, 'Given channel should contain exactly one video')
-
-  assertVideoMatchQueriedResult(channelResult.data.channels[0].videos[0], createVideoHappyCaseFixture.videoEntity)
-
-  // Perform number of full text searches on Video title, that is a slight variation on title that one expects would return the video.
-  let videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('Example')
-
-  assert(videoFullTextSearchResult.data.search.length === 2, 'Should contain two entries')
-
-  videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('Example video')
-
-  assert(videoFullTextSearchResult.data.search.length === 1, 'Should contain exactly one video')
-
-  // Perform number full text searches on Video title, that absolutely should NOT return the video.
-  videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('unknown')
-
-  assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  videoFullTextSearchResult = await query.performFullTextSearchOnVideoTitle('MediaVideo')
-
-  assert(videoFullTextSearchResult.data.search.length === 0, 'Should be empty')
-
-  debug('Done')
-}

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

@@ -1,49 +0,0 @@
-import { Api } from '../../Api'
-import { FlowProps } from '../../Flow'
-import { UpdateChannelFixture } from '../../fixtures/contentDirectoryModule'
-import { ChannelEntity } from '@joystream/cd-schemas/types/entities/ChannelEntity'
-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
-  const channelUpdateInput: Partial<ChannelEntity> = {
-    description,
-  }
-
-  const uniquePropVal: Record<string, any> = { handle }
-
-  return new UpdateChannelFixture(api, channelUpdateInput, uniquePropVal)
-}
-
-export default async function updateChannel({ api, query }: FlowProps): 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]
-
-  const description = 'Updated description'
-  const createUpdateChannelDescriptionHappyCaseFixture = createUpdateChannelHandleFixture(api, handle, description)
-
-  await new FixtureRunner(createUpdateChannelDescriptionHappyCaseFixture).run()
-
-  // Temporary solution (wait 2 minutes)
-  await Utils.wait(120000)
-
-  const channelAfterUpdateResult = await query.getChannelbyHandle(handle)
-  const channelAfterUpdate = channelAfterUpdateResult.data.channels[0]
-
-  // description field should be updated to provided one
-  assert.equal(channelAfterUpdate.description, description, 'Should be equal')
-
-  assert.equal(channelAfterUpdate.handle, channel.handle, 'Should be equal')
-  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')
-}

+ 0 - 6
tests/network-tests/src/scenarios/content-directory.ts

@@ -1,12 +1,6 @@
 import leaderSetup from '../flows/workingGroup/leaderSetup'
-import createChannel from '../flows/contentDirectory/creatingChannel'
-import createVideo from '../flows/contentDirectory/creatingVideo'
-import updateChannel from '../flows/contentDirectory/updatingChannel'
 import { scenario } from '../Scenario'
 
 scenario(async ({ job }) => {
   job('setup content lead', leaderSetup.content)
-    .then(job('create-channel', createChannel))
-    .then(job('create-video', createVideo))
-    .then(job('update-channel', updateChannel))
 })

+ 36 - 2
yarn.lock

@@ -9118,6 +9118,7 @@ cli-cursor@^3.1.0:
   dependencies:
     restore-cursor "^3.1.0"
 
+<<<<<<< HEAD
 cli-highlight@^2.1.4:
   version "2.1.4"
   resolved "https://registry.yarnpkg.com/cli-highlight/-/cli-highlight-2.1.4.tgz#098cb642cf17f42adc1c1145e07f960ec4d7522b"
@@ -9129,6 +9130,19 @@ cli-highlight@^2.1.4:
     parse5 "^5.1.1"
     parse5-htmlparser2-tree-adapter "^5.1.1"
     yargs "^15.0.0"
+=======
+cli-highlight@^2.1.10:
+  version "2.1.10"
+  resolved "https://registry.yarnpkg.com/cli-highlight/-/cli-highlight-2.1.10.tgz#26a087da9209dce4fcb8cf5427dc97cd96ac173a"
+  integrity sha512-CcPFD3JwdQ2oSzy+AMG6j3LRTkNjM82kzcSKzoVw6cLanDCJNlsLjeqVTOTfOfucnWv5F0rmBemVf1m9JiIasw==
+  dependencies:
+    chalk "^4.0.0"
+    highlight.js "^10.0.0"
+    mz "^2.4.0"
+    parse5 "^5.1.1"
+    parse5-htmlparser2-tree-adapter "^6.0.0"
+    yargs "^16.0.0"
+>>>>>>> 61a854817e3fdf569f4e993d854a0ef2b89cad4c
 
 cli-progress@^3.4.0:
   version "3.8.2"
@@ -14795,7 +14809,7 @@ highlight.js@^10.0.0:
   resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.1.2.tgz#c20db951ba1c22c055010648dfffd7b2a968e00c"
   integrity sha512-Q39v/Mn5mfBlMff9r+zzA+gWxRsCRKwEMvYTiisLr/XUiFI/4puWt0Ojdko3R3JCNWGdOWaA5g/Yxqa23kC5AA==
 
-highlight.js@^9.3.0, highlight.js@^9.6.0:
+highlight.js@^9.3.0:
   version "9.18.3"
   resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634"
   integrity sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ==
@@ -22233,12 +22247,21 @@ parse-url@^5.0.0:
     parse-path "^4.0.0"
     protocols "^1.4.0"
 
+<<<<<<< HEAD
 parse5-htmlparser2-tree-adapter@^5.1.1:
   version "5.1.1"
   resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-5.1.1.tgz#e8c743d4e92194d5293ecde2b08be31e67461cbc"
   integrity sha512-CF+TKjXqoqyDwHqBhFQ+3l5t83xYi6fVT1tQNg+Ye0JRLnTxWvIroCjEp1A0k4lneHNBGnICUf0cfYVYGEazqw==
   dependencies:
     parse5 "^5.1.1"
+=======
+parse5-htmlparser2-tree-adapter@^6.0.0:
+  version "6.0.1"
+  resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6"
+  integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==
+  dependencies:
+    parse5 "^6.0.1"
+>>>>>>> 61a854817e3fdf569f4e993d854a0ef2b89cad4c
 
 parse5@4.0.0:
   version "4.0.0"
@@ -28116,16 +28139,27 @@ typeorm-typedi-extensions@^0.2.3:
   resolved "https://registry.yarnpkg.com/typeorm-typedi-extensions/-/typeorm-typedi-extensions-0.2.3.tgz#94fca2656206d771bf6d2242f5aab570511188e8"
   integrity sha512-T9i1NvRZNjPn9Jb8oT772ihfn6PwdqDVpzPCtKSqjkZGOgXrCkdyD3dDrzfMaoWJ1afU58bVx2CMb95FzT42Ow==
 
+<<<<<<< HEAD
 typeorm@^0.2.25:
   version "0.2.29"
   resolved "https://registry.yarnpkg.com/typeorm/-/typeorm-0.2.29.tgz#401289dc91900d72eccb26e31cdb7f0591a2272e"
   integrity sha512-ih1vrTe3gEAGKRcWlcsTRxTL7gNjacQE498wVGuJ3ZRujtMqPZlbAWuC7xDzWCRjQnkZYNwZQeG9UgKfxSHB5g==
+=======
+typeorm@^0.2.25, typeorm@^0.2.31:
+  version "0.2.31"
+  resolved "https://registry.yarnpkg.com/typeorm/-/typeorm-0.2.31.tgz#82b8a1b233224f81c738f53b0380386ccf360917"
+  integrity sha512-dVvCEVHH48DG0QPXAKfo0l6ecQrl3A8ucGP4Yw4myz4YEDMProebTQo8as83uyES+nrwCbu3qdkL4ncC2+qcMA==
+>>>>>>> 61a854817e3fdf569f4e993d854a0ef2b89cad4c
   dependencies:
     "@sqltools/formatter" "1.2.2"
     app-root-path "^3.0.0"
     buffer "^5.5.0"
     chalk "^4.1.0"
+<<<<<<< HEAD
     cli-highlight "^2.1.4"
+=======
+    cli-highlight "^2.1.10"
+>>>>>>> 61a854817e3fdf569f4e993d854a0ef2b89cad4c
     debug "^4.1.1"
     dotenv "^8.2.0"
     glob "^7.1.6"
@@ -30095,7 +30129,7 @@ yargs@^14.2.2:
     y18n "^4.0.0"
     yargs-parser "^15.0.0"
 
-yargs@^15.0.0, yargs@^15.0.1, yargs@^15.3.1, yargs@^15.4.1:
+yargs@^15.0.1, yargs@^15.3.1, yargs@^15.4.1:
   version "15.4.1"
   resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
   integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==