diff --git a/packages/indexer-cli/src/__tests__/cli.test.ts b/packages/indexer-cli/src/__tests__/cli.test.ts index 8c3b8c1c8..40fcda30c 100644 --- a/packages/indexer-cli/src/__tests__/cli.test.ts +++ b/packages/indexer-cli/src/__tests__/cli.test.ts @@ -1,10 +1,10 @@ -import { cliTest, setup, teardown } from './util' +import { cliTest, setupMultiNetworks, teardown } from './util' import path from 'path' const baseDir = path.join(__dirname) describe('Indexer cli tests', () => { - beforeEach(setup) + beforeEach(setupMultiNetworks) afterEach(teardown) describe('General', () => { diff --git a/packages/indexer-cli/src/__tests__/indexer/actions.test.ts b/packages/indexer-cli/src/__tests__/indexer/actions.test.ts index efbf955aa..6d432b3d4 100644 --- a/packages/indexer-cli/src/__tests__/indexer/actions.test.ts +++ b/packages/indexer-cli/src/__tests__/indexer/actions.test.ts @@ -1,10 +1,16 @@ -import { cliTest, deleteFromAllTables, seedActions, setup, teardown } from '../util' +import { + cliTest, + deleteFromAllTables, + seedActions, + setupMultiNetworks, + teardown, +} from '../util' import path from 'path' const baseDir = path.join(__dirname, '..') describe('Indexer actions tests', () => { describe('With indexer management server', () => { - beforeAll(setup) + beforeAll(setupMultiNetworks) afterAll(teardown) beforeEach(seedActions) afterEach(deleteFromAllTables) diff --git a/packages/indexer-cli/src/__tests__/indexer/cost.test.ts b/packages/indexer-cli/src/__tests__/indexer/cost.test.ts index b076aeb51..f4963968a 100644 --- a/packages/indexer-cli/src/__tests__/indexer/cost.test.ts +++ b/packages/indexer-cli/src/__tests__/indexer/cost.test.ts @@ -1,18 +1,19 @@ import { cliTest, - setup, teardown, connect, deleteFromAllTables, seedCostModels, + setupSingleNetwork, + setupMultiNetworks, } from '../util' import path from 'path' const baseDir = path.join(__dirname, '..') -describe('Indexer cost tests', () => { +describe('Indexer cost tests singleNetwork', () => { describe('With indexer management server', () => { - beforeAll(setup) + beforeAll(setupSingleNetwork) afterAll(teardown) beforeEach(seedCostModels) afterEach(deleteFromAllTables) @@ -231,3 +232,47 @@ describe('Indexer cost tests', () => { ) }) }) + +describe('Indexer cost tests multiNetworks', () => { + beforeAll(setupMultiNetworks) + afterAll(teardown) + beforeEach(seedCostModels) + afterEach(deleteFromAllTables) + + describe('Cost set...', () => { + cliTest( + 'Indexer cost set model deployment id - reject multinetwork mode', + [ + 'indexer', + 'cost', + 'set', + 'model', + 'QmXRpJW3qBuYaiBYHdhv8DF4bHDZhXBmh91MtrnhJfQ5Lk', + 'references/basic.agora', + ], + 'references/indexer-cost-model-deployment-multinetworks', + { + expectedExitCode: 1, + cwd: baseDir, + timeout: 10000, + }, + ) + cliTest( + 'Indexer cost set variable deployment id - reject multinetwork mode', + [ + 'indexer', + 'cost', + 'set', + 'variables', + 'QmQ44hgrWWt3Qf2X9XEX2fPyTbmQbChxwNm5c1t4mhKpGt', + `'{"DAI": "0.5"}'`, + ], + 'references/indexer-cost-variables-deployment-multinetworks', + { + expectedExitCode: 1, + cwd: baseDir, + timeout: 10000, + }, + ) + }) +}) diff --git a/packages/indexer-cli/src/__tests__/indexer/rules.test.ts b/packages/indexer-cli/src/__tests__/indexer/rules.test.ts index c6fac2946..9e32e0046 100644 --- a/packages/indexer-cli/src/__tests__/indexer/rules.test.ts +++ b/packages/indexer-cli/src/__tests__/indexer/rules.test.ts @@ -1,10 +1,10 @@ import { cliTest, connect, - setup, teardown, deleteFromAllTables, seedIndexingRules, + setupMultiNetworks, } from '../util' import path from 'path' @@ -12,7 +12,7 @@ const baseDir = path.join(__dirname, '..') describe('Indexer rules tests', () => { describe('With indexer management server', () => { - beforeAll(setup) + beforeAll(setupMultiNetworks) afterAll(teardown) beforeEach(seedIndexingRules) afterEach(deleteFromAllTables) diff --git a/packages/indexer-cli/src/__tests__/references/indexer-cost-model-deployment-multinetworks.stdout b/packages/indexer-cli/src/__tests__/references/indexer-cost-model-deployment-multinetworks.stdout new file mode 100644 index 000000000..d5837d8c3 --- /dev/null +++ b/packages/indexer-cli/src/__tests__/references/indexer-cost-model-deployment-multinetworks.stdout @@ -0,0 +1 @@ +[GraphQL] Must be in single network mode to set cost models diff --git a/packages/indexer-cli/src/__tests__/references/indexer-cost-variables-deployment-multinetworks.stdout b/packages/indexer-cli/src/__tests__/references/indexer-cost-variables-deployment-multinetworks.stdout new file mode 100644 index 000000000..d5837d8c3 --- /dev/null +++ b/packages/indexer-cli/src/__tests__/references/indexer-cost-variables-deployment-multinetworks.stdout @@ -0,0 +1 @@ +[GraphQL] Must be in single network mode to set cost models diff --git a/packages/indexer-cli/src/__tests__/util.ts b/packages/indexer-cli/src/__tests__/util.ts index 8febc5902..f0ad712a3 100644 --- a/packages/indexer-cli/src/__tests__/util.ts +++ b/packages/indexer-cli/src/__tests__/util.ts @@ -103,7 +103,15 @@ export const testNetworkSpecification = specification.NetworkSpecification.parse }, }) -export const setup = async () => { +export const setupMultiNetworks = async () => { + return await setup(true) +} + +export const setupSingleNetwork = async () => { + return await setup(false) +} + +export const setup = async (multiNetworksEnabled: boolean) => { logger = createLogger({ name: 'Setup', async: false, @@ -141,10 +149,12 @@ export const setup = async () => { const fakeMainnetNetwork = cloneDeep(network) as Network fakeMainnetNetwork.specification.networkIdentifier = 'eip155:1' - const multiNetworks = new MultiNetworks( - [network, fakeMainnetNetwork], - (n: Network) => n.specification.networkIdentifier, - ) + const multiNetworks = multiNetworksEnabled + ? new MultiNetworks( + [network, fakeMainnetNetwork], + (n: Network) => n.specification.networkIdentifier, + ) + : new MultiNetworks([network], (n: Network) => n.specification.networkIdentifier) const defaults: IndexerManagementDefaults = { globalIndexingRule: {