git.delta.rocks / unique-network / refs/commits / 6bfc1ca502da

difftreelog

source

tests/src/connection.test.ts1.1 KiBsourcehistory
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import usingApi from './substrate/substrate-api';7import { WsProvider } from '@polkadot/api';8import * as chai from 'chai';9import chaiAsPromised from 'chai-as-promised';1011chai.use(chaiAsPromised);1213const expect = chai.expect;1415describe('Connection smoke test', () => {16  it('Connection can be established', async () => {17    await usingApi(async api => {18      const health = await api.rpc.system.health();19      expect(health).to.be.not.empty;20    });21  });2223  it('Cannot connect to 255.255.255.255', async () => {24    const log = console.log;25    const error = console.error;26    console.log = function () {};27    console.error = function () {};2829    const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');30    await expect((async () => {31      await usingApi(async api => {32        await api.rpc.system.health();33      }, { provider: neverConnectProvider });34    })()).to.be.eventually.rejected;3536    console.log = log;37    console.error = error;38  });39});