query-node.test.ts 867 B

1234567891011121314151617181920212223242526272829
  1. import { expect } from 'chai'
  2. import Container from 'typedi'
  3. import { QueryNode, QueryNodeState } from '../../src'
  4. import { sleep } from '../../src/utils/wait-for'
  5. describe('QueryNode', () => {
  6. before(async () => {
  7. await QueryNode.create({
  8. wsProviderURI: process.env.WS_PROVIDER_URI || '',
  9. redisURI: process.env.REDIS_URI,
  10. })
  11. })
  12. it('Should initialize the indexer', async () => {
  13. const node = Container.get<QueryNode>('QueryNode')
  14. expect(node.api, 'Api should be initialized').to.not.be.undefined
  15. expect(node.indexBuilder, 'IndexBuilder should be initialized').to.not.be
  16. .undefined
  17. await Promise.race([node.start(), sleep(100)])
  18. expect(node.state).to.be.eq(QueryNodeState.STARTED, 'Should be started')
  19. await node.stop()
  20. expect(node.state).to.be.eq(QueryNodeState.STOPPED, 'Should be stopped')
  21. })
  22. })