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

difftreelog

source

tests/src/connection.test.ts931 Bsourcehistory
1import usingApi from "./substrate/substrate-api";2import { WsProvider } from '@polkadot/api';3import * as chai from 'chai';4import chaiAsPromised from 'chai-as-promised';56chai.use(chaiAsPromised);78const expect = chai.expect;910describe('Connection smoke test', () => {11  it('Connection can be established', async () => {12    await usingApi(async api => {13      const health = await api.rpc.system.health();14      expect(health).to.be.not.empty;15    });16  });1718  it('Cannot connect to 255.255.255.255', async () => {19    console.log = function () {};20    console.error = function () {};2122    const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');23    await expect((async () => {24      await usingApi(async api => {25        const health = await api.rpc.system.health();26      }, { provider: neverConnectProvider });27    })()).to.be.eventually.rejected;2829    delete console.log;30    delete console.error;31  });32});