-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: convert to ESM and upgrade all deps (#84)
Upgrade to the latest libp2p and convert to ESM BREAKING CHANGE: this module is now ESM-only
- Loading branch information
1 parent
277b5d9
commit d88e0e7
Showing
13 changed files
with
193 additions
and
233 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
'use strict' | ||
import { createLibp2p } from 'libp2p' | ||
import { config } from './test/utils/create-libp2p.js' | ||
|
||
const Libp2p = require('libp2p') | ||
const PeerInfo = require('peer-info') | ||
const { config } = require('./test/utils/create-libp2p') | ||
|
||
let relay | ||
|
||
module.exports = { | ||
hooks: { | ||
pre: async () => { | ||
const peerInfo = await PeerInfo.create() | ||
peerInfo.multiaddrs.add('/ip4/127.0.0.1/tcp/24642/ws') | ||
|
||
const defaultConfig = await config() | ||
|
||
relay = new Libp2p({ | ||
export default { | ||
test: { | ||
async before () { | ||
const defaultConfig = config() | ||
const relay = await createLibp2p({ | ||
...defaultConfig, | ||
peerInfo, | ||
config: { | ||
...defaultConfig.config, | ||
relay: { | ||
relay: { | ||
enabled: true, | ||
hop: { | ||
enabled: true, | ||
hop: { | ||
enabled: true | ||
} | ||
active: true | ||
} | ||
}, | ||
addresses: { | ||
listen: [ | ||
'/ip4/127.0.0.1/tcp/24642/ws' | ||
] | ||
} | ||
}) | ||
|
||
await relay.start() | ||
|
||
const addrs = relay.getMultiaddrs() | ||
|
||
return { | ||
relay, | ||
env: { | ||
RELAY_ADDRESS: addrs[0] | ||
} | ||
} | ||
}, | ||
post: async () => { | ||
await relay.stop() | ||
async after (_, before) { | ||
await before.relay.stop() | ||
} | ||
} | ||
} |
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
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,11 +1,9 @@ | ||
'use strict' | ||
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string' | ||
|
||
const { fromString: uint8arrayFromString } = require('uint8arrays/from-string') | ||
|
||
module.exports = (_message) => { | ||
let message = _message | ||
export default (message) => { | ||
if (!(message instanceof Uint8Array)) { | ||
message = uint8arrayFromString(message) | ||
return uint8arrayFromString(message) | ||
} | ||
|
||
return message | ||
} |
Oops, something went wrong.