Browse Source

query node + tests - NFT mappings and test adaptation to Olympia

ondratra 3 years ago
parent
commit
d4e3b9ab0a
47 changed files with 861 additions and 436 deletions
  1. 4 20
      query-node/mappings/src/content/nft.ts
  2. 1 1
      query-node/mappings/src/content/utils.ts
  3. 1 1
      query-node/mappings/src/content/video.ts
  4. 1 2
      query-node/mappings/src/storage/index.ts
  5. 1 2
      query-node/run-tests.sh
  6. 2 0
      tests/integration-tests/package.json
  7. 166 7
      tests/integration-tests/src/Api.ts
  8. 44 0
      tests/integration-tests/src/QueryNodeApi.ts
  9. 3 1
      tests/integration-tests/src/Scenario.ts
  10. 1 1
      tests/integration-tests/src/cli/base.ts
  11. 1 2
      tests/integration-tests/src/cli/joystream.ts
  12. 0 0
      tests/integration-tests/src/cli/utils.ts
  13. 1 6
      tests/integration-tests/src/fixtures/content/activeVideoCounters.ts
  14. 0 0
      tests/integration-tests/src/fixtures/content/contentTemplates.ts
  15. 3 10
      tests/integration-tests/src/fixtures/content/createChannelsAndVideos.ts
  16. 7 10
      tests/integration-tests/src/fixtures/content/createContentStructure.ts
  17. 4 9
      tests/integration-tests/src/fixtures/content/createMembers.ts
  18. 0 0
      tests/integration-tests/src/fixtures/content/index.ts
  19. 0 3
      tests/integration-tests/src/fixtures/content/nft/auctionCancelations.ts
  20. 0 3
      tests/integration-tests/src/fixtures/content/nft/buyNow.ts
  21. 0 3
      tests/integration-tests/src/fixtures/content/nft/directOffer.ts
  22. 1 8
      tests/integration-tests/src/fixtures/content/nft/englishAuction.ts
  23. 0 0
      tests/integration-tests/src/fixtures/content/nft/index.ts
  24. 1 8
      tests/integration-tests/src/fixtures/content/nft/openAuction.ts
  25. 0 3
      tests/integration-tests/src/fixtures/content/nft/placeBidsInAuction.ts
  26. 0 0
      tests/integration-tests/src/fixtures/content/nft/utils.ts
  27. 1 5
      tests/integration-tests/src/flows/content/activeVideoCounters.ts
  28. 1 13
      tests/integration-tests/src/flows/content/nftAuctionAndOffers.ts
  29. 4 0
      tests/integration-tests/src/flows/storage/initStorage.ts
  30. 0 0
      tests/integration-tests/src/flows/utils.ts
  31. 95 0
      tests/integration-tests/src/graphql/generated/queries.ts
  32. 433 298
      tests/integration-tests/src/graphql/generated/schema.ts
  33. 51 0
      tests/integration-tests/src/graphql/queries/content.graphql
  34. 8 6
      tests/integration-tests/src/scenarios/content-directory.ts
  35. 1 1
      tests/integration-tests/src/scenarios/council.ts
  36. 1 1
      tests/integration-tests/src/scenarios/forum.ts
  37. 1 1
      tests/integration-tests/src/scenarios/forumPostDeletionsBug.ts
  38. 1 1
      tests/integration-tests/src/scenarios/full.ts
  39. 1 1
      tests/integration-tests/src/scenarios/memberships.ts
  40. 1 1
      tests/integration-tests/src/scenarios/olympia.ts
  41. 1 1
      tests/integration-tests/src/scenarios/proposals.ts
  42. 1 1
      tests/integration-tests/src/scenarios/proposalsDiscussion.ts
  43. 1 1
      tests/integration-tests/src/scenarios/setupNewChain.ts
  44. 1 1
      tests/integration-tests/src/scenarios/workingGroups.ts
  45. 1 1
      tests/integration-tests/src/sender.ts
  46. 3 3
      tests/network-tests/src/scenarios/combined.ts
  47. 12 0
      yarn.lock

+ 4 - 20
query-node/mappings/src/content/nft.ts

@@ -1,7 +1,7 @@
 // TODO: solve events' relations to videos and other entites that can be changed or deleted
 
 import { DatabaseManager, EventContext, StoreContext, SubstrateEvent } from '@joystream/hydra-common'
-import { genericEventFields, inconsistentState, unexpectedData, logger } from '../common'
+import { genericEventFields, inconsistentState, logger } from '../common'
 import {
   // entities
   Auction,
@@ -295,7 +295,7 @@ async function createBid(
 
   await store.save<Auction>(auction)
 
-  return { member, video }
+  return { auction, member, video }
 }
 
 export async function contentNft_AuctionStarted({ event, store }: EventContext & StoreContext): Promise<void> {
@@ -456,24 +456,8 @@ export async function contentNft_AuctionBidMade({ event, store }: EventContext &
 
   // specific event processing
 
-  // load member
-  const member = await getRequiredExistingEntity(
-    store,
-    Membership,
-    memberId.toString(),
-    'Non-existing member bid in auction'
-  )
-
-  // load video and auction
-  const { video, auction } = await getCurrentAuctionFromVideo(
-    store,
-    videoId.toString(),
-    'Non-existing video got bid',
-    'Non-existing auction got bid canceled'
-  )
-
   // create record for winning bid
-  await createBid(event, store, memberId.toNumber(), videoId.toNumber(), bidAmount.toString())
+  const { member, video } = await createBid(event, store, memberId.toNumber(), videoId.toNumber(), bidAmount.toString())
 
   // common event processing - second
 
@@ -797,7 +781,7 @@ export async function contentNft_NftBought({ event, store }: EventContext & Stor
   // specific event processing
 
   // load NFT
-  const { video, nft } = await getNftFromVideo(
+  const { video } = await getNftFromVideo(
     store,
     videoId.toString(),
     'Non-existing video was bought',

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

@@ -636,7 +636,7 @@ export async function updateChannelCategoryVideoActiveCounter(
   originalCategory: ChannelCategory | undefined,
   newCategory: ChannelCategory | undefined,
   videosCount: number
-) {
+): Promise<void> {
   // escape if no counter change needed
   if (!videosCount || originalCategory === newCategory) {
     return

+ 1 - 1
query-node/mappings/src/content/video.ts

@@ -12,7 +12,7 @@ import {
   videoRelationsForCountersBare,
   videoRelationsForCounters,
 } from './utils'
-import { Channel, ChannelCategory, Video, VideoCategory } from 'query-node/dist/model'
+import { Channel, Video, VideoCategory } from 'query-node/dist/model'
 import { VideoMetadata, VideoCategoryMetadata } from '@joystream/metadata-protobuf'
 import { integrateMeta } from '@joystream/metadata-protobuf/utils'
 import _ from 'lodash'

+ 1 - 2
query-node/mappings/src/storage/index.ts

@@ -25,7 +25,6 @@ import { getById, inconsistentState } from '../common'
 import {
   getVideoActiveStatus,
   updateVideoActiveCounters,
-  IVideoActiveStatus,
   videoRelationsForCounters,
   unsetAssetRelations,
 } from '../content/utils'
@@ -256,7 +255,7 @@ export async function storage_PendingDataObjectsAccepted({ event, store }: Event
 
   // accept storage data objects
   await Promise.all(
-    dataObjects.map(async (dataObject, index) => {
+    dataObjects.map(async (dataObject) => {
       dataObject.isAccepted = true
       await store.save<StorageDataObject>(dataObject)
     })

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

@@ -31,5 +31,4 @@ SCENARIO=$1
 # fallback if scenario if not specified
 SCENARIO=${SCENARIO:=full}
 
-#time yarn workspace integration-tests run-test-scenario ${SCENARIO}
-time yarn workspace network-tests run-test-scenario ${SCENARIO}
+time yarn workspace integration-tests run-test-scenario ${SCENARIO}

+ 2 - 0
tests/integration-tests/package.json

@@ -26,6 +26,8 @@
     "cross-fetch": "^3.0.6",
     "dotenv": "^8.2.0",
     "fs": "^0.0.1-security",
+    "bmp-js": "^0.1.0",
+    "@types/bmp-js": "^0.1.0",
     "uuid": "^7.0.3"
   },
   "devDependencies": {

+ 166 - 7
tests/integration-tests/src/Api.ts

@@ -1,5 +1,5 @@
 import { ApiPromise, WsProvider, Keyring } from '@polkadot/api'
-import { u32, BTreeMap } from '@polkadot/types'
+import { u32, BTreeMap, BTreeSet } from '@polkadot/types'
 import { IEvent, ISubmittableResult } from '@polkadot/types/types'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { AccountId, MemberId, PostId, ThreadId } from '@joystream/types/common'
@@ -48,6 +48,8 @@ import {
   ApplyOnOpeningParameters,
   Worker,
 } from '@joystream/types/working-group'
+import { DataObjectId, StorageBucketId } from '@joystream/types/storage'
+import { VideoId, VideoCategoryId, AuctionParams } from '@joystream/types/content'
 import { DeriveAllSections } from '@polkadot/api/util/decorate'
 import { ExactDerive } from '@polkadot/api-derive'
 import { ProposalId, ProposalParameters } from '@joystream/types/proposals'
@@ -148,18 +150,18 @@ export class ApiFactory {
     return keys
   }
 
-  private createKeyPair(suriPath: string, isCustom = false): KeyringPair {
+  private createKeyPair(suriPath: string, isCustom = false, isFinalPath = false): KeyringPair {
     if (isCustom) {
       this.customKeys.push(suriPath)
     }
-    const uri = `${this.miniSecret}//testing//${suriPath}`
+    const uri = isFinalPath ? suriPath : `${this.miniSecret}//testing//${suriPath}`
     const pair = this.keyring.addFromUri(uri)
     this.addressesToSuri.set(pair.address, uri)
     return pair
   }
 
-  public createCustomKeyPair(customPath: string): KeyringPair {
-    return this.createKeyPair(customPath, true)
+  public createCustomKeyPair(customPath: string, isFinalPath = false): KeyringPair {
+    return this.createKeyPair(customPath, true, isFinalPath)
   }
 
   public keyGenInfo(): KeyGenInfo {
@@ -255,6 +257,10 @@ export class Api {
     return this.signAndSend(this.api.tx.sudo.sudo(tx), sudo)
   }
 
+  public getKeypair(address: string | AccountId): KeyringPair {
+    return this.factory.getKeypair(address)
+  }
+
   public enableDebugTxLogs(): void {
     this.sender.setLogLevel(LogLevel.Debug)
   }
@@ -271,8 +277,8 @@ export class Api {
     return pairs
   }
 
-  public createCustomKeyPair(path: string): KeyringPair {
-    return this.factory.createCustomKeyPair(path)
+  public createCustomKeyPair(path: string, isFinalPath = false): KeyringPair {
+    return this.factory.createCustomKeyPair(path, isFinalPath)
   }
 
   public keyGenInfo(): KeyGenInfo {
@@ -806,4 +812,157 @@ export class Api {
   lockIdByGroup(group: WorkingGroupModuleName): LockIdentifier {
     return this.api.consts[group].stakingHandlerLockId
   }
+
+  async acceptPendingDataObjects(
+    accountFrom: string,
+    workerId: WorkerId,
+    storageBucketId: StorageBucketId,
+    channelId: string,
+    dataObjectIds: string[]
+  ): Promise<ISubmittableResult> {
+    const bagId = { Dynamic: { Channel: channelId } }
+    const encodedDataObjectIds = new BTreeSet<DataObjectId>(this.api.registry, 'DataObjectId', dataObjectIds)
+
+    return this.sender.signAndSend(
+      this.api.tx.storage.acceptPendingDataObjects(workerId, storageBucketId, bagId, encodedDataObjectIds),
+      accountFrom
+    )
+  }
+
+  async issueNft(
+    accountFrom: string,
+    memberId: number,
+    videoId: number,
+    metadata = '',
+    royaltyPercentage?: number,
+    toMemberId?: number | null
+  ): Promise<ISubmittableResult> {
+    const perbillOnePercent = 10 * 1000000
+
+    const royalty = this.api.createType(
+      'Option<Royalty>',
+      royaltyPercentage ? royaltyPercentage * perbillOnePercent : null
+    )
+    // TODO: find proper way to encode metadata (should they be raw string, hex string or some object?)
+    // const encodedMetadata = this.api.createType('Metadata', metadata)
+    // const encodedMetadata = this.api.createType('Metadata', metadata).toU8a() // invalid type passed to Metadata constructor
+    // const encodedMetadata = this.api.createType('Vec<u8>', metadata)
+    // const encodedMetadata = this.api.createType('Vec<u8>', 'someNonEmptyText') // decodeU8a: failed at 0x736f6d654e6f6e45… on magicNumber: u32:: MagicNumber mismatch: expected 0x6174656d, found 0x656d6f73
+    // const encodedMetadata = this.api.createType('Bytes', 'someNonEmptyText') // decodeU8a: failed at 0x736f6d654e6f6e45… on magicNumber: u32:: MagicNumber mismatch: expected 0x6174656d, found 0x656d6f73
+    // const encodedMetadata = this.api.createType('Metadata', {})
+    // const encodedMetadata = this.api.createType('Bytes', '0x') // error
+    // const encodedMetadata = this.api.createType('NFTMetadata', 'someNonEmptyText')
+    // const encodedMetadata = this.api.createType('NFTMetadata', 'someNonEmptyText').toU8a() // createType(NFTMetadata) // Vec length 604748352930462863646034177481338223 exceeds 65536
+    const encodedMetadata = this.api.createType('NFTMetadata', '').toU8a() // THIS IS OK!!! but only for empty string :-\
+    // try this later on // const encodedMetadata = this.api.createType('Vec<u8>', 'someNonEmptyText').toU8a()
+    // const encodedMetadata = this.api.createType('Vec<u8>', 'someNonEmptyText').toU8a() // throws error in QN when decoding this (but mb QN error)
+
+    const encodedToAccount = this.api.createType('Option<MemberId>', toMemberId || memberId)
+
+    const issuanceParameters = this.api.createType('NftIssuanceParameters', {
+      royalty,
+      nft_metadata: encodedMetadata,
+      non_channel_owner: encodedToAccount,
+      init_transactional_status: this.api.createType('InitTransactionalStatus', { Idle: null }),
+    })
+
+    return await this.sender.signAndSend(
+      this.api.tx.content.issueNft({ Member: memberId }, videoId, issuanceParameters),
+      accountFrom
+    )
+  }
+
+  createAuctionParameters(
+    auctionType: 'English' | 'Open',
+    startingPrice: BN,
+    minimalBidStep: BN,
+    buyNowPrice?: BN,
+    startInBlock?: BN,
+    whitelist: string[] = []
+  ): AuctionParams {
+    const encodedAuctionType =
+      auctionType === 'English'
+        ? {
+            English: {
+              extension_period: 5, // TODO - read min/max bounds from runtime and set min value here (?)
+              auction_duration: 5, // TODO - read min/max bounds from runtime and set min value here (?)
+            },
+          }
+        : {
+            Open: {
+              bid_lock_duration: 2, // TODO - read min/max bounds from runtime and set min value here (?)
+            },
+          }
+
+    return this.api.createType('AuctionParams', {
+      auction_type: this.api.createType('AuctionType', encodedAuctionType),
+      starting_price: this.api.createType('u128', startingPrice),
+      minimal_bid_step: this.api.createType('u128', minimalBidStep),
+      buy_now_price: this.api.createType('Option<BlockNumber>', buyNowPrice),
+      starts_at: this.api.createType('Option<BlockNumber>', startInBlock),
+      whitelist: this.api.createType('BTreeSet<StorageBucketId>', whitelist),
+    })
+  }
+
+  async startNftAuction(
+    accountFrom: string,
+    memberId: number,
+    videoId: number,
+    auctionParams: AuctionParams
+  ): Promise<ISubmittableResult> {
+    return await this.sender.signAndSend(
+      this.api.tx.content.startNftAuction({ Member: memberId }, videoId, auctionParams),
+      accountFrom
+    )
+  }
+
+  async bidInNftAuction(
+    accountFrom: string,
+    memberId: number,
+    videoId: number,
+    bidAmount: BN
+  ): Promise<ISubmittableResult> {
+    return await this.sender.signAndSend(this.api.tx.content.makeBid(memberId, videoId, bidAmount), accountFrom)
+  }
+
+  async claimWonEnglishAuction(accountFrom: string, memberId: number, videoId: number): Promise<ISubmittableResult> {
+    return await this.sender.signAndSend(this.api.tx.content.claimWonEnglishAuction(memberId, videoId), accountFrom)
+  }
+
+  async pickOpenAuctionWinner(accountFrom: string, memberId: number, videoId: number) {
+    return await this.sender.signAndSend(
+      this.api.tx.content.pickOpenAuctionWinner({ Member: memberId }, videoId),
+      accountFrom
+    )
+  }
+
+  async cancelOpenAuctionBid(accountFrom: string, participantId: number, videoId: number) {
+    return await this.sender.signAndSend(this.api.tx.content.cancelOpenAuctionBid(participantId, videoId), accountFrom)
+  }
+
+  async cancelNftAuction(accountFrom: string, ownerId: number, videoId: number) {
+    return await this.sender.signAndSend(
+      this.api.tx.content.cancelNftAuction({ Member: ownerId }, videoId),
+      accountFrom
+    )
+  }
+
+  async sellNft(accountFrom: string, videoId: number, ownerId: number, price: BN) {
+    return await this.sender.signAndSend(this.api.tx.content.sellNft(videoId, { Member: ownerId }, price), accountFrom)
+  }
+
+  async buyNft(accountFrom: string, videoId: number, participantId: number) {
+    return await this.sender.signAndSend(this.api.tx.content.buyNft(videoId, participantId), accountFrom)
+  }
+
+  async offerNft(accountFrom: string, videoId: number, ownerId: number, toMemberId: number, price: BN | null = null) {
+    return await this.sender.signAndSend(
+      this.api.tx.content.offerNft(videoId, { Member: ownerId }, toMemberId, price),
+      accountFrom
+    )
+  }
+
+  async acceptIncomingOffer(accountFrom: string, videoId: number) {
+    return await this.sender.signAndSend(this.api.tx.content.acceptIncomingOffer(videoId), accountFrom)
+  }
 }

+ 44 - 0
tests/integration-tests/src/QueryNodeApi.ts

@@ -295,6 +295,22 @@ import {
   GetProposalDiscussionThreadsByIdsQuery,
   GetProposalDiscussionThreadsByIdsQueryVariables,
   GetProposalDiscussionThreadsByIds,
+  OwnedNftFieldsFragment,
+  ChannelFieldsFragment,
+  GetChannelsQuery,
+  GetChannelsQueryVariables,
+  GetChannels,
+  ChannelCategoryFieldsFragment,
+  GetChannelCategoriesQuery,
+  GetChannelCategoriesQueryVariables,
+  GetChannelCategories,
+  VideoCategoryFieldsFragment,
+  GetVideoCategoriesQuery,
+  GetVideoCategoriesQueryVariables,
+  GetVideoCategories,
+  GetOwnedNftByVideoId,
+  GetOwnedNftByVideoIdQuery,
+  GetOwnedNftByVideoIdQueryVariables,
 } from './graphql/generated/queries'
 import { Maybe } from './graphql/generated/schema'
 import { OperationDefinitionNode } from 'graphql'
@@ -1071,4 +1087,32 @@ export class QueryNodeApi {
       GetProposalDiscussionThreadsByIdsQueryVariables
     >(GetProposalDiscussionThreadsByIds, { ids: ids.map((id) => id.toString()) }, 'proposalDiscussionThreads')
   }
+
+  public async getChannels(): Promise<ChannelFieldsFragment[]> {
+    return this.multipleEntitiesQuery<GetChannelsQuery, GetChannelsQueryVariables>(GetChannels, {}, 'channels')
+  }
+
+  public async getChannelCategories(): Promise<ChannelCategoryFieldsFragment[]> {
+    return this.multipleEntitiesQuery<GetChannelCategoriesQuery, GetChannelCategoriesQueryVariables>(
+      GetChannelCategories,
+      {},
+      'channelCategories'
+    )
+  }
+
+  public async getVideoCategories(): Promise<VideoCategoryFieldsFragment[]> {
+    return this.multipleEntitiesQuery<GetVideoCategoriesQuery, GetVideoCategoriesQueryVariables>(
+      GetVideoCategories,
+      {},
+      'videoCategories'
+    )
+  }
+
+  public async ownedNftByVideoId(videoId: string): Promise<Maybe<OwnedNftFieldsFragment>> {
+    return this.firstEntityQuery<GetOwnedNftByVideoIdQuery, GetOwnedNftByVideoIdQueryVariables>(
+      GetOwnedNftByVideoId,
+      { videoId },
+      'ownedNfts'
+    )
+  }
 }

+ 3 - 1
tests/integration-tests/src/Scenario.ts

@@ -42,7 +42,7 @@ function writeOutput(api: Api, miniSecret: string) {
   fs.writeFileSync(OUTPUT_FILE_PATH, JSON.stringify(output, undefined, 2))
 }
 
-export async function scenario(scene: (props: ScenarioProps) => Promise<void>): Promise<void> {
+export async function scenario(label: string, scene: (props: ScenarioProps) => Promise<void>): Promise<void> {
   // Load env variables
   config()
   const env = process.env
@@ -87,6 +87,8 @@ export async function scenario(scene: (props: ScenarioProps) => Promise<void>):
 
   const debug = extendDebug('scenario')
 
+  debug(label)
+
   const jobs = new JobManager({ apiFactory, query, env })
 
   await scene({ env, debug, job: jobs.createJob.bind(jobs) })

+ 1 - 1
tests/network-tests/src/cli/base.ts → tests/integration-tests/src/cli/base.ts

@@ -69,7 +69,7 @@ export abstract class CLI {
             ...execOutputs,
             exitCode: 0,
           }
-        } catch (error: unknown) {
+        } catch (error) {
           const errorTyped = error as ExecFileException & { stdout: string; stderr: string }
           // escape if command's success is required
           if (requireSuccess) {

+ 1 - 2
tests/network-tests/src/cli/joystream.ts → tests/integration-tests/src/cli/joystream.ts

@@ -2,8 +2,7 @@ import { KeyringPair } from '@polkadot/keyring/types'
 import path from 'path'
 import { CLI, CommandResult } from './base'
 import { TmpFileManager } from './utils'
-import { ChannelInputParameters } from '@joystream/cli/src/Types'
-import { MemberId } from '@joystream/types/members'
+import { MemberId } from '@joystream/types/common'
 
 const CLI_ROOT_PATH = path.resolve(__dirname, '../../../../cli')
 

+ 0 - 0
tests/network-tests/src/cli/utils.ts → tests/integration-tests/src/cli/utils.ts


+ 1 - 6
tests/network-tests/src/fixtures/content/activeVideoCounters.ts → tests/integration-tests/src/fixtures/content/activeVideoCounters.ts

@@ -1,14 +1,11 @@
 import { assert } from 'chai'
 import { ApolloQueryResult } from '@apollo/client'
 import { Api } from '../../Api'
-import { WorkingGroups } from '../../WorkingGroups'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../Fixture'
-import { BuyMembershipHappyCaseFixture } from '../membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../membership'
 import { KeyringPair } from '@polkadot/keyring/types'
 import { Bytes } from '@polkadot/types'
 import { QueryNodeApi } from '../../QueryNodeApi'
-import { PaidTermId, MemberId } from '@joystream/types/members'
-import { Debugger, extendDebug } from '../../Debugger'
 import BN from 'bn.js'
 import { Worker, WorkerId } from '@joystream/types/working-group'
 
@@ -30,7 +27,6 @@ import * as path from 'path'
   `channelIds[0]`, `channelCategoryIds[0]`, and `videoCategoryIds[0]`.
 */
 export class ActiveVideoCountersFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private channelIds: number[]
   private videosData: ICreatedVideoData[]
@@ -52,7 +48,6 @@ export class ActiveVideoCountersFixture extends BaseQueryNodeFixture {
     this.videosData = videosData
     this.channelCategoryIds = channelCategoryIds
     this.videoCategoryIds = videoCategoryIds
-    this.debug = extendDebug('fixture:ActiveVideoCountersFixture')
   }
 
   /*

+ 0 - 0
tests/network-tests/src/fixtures/content/contentTemplates.ts → tests/integration-tests/src/fixtures/content/contentTemplates.ts


+ 3 - 10
tests/network-tests/src/fixtures/content/createChannelsAndVideos.ts → tests/integration-tests/src/fixtures/content/createChannelsAndVideos.ts

@@ -1,25 +1,22 @@
 import { BaseQueryNodeFixture, FixtureRunner } from '../../Fixture'
-import { Debugger, extendDebug } from '../../Debugger'
 import { JoystreamCLI, ICreatedVideoData } from '../../cli/joystream'
-import { PaidTermId, MemberId } from '@joystream/types/members'
+import { MemberId } from '@joystream/types/common'
 import { QueryNodeApi } from '../../QueryNodeApi'
 import { Api } from '../../Api'
 import * as path from 'path'
 import { getMemberDefaults, getVideoDefaults, getChannelDefaults } from './contentTemplates'
 import { KeyringPair } from '@polkadot/keyring/types'
-import { BuyMembershipHappyCaseFixture } from '../membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../membership'
 import BN from 'bn.js'
 import { DataObjectId, StorageBucketId } from '@joystream/types/storage'
 import { Worker, WorkerId } from '@joystream/types/working-group'
 import { createType } from '@joystream/types'
-import { singleBucketConfig } from '../../flows/storagev2/initStorage'
+import { singleBucketConfig } from '../../flows/storage/initStorage'
 import { IMember } from './createMembers'
 
 const cliExamplesFolderPath = path.dirname(require.resolve('@joystream/cli/package.json')) + '/examples/content'
 
 export class CreateChannelsAndVideosFixture extends BaseQueryNodeFixture {
-  private paidTerms: PaidTermId
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private channelCount: number
   private videoCount: number
@@ -35,7 +32,6 @@ export class CreateChannelsAndVideosFixture extends BaseQueryNodeFixture {
     api: Api,
     query: QueryNodeApi,
     cli: JoystreamCLI,
-    paidTerms: PaidTermId,
     channelCount: number,
     videoCount: number,
     channelCategoryId: number,
@@ -43,14 +39,12 @@ export class CreateChannelsAndVideosFixture extends BaseQueryNodeFixture {
     author: IMember
   ) {
     super(api, query)
-    this.paidTerms = paidTerms
     this.cli = cli
     this.channelCount = channelCount
     this.videoCount = videoCount
     this.channelCategoryId = channelCategoryId
     this.videoCategoryId = videoCategoryId
     this.author = author
-    this.debug = extendDebug('fixture:CreateChannelsAndVideosFixture')
 
     this.createdItems = {
       channelIds: [],
@@ -89,7 +83,6 @@ export class CreateChannelsAndVideosFixture extends BaseQueryNodeFixture {
     this.debug('Accepting content to storage bag')
     const allAssetIds = this.createdItems.videosData.map((item) => item.assetContentIds).flat()
     await this.api.acceptPendingDataObjects(
-      // storageGroupWorker.keyringPair.address,
       storageGroupWorkerAccount,
       storageGroupWorkerId,
       storageBucketId,

+ 7 - 10
tests/network-tests/src/fixtures/content/createContentStructure.ts → tests/integration-tests/src/fixtures/content/createContentStructure.ts

@@ -1,16 +1,14 @@
 import { BaseQueryNodeFixture, FixtureRunner } from '../../Fixture'
 import { JoystreamCLI } from '../../cli/joystream'
 import { QueryNodeApi } from '../../QueryNodeApi'
-import { PaidTermId, MemberId } from '@joystream/types/members'
-import { Debugger, extendDebug } from '../../Debugger'
+import { MemberId } from '@joystream/types/common'
 import { Api } from '../../Api'
-import { WorkingGroups } from '../../WorkingGroups'
+import { WorkingGroupModuleName } from '../../types'
 import { Worker, WorkerId } from '@joystream/types/working-group'
 import { getVideoCategoryDefaults, getChannelCategoryDefaults } from './contentTemplates'
 import BN from 'bn.js'
 
 export class CreateContentStructureFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private channelCategoryCount: number
   private videoCategoryCount: number
@@ -30,7 +28,6 @@ export class CreateContentStructureFixture extends BaseQueryNodeFixture {
     this.cli = cli
     this.channelCategoryCount = channelCategoryCount
     this.videoCategoryCount = videoCategoryCount
-    this.debug = extendDebug('fixture:CreateContentStructureFixture')
 
     this.createdItems = {
       channelCategoryIds: [],
@@ -69,17 +66,17 @@ export class CreateContentStructureFixture extends BaseQueryNodeFixture {
     Retrieves information about accounts of group leads for content and storage working groups.
   */
   private async retrieveWorkingGroupLeaders(): Promise<{ contentLeader: Worker; storageLeader: Worker }> {
-    const retrieveGroupLeader = async (group: WorkingGroups) => {
-      const leader = await this.api.getGroupLead(group)
+    const retrieveGroupLeader = async (group: WorkingGroupModuleName) => {
+      const leader = await this.api.getLeader(group)
       if (!leader) {
         throw new Error(`Working group leader for "${group}" is missing!`)
       }
-      return leader
+      return leader[1]
     }
 
     return {
-      contentLeader: await retrieveGroupLeader(WorkingGroups.Content),
-      storageLeader: await retrieveGroupLeader(WorkingGroups.Storage),
+      contentLeader: await retrieveGroupLeader('contentWorkingGroup'),
+      storageLeader: await retrieveGroupLeader('storageWorkingGroup'),
     }
   }
 

+ 4 - 9
tests/network-tests/src/fixtures/content/createMembers.ts → tests/integration-tests/src/fixtures/content/createMembers.ts

@@ -1,11 +1,10 @@
-import { Debugger, extendDebug } from '../../Debugger'
 import { QueryNodeApi } from '../../QueryNodeApi'
-import { PaidTermId, MemberId } from '@joystream/types/members'
+import { MemberId } from '@joystream/types/common'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../Fixture'
 import { Api } from '../../Api'
 import { KeyringPair } from '@polkadot/keyring/types'
 import BN from 'bn.js'
-import { BuyMembershipHappyCaseFixture } from '../membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../membership'
 
 export interface IMember {
   keyringPair: KeyringPair
@@ -14,18 +13,14 @@ export interface IMember {
 }
 
 export class CreateMembersFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
-  private paidTerms: PaidTermId
   private memberCount: number
   private topupAmount: BN
   private createdItems: IMember[] = []
 
-  constructor(api: Api, query: QueryNodeApi, paidTerms: PaidTermId, memberCount: number, topupAmount: BN) {
+  constructor(api: Api, query: QueryNodeApi, memberCount: number, topupAmount: BN) {
     super(api, query)
-    this.paidTerms = paidTerms
     this.memberCount = memberCount
     this.topupAmount = topupAmount
-    this.debug = extendDebug('fixture:NftAuctionFixture')
   }
 
   public getCreatedItems() {
@@ -52,7 +47,7 @@ export class CreateMembersFixture extends BaseQueryNodeFixture {
   private async createMembers(numberOfMembers: number): Promise<IMember[]> {
     const keyringPairs = (await this.api.createKeyPairs(numberOfMembers)).map((kp) => kp.key)
     const accounts = keyringPairs.map((item) => item.address)
-    const buyMembershipsFixture = new BuyMembershipHappyCaseFixture(this.api, accounts, this.paidTerms)
+    const buyMembershipsFixture = new BuyMembershipHappyCaseFixture(this.api, this.query, accounts)
 
     await new FixtureRunner(buyMembershipsFixture).run()
 

+ 0 - 0
tests/network-tests/src/fixtures/content/index.ts → tests/integration-tests/src/fixtures/content/index.ts


+ 0 - 3
tests/network-tests/src/fixtures/content/nft/auctionCancelations.ts → tests/integration-tests/src/fixtures/content/nft/auctionCancelations.ts

@@ -1,7 +1,6 @@
 import { Api } from '../../../Api'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../../Fixture'
 import { JoystreamCLI } from '../../../cli/joystream'
-import { Debugger, extendDebug } from '../../../Debugger'
 import { QueryNodeApi } from '../../../QueryNodeApi'
 import { IMember } from '../createMembers'
 import { PlaceBidsInAuctionFixture } from './placeBidsInAuction'
@@ -10,7 +9,6 @@ import { assertNftOwner } from './utils'
 import BN from 'bn.js'
 
 export class AuctionCancelationsFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private videoId: number
   private author: IMember
@@ -29,7 +27,6 @@ export class AuctionCancelationsFixture extends BaseQueryNodeFixture {
     this.videoId = videoId
     this.author = author
     this.participant = participant
-    this.debug = extendDebug('fixture:AuctionCancelationsFixture')
   }
 
   /*

+ 0 - 3
tests/network-tests/src/fixtures/content/nft/buyNow.ts → tests/integration-tests/src/fixtures/content/nft/buyNow.ts

@@ -1,7 +1,6 @@
 import { Api } from '../../../Api'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../../Fixture'
 import { JoystreamCLI } from '../../../cli/joystream'
-import { Debugger, extendDebug } from '../../../Debugger'
 import { QueryNodeApi } from '../../../QueryNodeApi'
 import { IMember } from '../createMembers'
 import { PlaceBidsInAuctionFixture } from './placeBidsInAuction'
@@ -9,7 +8,6 @@ import BN from 'bn.js'
 import { assertNftOwner } from './utils'
 
 export class NftBuyNowFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private videoId: number
   private author: IMember
@@ -28,7 +26,6 @@ export class NftBuyNowFixture extends BaseQueryNodeFixture {
     this.videoId = videoId
     this.author = author
     this.participant = participant
-    this.debug = extendDebug('fixture:NftBuyNowFixture')
   }
 
   /*

+ 0 - 3
tests/network-tests/src/fixtures/content/nft/directOffer.ts → tests/integration-tests/src/fixtures/content/nft/directOffer.ts

@@ -1,13 +1,11 @@
 import { Api } from '../../../Api'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../../Fixture'
 import { JoystreamCLI } from '../../../cli/joystream'
-import { Debugger, extendDebug } from '../../../Debugger'
 import { QueryNodeApi } from '../../../QueryNodeApi'
 import { IMember } from '../createMembers'
 import { assertNftOwner } from './utils'
 
 export class NftDirectOfferFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private videoId: number
   private author: IMember
@@ -26,7 +24,6 @@ export class NftDirectOfferFixture extends BaseQueryNodeFixture {
     this.videoId = videoId
     this.author = author
     this.participant = participant
-    this.debug = extendDebug('fixture:NftDirectOfferFixture')
   }
 
   /*

+ 1 - 8
tests/network-tests/src/fixtures/content/nft/englishAuction.ts → tests/integration-tests/src/fixtures/content/nft/englishAuction.ts

@@ -2,12 +2,10 @@ import { assert } from 'chai'
 import { Api } from '../../../Api'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../../Fixture'
 import { JoystreamCLI } from '../../../cli/joystream'
-import { Debugger, extendDebug } from '../../../Debugger'
 import { QueryNodeApi } from '../../../QueryNodeApi'
 import { IMember } from '../createMembers'
-import { BuyMembershipHappyCaseFixture } from '../../membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../../membership'
 import { PlaceBidsInAuctionFixture } from './placeBidsInAuction'
-import { PaidTermId } from '@joystream/types/members'
 import { Utils } from '../../../utils'
 import { assertNftOwner } from './utils'
 import BN from 'bn.js'
@@ -16,18 +14,15 @@ import BN from 'bn.js'
 const sufficientTopupAmount = new BN(1000000) // some very big number to cover fees of all transactions
 
 export class NftEnglishAuctionFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private videoId: number
   private author: IMember
-  private paidTerms: PaidTermId
   private participants: IMember[]
 
   constructor(
     api: Api,
     query: QueryNodeApi,
     cli: JoystreamCLI,
-    paidTerms: PaidTermId,
     videoId: number,
     author: IMember,
     participants: IMember[]
@@ -36,9 +31,7 @@ export class NftEnglishAuctionFixture extends BaseQueryNodeFixture {
     this.cli = cli
     this.videoId = videoId
     this.author = author
-    this.paidTerms = paidTerms
     this.participants = participants
-    this.debug = extendDebug('fixture:NftEnglishAuctionFixture')
   }
 
   /*

+ 0 - 0
tests/network-tests/src/fixtures/content/nft/index.ts → tests/integration-tests/src/fixtures/content/nft/index.ts


+ 1 - 8
tests/network-tests/src/fixtures/content/nft/openAuction.ts → tests/integration-tests/src/fixtures/content/nft/openAuction.ts

@@ -1,12 +1,10 @@
 import { Api } from '../../../Api'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../../Fixture'
 import { JoystreamCLI } from '../../../cli/joystream'
-import { Debugger, extendDebug } from '../../../Debugger'
 import { QueryNodeApi } from '../../../QueryNodeApi'
 import { IMember } from '../createMembers'
-import { BuyMembershipHappyCaseFixture } from '../../membershipModule'
+import { BuyMembershipHappyCaseFixture } from '../../membership'
 import { PlaceBidsInAuctionFixture } from './placeBidsInAuction'
-import { PaidTermId } from '@joystream/types/members'
 import { assertNftOwner } from './utils'
 import BN from 'bn.js'
 
@@ -14,18 +12,15 @@ import BN from 'bn.js'
 const sufficientTopupAmount = new BN(1000000) // some very big number to cover fees of all transactions
 
 export class NftOpenAuctionFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private cli: JoystreamCLI
   private videoId: number
   private author: IMember
-  private paidTerms: PaidTermId
   private participants: IMember[]
 
   constructor(
     api: Api,
     query: QueryNodeApi,
     cli: JoystreamCLI,
-    paidTerms: PaidTermId,
     videoId: number,
     author: IMember,
     participants: IMember[]
@@ -34,9 +29,7 @@ export class NftOpenAuctionFixture extends BaseQueryNodeFixture {
     this.cli = cli
     this.videoId = videoId
     this.author = author
-    this.paidTerms = paidTerms
     this.participants = participants
-    this.debug = extendDebug('fixture:NftOpenAuctionFixture')
   }
 
   /*

+ 0 - 3
tests/network-tests/src/fixtures/content/nft/placeBidsInAuction.ts → tests/integration-tests/src/fixtures/content/nft/placeBidsInAuction.ts

@@ -1,12 +1,10 @@
 import { Api } from '../../../Api'
 import { BaseQueryNodeFixture, FixtureRunner } from '../../../Fixture'
-import { Debugger, extendDebug } from '../../../Debugger'
 import { QueryNodeApi } from '../../../QueryNodeApi'
 import { IMember } from '../createMembers'
 import BN from 'bn.js'
 
 export class PlaceBidsInAuctionFixture extends BaseQueryNodeFixture {
-  private debug: Debugger.Debugger
   private participants: IMember[]
   private startingPrice: BN
   private minimalBidStep: BN
@@ -25,7 +23,6 @@ export class PlaceBidsInAuctionFixture extends BaseQueryNodeFixture {
     this.startingPrice = startingPrice
     this.minimalBidStep = minimalBidStep
     this.videoId = videoId
-    this.debug = extendDebug('fixture:PlaceBidsInAuctionFixture')
   }
 
   /*

+ 0 - 0
tests/network-tests/src/fixtures/content/nft/utils.ts → tests/integration-tests/src/fixtures/content/nft/utils.ts


+ 1 - 5
tests/network-tests/src/flows/content/activeVideoCounters.ts → tests/integration-tests/src/flows/content/activeVideoCounters.ts

@@ -7,7 +7,6 @@ import {
   CreateContentStructureFixture,
   CreateMembersFixture,
 } from '../../fixtures/content'
-import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 import { createJoystreamCli } from '../utils'
 
@@ -26,8 +25,6 @@ export default async function activeVideoCounters({ api, query, env }: FlowProps
   const channelCategoryCount = 2
   const sufficientTopupAmount = new BN(1000000) // some very big number to cover fees of all transactions
 
-  const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
-
   // flow itself
 
   // create channel categories and video categories
@@ -43,7 +40,7 @@ export default async function activeVideoCounters({ api, query, env }: FlowProps
   const { channelCategoryIds, videoCategoryIds } = createContentStructureFixture.getCreatedItems()
 
   // create author of channels and videos
-  const createMembersFixture = new CreateMembersFixture(api, query, paidTerms, 1, sufficientTopupAmount)
+  const createMembersFixture = new CreateMembersFixture(api, query, 1, sufficientTopupAmount)
   await new FixtureRunner(createMembersFixture).run()
   const author = createMembersFixture.getCreatedItems()[0]
 
@@ -52,7 +49,6 @@ export default async function activeVideoCounters({ api, query, env }: FlowProps
     api,
     query,
     joystreamCli,
-    paidTerms,
     channelCount,
     videoCount,
     channelCategoryIds[0],

+ 1 - 13
tests/network-tests/src/flows/content/nftAuctionAndOffers.ts → tests/integration-tests/src/flows/content/nftAuctionAndOffers.ts

@@ -13,7 +13,6 @@ import {
   AuctionCancelationsFixture,
   IMember,
 } from '../../fixtures/content'
-import { PaidTermId } from '@joystream/types/members'
 import BN from 'bn.js'
 import { createJoystreamCli } from '../utils'
 
@@ -33,8 +32,6 @@ export default async function nftAuctionAndOffers({ api, query, env }: FlowProps
   const auctionParticipantsCount = 3
   const sufficientTopupAmount = new BN(1000000) // some very big number to cover fees of all transactions
 
-  const paidTerms: PaidTermId = api.createPaidTermId(new BN(+env.MEMBERSHIP_PAID_TERMS!))
-
   // prepare content
 
   const createContentStructureFixture = new CreateContentStructureFixture(
@@ -49,13 +46,7 @@ export default async function nftAuctionAndOffers({ api, query, env }: FlowProps
   const { channelCategoryIds, videoCategoryIds } = createContentStructureFixture.getCreatedItems()
 
   // create author of channels and videos as well as auction participants
-  const createMembersFixture = new CreateMembersFixture(
-    api,
-    query,
-    paidTerms,
-    auctionParticipantsCount + 1,
-    sufficientTopupAmount
-  )
+  const createMembersFixture = new CreateMembersFixture(api, query, auctionParticipantsCount + 1, sufficientTopupAmount)
   await new FixtureRunner(createMembersFixture).run()
   const [author, ...auctionParticipants] = createMembersFixture.getCreatedItems()
 
@@ -63,7 +54,6 @@ export default async function nftAuctionAndOffers({ api, query, env }: FlowProps
     api,
     query,
     joystreamCli,
-    paidTerms,
     channelCount,
     videoCount,
     channelCategoryIds[0],
@@ -85,7 +75,6 @@ export default async function nftAuctionAndOffers({ api, query, env }: FlowProps
     api,
     query,
     joystreamCli,
-    paidTerms,
     nextVideo().videoId,
     author as IMember,
     auctionParticipants
@@ -97,7 +86,6 @@ export default async function nftAuctionAndOffers({ api, query, env }: FlowProps
     api,
     query,
     joystreamCli,
-    paidTerms,
     nextVideo().videoId,
     author,
     auctionParticipants

+ 4 - 0
tests/integration-tests/src/flows/storage/initStorage.ts

@@ -14,6 +14,7 @@ type StorageBucketConfig = {
   objectsLimit: number
   operatorId: number
   transactorKey: string
+  transactorUri: string
   transactorBalance: BN
 }
 
@@ -48,6 +49,7 @@ export const singleBucketConfig: InitStorageConfig = {
       storageLimit: new BN(1_000_000_000_000),
       objectsLimit: 1000000000,
       transactorKey: process.env.COLOSSUS_1_TRANSACTOR_KEY || '5DkE5YD8m5Yzno6EH2RTBnH268TDnnibZMEMjxwYemU4XevU', // //Colossus1
+      transactorUri: process.env.COLOSSUS_1_TRANSACTOR_URI || '//Colossus1',
       transactorBalance: new BN(100_000),
     },
   ],
@@ -66,6 +68,7 @@ export const doubleBucketConfig: InitStorageConfig = {
       storageLimit: new BN(1_000_000_000_000),
       objectsLimit: 1000000000,
       transactorKey: process.env.COLOSSUS_1_TRANSACTOR_KEY || '5DkE5YD8m5Yzno6EH2RTBnH268TDnnibZMEMjxwYemU4XevU', // //Colossus1
+      transactorUri: process.env.COLOSSUS_1_TRANSACTOR_URI || '//Colossus1',
       transactorBalance: new BN(100_000),
     },
     {
@@ -75,6 +78,7 @@ export const doubleBucketConfig: InitStorageConfig = {
       storageLimit: new BN(1_000_000_000_000),
       objectsLimit: 1000000000,
       transactorKey: process.env.COLOSSUS_2_TRANSACTOR_KEY || '5FbzYmQ3HogiEEDSXPYJe58yCcmSh3vsZLodTdBB6YuLDAj7', // //Colossus2
+      transactorUri: process.env.COLOSSUS_2_TRANSACTOR_URI || '//Colossus2',
       transactorBalance: new BN(100_000),
     },
   ],

+ 0 - 0
tests/network-tests/src/flows/utils.ts → tests/integration-tests/src/flows/utils.ts


+ 95 - 0
tests/integration-tests/src/graphql/generated/queries.ts

@@ -1,6 +1,38 @@
 import * as Types from './schema'
 
 import gql from 'graphql-tag'
+export type ChannelFieldsFragment = { id: string; activeVideosCounter: number }
+
+export type ChannelCategoryFieldsFragment = { id: string; activeVideosCounter: number }
+
+export type VideoCategoryFieldsFragment = { id: string; activeVideosCounter: number }
+
+export type OwnedNftFieldsFragment = {
+  id: string
+  metadata: string
+  creatorRoyalty?: Types.Maybe<number>
+  video: { id: string }
+  ownerMember?: Types.Maybe<{ id: string }>
+}
+
+export type GetChannelsQueryVariables = Types.Exact<{ [key: string]: never }>
+
+export type GetChannelsQuery = { channels: Array<ChannelFieldsFragment> }
+
+export type GetChannelCategoriesQueryVariables = Types.Exact<{ [key: string]: never }>
+
+export type GetChannelCategoriesQuery = { channelCategories: Array<ChannelCategoryFieldsFragment> }
+
+export type GetVideoCategoriesQueryVariables = Types.Exact<{ [key: string]: never }>
+
+export type GetVideoCategoriesQuery = { videoCategories: Array<VideoCategoryFieldsFragment> }
+
+export type GetOwnedNftByVideoIdQueryVariables = Types.Exact<{
+  videoId: Types.Scalars['ID']
+}>
+
+export type GetOwnedNftByVideoIdQuery = { ownedNfts: Array<OwnedNftFieldsFragment> }
+
 export type CouncilMemberFieldsFragment = { id: string; member: { id: string } }
 
 export type ElectedCouncilFieldsFragment = { councilMembers: Array<CouncilMemberFieldsFragment> }
@@ -1900,6 +1932,37 @@ export type GetBudgetSpendingEventsByEventIdsQueryVariables = Types.Exact<{
 
 export type GetBudgetSpendingEventsByEventIdsQuery = { budgetSpendingEvents: Array<BudgetSpendingEventFieldsFragment> }
 
+export const ChannelFields = gql`
+  fragment ChannelFields on Channel {
+    id
+    activeVideosCounter
+  }
+`
+export const ChannelCategoryFields = gql`
+  fragment ChannelCategoryFields on ChannelCategory {
+    id
+    activeVideosCounter
+  }
+`
+export const VideoCategoryFields = gql`
+  fragment VideoCategoryFields on VideoCategory {
+    id
+    activeVideosCounter
+  }
+`
+export const OwnedNftFields = gql`
+  fragment OwnedNftFields on OwnedNft {
+    id
+    video {
+      id
+    }
+    ownerMember {
+      id
+    }
+    metadata
+    creatorRoyalty
+  }
+`
 export const CouncilMemberFields = gql`
   fragment CouncilMemberFields on CouncilMember {
     id
@@ -3657,6 +3720,38 @@ export const BudgetSpendingEventFields = gql`
     rationale
   }
 `
+export const GetChannels = gql`
+  query getChannels {
+    channels {
+      ...ChannelFields
+    }
+  }
+  ${ChannelFields}
+`
+export const GetChannelCategories = gql`
+  query getChannelCategories {
+    channelCategories {
+      ...ChannelCategoryFields
+    }
+  }
+  ${ChannelCategoryFields}
+`
+export const GetVideoCategories = gql`
+  query getVideoCategories {
+    videoCategories {
+      ...VideoCategoryFields
+    }
+  }
+  ${VideoCategoryFields}
+`
+export const GetOwnedNftByVideoId = gql`
+  query getOwnedNftByVideoId($videoId: ID!) {
+    ownedNfts(where: { video: { id_eq: $videoId } }) {
+      ...OwnedNftFields
+    }
+  }
+  ${OwnedNftFields}
+`
 export const GetCurrentCouncilMembers = gql`
   query getCurrentCouncilMembers {
     electedCouncils(where: { endedAtBlock_eq: null }) {

File diff suppressed because it is too large
+ 433 - 298
tests/integration-tests/src/graphql/generated/schema.ts


+ 51 - 0
tests/integration-tests/src/graphql/queries/content.graphql

@@ -0,0 +1,51 @@
+fragment ChannelFields on Channel {
+  id
+  activeVideosCounter
+}
+
+fragment ChannelCategoryFields on ChannelCategory {
+  id
+  activeVideosCounter
+}
+
+fragment VideoCategoryFields on VideoCategory {
+  id
+  activeVideosCounter
+}
+
+fragment OwnedNftFields on OwnedNft {
+  id
+  video {
+    id
+  }
+  ownerMember {
+    id
+  }
+  metadata
+  # transactionalStatus TODO
+  creatorRoyalty
+}
+
+query getChannels {
+  channels {
+    ...ChannelFields
+  }
+}
+
+query getChannelCategories {
+  channelCategories {
+    ...ChannelCategoryFields
+  }
+}
+
+query getVideoCategories {
+  videoCategories {
+    ...VideoCategoryFields
+  }
+}
+
+query getOwnedNftByVideoId($videoId: ID!) {
+  ownedNfts(where: { video: { id_eq: $videoId } }) {
+    ...OwnedNftFields
+  }
+}

+ 8 - 6
tests/network-tests/src/scenarios/content-directory.ts → tests/integration-tests/src/scenarios/content-directory.ts

@@ -1,16 +1,18 @@
-import leaderSetup from '../flows/workingGroup/leaderSetup'
+import leaderSetup from '../flows/working-groups/leadOpening'
 import activeVideoCounters from '../flows/content/activeVideoCounters'
 import nftAuctionAndOffers from '../flows/content/nftAuctionAndOffers'
-import initStorageBucket from '../flows/clis/initStorageBucket'
-import initStorage, { singleBucketConfig as storageConfig } from '../flows/storagev2/initStorage'
-import { WorkingGroups } from '../WorkingGroups'
+import initStorage, { singleBucketConfig as storageConfig } from '../flows/storage/initStorage'
+import { workingGroups } from '../consts'
 import { scenario } from '../Scenario'
 
 scenario('Content directory', async ({ job }) => {
+  const leadSetupJob = job('Set WorkingGroup Leads', leaderSetup)
+  /*
   const leadSetupJob = job('setup working group leads', [
-    leaderSetup(WorkingGroups.Content, true),
-    leaderSetup(WorkingGroups.Storage, true),
+    leaderSetup(workingGroups.Content, true),
+    leaderSetup(workingGroups.Storage, true),
   ])
+  */
 
   const initStorageJob = job('initialize storage system', initStorage(storageConfig)).requires(leadSetupJob)
 

+ 1 - 1
tests/integration-tests/src/scenarios/council.ts

@@ -2,7 +2,7 @@ import electCouncil from '../flows/council/elect'
 import failToElectCouncil from '../flows/council/failToElect'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Council', async ({ job }) => {
   const councilJob = job('electing council', electCouncil)
   const secondCouncilJob = job('electing second council', electCouncil).requires(councilJob)
 

+ 1 - 1
tests/integration-tests/src/scenarios/forum.ts

@@ -7,7 +7,7 @@ import leadOpening from '../flows/working-groups/leadOpening'
 import threadTags from '../flows/forum/threadTags'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Forum', async ({ job }) => {
   const sudoHireLead = job('hiring working group leads', leadOpening)
   job('forum categories', categories).requires(sudoHireLead)
   job('forum threads', threads).requires(sudoHireLead)

+ 1 - 1
tests/integration-tests/src/scenarios/forumPostDeletionsBug.ts

@@ -2,7 +2,7 @@ import leadOpening from '../flows/working-groups/leadOpening'
 import multiplePostDeletionsBug from '../flows/forum/multiplePostDeletionsBug'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Forum post deletions bug', async ({ job }) => {
   const sudoHireLead = job('hiring working group leads', leadOpening)
   job('forum post deletions bug', multiplePostDeletionsBug).requires(sudoHireLead)
 })

+ 1 - 1
tests/integration-tests/src/scenarios/full.ts

@@ -28,7 +28,7 @@ import expireProposal from '../flows/proposals/expireProposal'
 import proposalsDiscussion from '../flows/proposalsDiscussion'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job, env }) => {
+scenario('Full', async ({ job, env }) => {
   // Runtime upgrade should always be first job
   // (except councilJob, which is required for voting and should probably depend on the "source" runtime)
   const councilJob = job('electing council', electCouncil)

+ 1 - 1
tests/integration-tests/src/scenarios/memberships.ts

@@ -7,7 +7,7 @@ import managingStakingAccounts from '../flows/membership/managingStakingAccounts
 import membershipSystem from '../flows/membership/membershipSystem'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Memberships', async ({ job }) => {
   const membershipSystemJob = job('membership system', membershipSystem)
   // All other job should be executed after, otherwise changing membershipPrice etc. may break them
   job('creating members', creatingMemberships).after(membershipSystemJob)

+ 1 - 1
tests/integration-tests/src/scenarios/olympia.ts

@@ -6,7 +6,7 @@ import transferringInvites from '../flows/membership/transferringInvites'
 import managingStakingAccounts from '../flows/membership/managingStakingAccounts'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Olympia', async ({ job }) => {
   job('creating members', creatingMemberships)
   job('updating member profile', updatingMemberProfile)
   job('updating member accounts', updatingMemberAccounts)

+ 1 - 1
tests/integration-tests/src/scenarios/proposals.ts

@@ -8,7 +8,7 @@ import expireProposal from '../flows/proposals/expireProposal'
 import proposalsDiscussion from '../flows/proposalsDiscussion'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job, env }) => {
+scenario('Proposals', async ({ job, env }) => {
   const councilJob = job('electing council', electCouncil)
   const runtimeUpgradeProposalJob = env.RUNTIME_UPGRADE_TARGET_WASM_PATH
     ? job('runtime upgrade proposal', runtimeUpgradeProposal).requires(councilJob)

+ 1 - 1
tests/integration-tests/src/scenarios/proposalsDiscussion.ts

@@ -2,7 +2,7 @@ import electCouncil from '../flows/council/elect'
 import proposalsDiscussion from '../flows/proposalsDiscussion'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job, env }) => {
+scenario('Proposals discussion', async ({ job, env }) => {
   const councilJob = job('electing council', electCouncil)
   job('proposal discussion', [proposalsDiscussion]).requires(councilJob)
 })

+ 1 - 1
tests/integration-tests/src/scenarios/setupNewChain.ts

@@ -5,7 +5,7 @@ import initStorage, { singleBucketConfig as defaultStorageConfig } from '../flow
 import initDistribution, { singleBucketConfig as defaultDistributionConfig } from '../flows/storage/initDistribution'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Setup new chain', async ({ job }) => {
   job('Elect Council', electCouncil)
   const leads = job('Set WorkingGroup Leads', leaderSetup)
   const updateWorkerAccounts = job('Update worker accounts', updateAccountsFlow).after(leads)

+ 1 - 1
tests/integration-tests/src/scenarios/workingGroups.ts

@@ -6,7 +6,7 @@ import workerActions from '../flows/working-groups/workerActions'
 import { scenario } from '../Scenario'
 import groupBudget from '../flows/working-groups/groupBudget'
 
-scenario(async ({ job }) => {
+scenario('Working groups', async ({ job }) => {
   const sudoHireLead = job('sudo lead opening', leadOpening)
   job('openings and applications', openingsAndApplications).requires(sudoHireLead)
   job('upcoming openings', upcomingOpenings).requires(sudoHireLead)

+ 1 - 1
tests/integration-tests/src/sender.ts

@@ -19,7 +19,7 @@ const nonceCacheByAccount = new Map<string, number>()
 
 export class Sender {
   private readonly api: ApiPromise
-  private static readonly asyncLock: AsyncLock = new AsyncLock()
+  static readonly asyncLock: AsyncLock = new AsyncLock()
   private readonly keyring: Keyring
   private readonly debug: Debugger.Debugger
   private logs: LogLevel = LogLevel.None

+ 3 - 3
tests/network-tests/src/scenarios/combined.ts

@@ -41,18 +41,18 @@ scenario('Combined', async ({ job }) => {
     manageWorkerAsWorker.distribution,
   ]).requires(leadSetupJob)
 
-<<<<<<< HEAD
   // Run CLI tests after workerPayoutsJob as they may lock Sender for too long and cause FillOpeningInvalidNextPaymentBlock
   const createChannelJob = job('create channel via CLI', createChannel).after(workerPayoutsJob)
   job('init storage and distribution buckets via CLI', [initDistributionBucket, initStorageBucket]).after(
     createChannelJob
   )
-=======
+
+  /* TODO: delete this alternative from pre-olympia-merge NFT branch if not useful
   const initBucketsJob = job('init storage and distribution buckets via CLI', [
     initDistributionBucket,
     initStorageBucket,
   ]).requires(leadSetupJob)
 
   const createChannelJob = job('create channel via CLI', createChannel).requires(initBucketsJob)
->>>>>>> vnft_schema_mappings_second
+  */
 })

+ 12 - 0
yarn.lock

@@ -2923,6 +2923,13 @@
   resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.36.tgz#00d9301d4dc35c2f6465a8aec634bb533674c652"
   integrity sha512-HBNx4lhkxN7bx6P0++W8E289foSu8kO8GCk2unhuVggO+cE7rh9DhZUyPhUxNRG9m+5B5BTKxZQ5ZP92x/mx9Q==
 
+"@types/bmp-js@^0.1.0":
+  version "0.1.0"
+  resolved "https://registry.yarnpkg.com/@types/bmp-js/-/bmp-js-0.1.0.tgz#301afe2bb3ac7ef0f18465966e4166f0491b3332"
+  integrity sha512-uMU85ROcmlY1f4mVPTlNodRXa6Z5f0AIxvv5b0pvjty3KNg7ljf5lNSspHgaF6iFDCiGpLQmJna+VwEpUC9TyA==
+  dependencies:
+    "@types/node" "*"
+
 "@types/bn.js@^4.11.5", "@types/bn.js@^4.11.6":
   version "4.11.6"
   resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c"
@@ -5071,6 +5078,11 @@ bluebird@~3.4.1:
   resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3"
   integrity sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=
 
+bmp-js@^0.1.0:
+  version "0.1.0"
+  resolved "https://registry.yarnpkg.com/bmp-js/-/bmp-js-0.1.0.tgz#e05a63f796a6c1ff25f4771ec7adadc148c07233"
+  integrity sha1-4Fpj95amwf8l9Hcex62twUjAcjM=
+
 bn.js@4.12.0, bn.js@^4.11.8, bn.js@^4.11.9, bn.js@^4.12.0, bn.js@^5.1.2, bn.js@^5.1.3, bn.js@^5.2.0:
   version "4.12.0"
   resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88"

Some files were not shown because too many files changed in this diff