2021-04-13 17:10:03 +02:00
|
|
|
/* eslint-disable prefer-destructuring */
|
|
|
|
import { assert, use } from 'chai'
|
|
|
|
import spies from 'chai-spies'
|
|
|
|
import Web3 from 'web3'
|
|
|
|
const fetch = require('cross-fetch')
|
|
|
|
const web3 = new Web3('http://127.0.0.1:8545')
|
|
|
|
const subgraphUrl =
|
|
|
|
'http://localhost:9000/subgraphs/name/oceanprotocol/ocean-subgraph'
|
|
|
|
|
2021-05-13 08:19:21 +02:00
|
|
|
function sleep(ms: number) {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
setTimeout(resolve, ms)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-13 17:10:03 +02:00
|
|
|
use(spies)
|
|
|
|
|
|
|
|
describe('Ending tests', () => {
|
|
|
|
let result: any
|
2021-05-13 08:19:21 +02:00
|
|
|
let lastblock
|
2021-04-13 17:10:03 +02:00
|
|
|
it('Get Graph status', async () => {
|
2021-05-13 08:19:21 +02:00
|
|
|
lastblock = await web3.eth.getBlockNumber()
|
2022-09-23 14:54:27 +02:00
|
|
|
await sleep(3000) // let graph ingest our last transactions
|
2021-04-13 17:10:03 +02:00
|
|
|
const query = {
|
|
|
|
query: `query {
|
|
|
|
_meta{hasIndexingErrors,
|
|
|
|
deployment,
|
|
|
|
block{number}
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
}
|
|
|
|
const response = await fetch(subgraphUrl, {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(query)
|
|
|
|
})
|
|
|
|
result = await response.json()
|
|
|
|
})
|
|
|
|
|
2022-09-23 14:54:27 +02:00
|
|
|
it('Make sure that graph has no index errors', async () => {
|
2021-04-13 17:10:03 +02:00
|
|
|
assert(result.data._meta.hasIndexingErrors == false)
|
|
|
|
})
|
|
|
|
it('Make sure that graph has synced to last block', async () => {
|
2022-09-23 14:54:27 +02:00
|
|
|
assert(result.data._meta.block.number >= lastblock)
|
2021-04-13 17:10:03 +02:00
|
|
|
})
|
|
|
|
})
|