Skip to content

Commit

Permalink
cli, common: Update tests
Browse files Browse the repository at this point in the history
No longer use localhost
Use Sepolia testnet
  • Loading branch information
fordN committed Jan 4, 2024
1 parent 2646571 commit eb97773
Show file tree
Hide file tree
Showing 29 changed files with 168 additions and 158 deletions.
2 changes: 1 addition & 1 deletion packages/indexer-agent/src/__tests__/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const setup = async () => {
const networkSpecification = specification.NetworkSpecification.parse({
networkIdentifier: 'eip155:5',
gateway: {
url: 'http://localhost:8030/',
url: 'http://127.0.0.1:8030/',
},
networkProvider: {
url: testProviderUrl,
Expand Down
14 changes: 2 additions & 12 deletions packages/indexer-cli/src/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,14 @@ describe('Indexer cli tests', () => {
})
cliTest(
'Indexer connect - success',
['indexer', 'connect', 'http://localhost:18000'],
'references/indexer-connect',
{
expectedExitCode: 0,
cwd: baseDir,
timeout: 10000,
},
)
// TODO: Connect should fail with helpful error message if incorrect port is provided or server isn't live
cliTest(
'Indexer connect - success with incorrect port',
['indexer', 'connect', 'http://localhost:18003'],
['indexer', 'connect', 'http://127.0.0.1:18000'],
'references/indexer-connect',
{
expectedExitCode: 0,
cwd: baseDir,
timeout: 10000,
},
)
// TODO: Test that connect should fail with helpful error message if incorrect port is provided or server isn't live
})
})
38 changes: 10 additions & 28 deletions packages/indexer-cli/src/__tests__/indexer/actions.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { cliTest, setup, teardown } from '../util'
import path from 'path'
import { Action, ActionType, ActionStatus } from '@graphprotocol/indexer-common'

const baseDir = path.join(__dirname, '..')
describe('Indexer actions tests', () => {
Expand All @@ -23,10 +22,18 @@ describe('Indexer actions tests', () => {
timeout: 10000,
},
)
cliTest(
'Indexer actions get',
['indexer', 'actions', 'get', 'all'],
'references/indexer-actions-get',
{
expectedExitCode: 0,
cwd: baseDir,
timeout: 10000,
},
)
})
describe('Actions queue', () => {
beforeAll(createTestAction)
afterAll(truncateActions)
cliTest(
'Indexer actions get',
['indexer', 'actions', 'get', 'all'],
Expand Down Expand Up @@ -78,28 +85,3 @@ describe('Indexer actions tests', () => {
})
})
})

async function createTestAction() {
await Action.create({
type: ActionType.ALLOCATE,
status: ActionStatus.SUCCESS,
deploymentID: 'QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr',
source: 'test',
reason: 'test',
protocolNetwork: 'eip155:5',
})
await Action.create({
type: ActionType.UNALLOCATE,
status: ActionStatus.FAILED,
deploymentID: 'QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66',
source: 'test',
reason: 'test',
protocolNetwork: 'eip155:5',
})
}

async function truncateActions() {
await Action.destroy({
truncate: true,
})
}
17 changes: 8 additions & 9 deletions packages/indexer-cli/src/__tests__/indexer/cost.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { cliTest, setup, seed, teardown, connect } from '../util'
import {cliTest, setup, seed, teardown, connect, deleteFromAllTables} from '../util'
import path from 'path'

const baseDir = path.join(__dirname, '..')

describe('Indexer cost tests', () => {
describe('With indexer management server', () => {
beforeEach(async () => {
await setup()
await seed()
})
afterEach(teardown)
beforeAll(setup)
afterAll(teardown)
beforeEach(seed)
afterEach(deleteFromAllTables)
describe('Cost help', () => {
cliTest('Indexer cost', ['indexer', 'cost'], 'references/indexer-cost', {
expectedExitCode: 255,
Expand All @@ -36,7 +35,7 @@ describe('Indexer cost tests', () => {
'cost',
'set',
'model',
'QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr',
'QmXRpJW3qBuYaiBYHdhv8DF4bHDZhXBmh91MtrnhJfQ5Lk',
'references/basic.agora',
],
'references/indexer-cost-model-deployment',
Expand Down Expand Up @@ -195,7 +194,7 @@ describe('Indexer cost tests', () => {
'cost',
'set',
'model',
'QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr',
'QmXRpJW3qBuYaiBYHdhv8DF4bHDZhXBmh91MtrnhJfQ5Lk',
'references/basic.agora',
],
'references/indexer-not-connected',
Expand All @@ -217,7 +216,7 @@ describe('Indexer cost tests', () => {
)
cliTest(
'Indexer cost get - not connected',
['indexer', 'cost', 'get', 'QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr'],
['indexer', 'cost', 'get', 'QmXRpJW3qBuYaiBYHdhv8DF4bHDZhXBmh91MtrnhJfQ5Lk'],
'references/indexer-not-connected',
{
expectedExitCode: 1,
Expand Down
Loading

0 comments on commit eb97773

Please sign in to comment.