git.delta.rocks / unique-network / refs/commits / f7b41a8746a2

difftreelog

source

tests/src/connection.test.ts1.0 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    console.log = function () {};25    console.error = function () {};2627    const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');28    await expect((async () => {29      await usingApi(async api => {30        const health = await api.rpc.system.health();31      }, { provider: neverConnectProvider });32    })()).to.be.eventually.rejected;3334    delete console.log;35    delete console.error;36  });37});