diff --git a/start-orion.sh b/start-orion.sh index 9c9325876d..fb07cf4c56 100755 --- a/start-orion.sh +++ b/start-orion.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e +SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")" +cd $SCRIPT_PATH + docker-compose up -d orion-db docker-compose up -d squid-archive docker-compose up -d squid-archive-gateway diff --git a/tests/network-tests/run-tests.sh b/tests/network-tests/run-tests.sh index 48ffc85f91..eccf8f6e38 100755 --- a/tests/network-tests/run-tests.sh +++ b/tests/network-tests/run-tests.sh @@ -29,6 +29,12 @@ then ../../query-node/start.sh fi +# Start orion +if [ "${NO_ORION}" != true ] +then + ../../start-orion.sh +fi + # Execute tests if [ "${NO_STORAGE}" != true ] diff --git a/tests/network-tests/src/Fixture.ts b/tests/network-tests/src/Fixture.ts index 5bd7de4819..41599b80f7 100644 --- a/tests/network-tests/src/Fixture.ts +++ b/tests/network-tests/src/Fixture.ts @@ -1,7 +1,6 @@ import { Api } from './Api' import { assert } from 'chai' import { ISubmittableResult } from '@polkadot/types/types/' -import { DispatchResult } from '@polkadot/types/interfaces/system' import { QueryNodeApi } from './QueryNodeApi' import { SubmittableExtrinsic } from '@polkadot/api/types' import { extendDebug, Debugger } from './Debugger' @@ -90,6 +89,13 @@ export abstract class BaseQueryNodeFixture extends BaseFixture { // Implement in child class! } + public async runOrionChecks(): Promise { + if (!this.executed) { + throw new Error('Cannot run orion checks before Fixture is executed') + } + // Implement in child class! + } + protected findMatchingQueryNodeEvent( eventToFind: EventDetails, queryNodeEvents: T[] @@ -125,7 +131,7 @@ export abstract class StandardizedFixture extends BaseQueryNodeFixture { }) } - public setErrorName(errName: string) { + public setErrorName(errName: string): void { this.expectedErrorName = errName } @@ -154,6 +160,7 @@ export class FixtureRunner { private fixture: BaseFixture private ran = false private queryNodeChecksRan = false + private orionChecksRan = false constructor(fixture: BaseFixture) { this.fixture = fixture @@ -190,8 +197,25 @@ export class FixtureRunner { await this.fixture.runQueryNodeChecks() } + public async runOrionChecks(): Promise { + if (process.env.SKIP_ORION_CHECKS) { + return + } + if (!(this.fixture instanceof BaseQueryNodeFixture)) { + throw new Error('Tried to run orion checks for non-query-node fixture!') + } + if (this.orionChecksRan) { + throw new Error('Fixture orion checks already ran') + } + + this.orionChecksRan = true + + await this.fixture.runOrionChecks() + } + public async runWithQueryNodeChecks(): Promise { await this.run() await this.runQueryNodeChecks() + await this.runOrionChecks() } } diff --git a/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts b/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts index b1321c8283..b419a7c0c1 100644 --- a/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts +++ b/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts @@ -11,6 +11,7 @@ import { MembershipBoughtEventFieldsFragment, MembershipFieldsFragment } from '. import { Utils } from '../../utils' import { StandardizedFixture } from '../../Fixture' import { SubmittableResult } from '@polkadot/api' +import axios from 'axios' type MembershipBoughtEventDetails = EventDetails> @@ -124,4 +125,22 @@ export class BuyMembershipHappyCaseFixture extends StandardizedFixture { const qMembers = await this.query.getMembersByIds(this.events.map((e) => e.event.data[0])) this.assertQueriedMembersAreValid(qMembers, qEvents) } + + public async runOrionChecks(): Promise { + await super.runOrionChecks() + // Wait a minute, let Orion catch up + await Utils.wait(60_000) + const result = await axios.post('http://localhost:4350/graphql', { + query: ` + query { + memberships(where: { id_in: [${this.getCreatedMembers() + .map((id) => `"${id}"`) + .join(', ')}] }) { + id + } + } + `, + }) + assert.equal(result.data.data.memberships.length, this.getCreatedMembers().length) + } } diff --git a/tests/network-tests/src/scenarios/orion.ts b/tests/network-tests/src/scenarios/orion.ts new file mode 100644 index 0000000000..793b3a1595 --- /dev/null +++ b/tests/network-tests/src/scenarios/orion.ts @@ -0,0 +1,7 @@ +import { scenario } from '../Scenario' +import buyingMemberships from '../flows/membership/buyingMemberships' + +// eslint-disable-next-line @typescript-eslint/no-floating-promises +scenario('Orion', async ({ job }) => { + job('buying memberships', buyingMemberships) +})