-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9d8470
commit 334da41
Showing
9 changed files
with
112 additions
and
4 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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export const Commands = Object.freeze({ | ||
AUTH_ADD: 1, | ||
AUTH_DEL: 2, | ||
AUTH_LIST: 3 | ||
AUTH_LIST: 3, | ||
PEER_ID: 4, | ||
PEER_ADDRESSES: 5 | ||
}) |
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,8 @@ | ||
export default ({ libp2p }) => { | ||
const addresses = [] | ||
libp2p.getMultiaddrs().forEach((address) => { | ||
addresses.push(address.toString()) | ||
}) | ||
|
||
return addresses | ||
} |
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,3 @@ | ||
export default ({ libp2p }) => { | ||
return libp2p.peerId.toString() | ||
} |
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
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,35 @@ | ||
import { spawn, execSync } from 'node:child_process' | ||
import { strictEqual } from 'assert' | ||
import { rimraf } from 'rimraf' | ||
import { loadConfig } from '../../src/utils/config-manager.js' | ||
import waitForDaemonStarted from '../utils/wait-for-daemon-start.js' | ||
|
||
describe.only('Commands - peer', function () { | ||
let daemon | ||
let config | ||
|
||
before(async function () { | ||
daemon = spawn('./src/bin/cli.js', ['daemon']) | ||
await waitForDaemonStarted(daemon) | ||
const path = 'voyager' | ||
config = await loadConfig({ path }) | ||
}) | ||
|
||
after(async function () { | ||
if (daemon) { | ||
daemon.kill() | ||
} | ||
await rimraf('voyager') | ||
}) | ||
|
||
it('gets the peer id', function () { | ||
const peerId = execSync('./src/bin/cli.js peer id') | ||
strictEqual(peerId.toString(), `${config.orbiter.peerId}\n`) | ||
}) | ||
|
||
it('gets the peer addresses', function () { | ||
const peerAddresses = execSync('./src/bin/cli.js peer addresses') | ||
const addresses = peerAddresses.toString().split("\n"); | ||
strictEqual(addresses.includes(config.orbiter.api), true) | ||
}) | ||
}) |