-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: isOnline should return false when node is offline (#222)
If the node is offline, trying to invoke the api client results in an error being thrown. If this happens the node is not online so return false instead.
- Loading branch information
1 parent
7266128
commit e9436ca
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { expect } from 'aegir/chai' | ||
import { factory } from './utils/factory.js' | ||
import type { KuboRPCClient } from '../src/index.js' | ||
|
||
const f = factory() | ||
|
||
describe('.isOnline', function () { | ||
this.timeout(20 * 1000) | ||
|
||
let ipfs: KuboRPCClient | ||
|
||
before(async function () { | ||
ipfs = (await f.spawn()).api | ||
}) | ||
|
||
after(async function () { return f.clean() }) | ||
|
||
it('should return true when the node is online', async function () { | ||
await expect(ipfs.isOnline()).to.eventually.be.true() | ||
}) | ||
|
||
it('should return false when the node is offline', async function () { | ||
await f.controllers[0].stop() | ||
await expect(ipfs.isOnline()).to.eventually.be.false() | ||
}) | ||
}) |