Merge pull request #763 from status-im/go-waku-drop-in

This commit is contained in:
fryorcraken.eth 2022-08-25 15:16:49 +10:00 committed by GitHub
commit 9f52d2b49d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 4 deletions

View File

@ -97,6 +97,52 @@ jobs:
name: nwaku-logs
path: log/
node_with_go_waku:
runs-on: ubuntu-latest
env:
GO_WAKU_VERSION: "0.2.1"
WAKU_SERVICE_NODE_DIR: ./go-waku
WAKU_SERVICE_NODE_BIN: ./waku
WAKU_SERVICE_NODE_PARAMS: "--min-relay-peers-to-publish=0" # Can be removed once https://github.com/status-im/nwaku/issues/1004 is done
DEBUG: "waku*"
steps:
- uses: actions/checkout@v3
- name: Get go-waku
shell: bash
run: |
pwd
mkdir -p go-waku/
cd go-waku
wget "https://github.com/status-im/go-waku/releases/download/v${GO_WAKU_VERSION}/gowaku-${GO_WAKU_VERSION}-x86_64.deb"
sudo apt install ./gowaku-${GO_WAKU_VERSION}-x86_64.deb
cp $(which waku) ./
- name: Ensure go-waku is ready
shell: bash
run: |
uname -a
cd "${WAKU_SERVICE_NODE_DIR}"
"${WAKU_SERVICE_NODE_BIN}" --version
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- uses: bahmutov/npm-install@v1
- run: npm run test:node
env:
DEBUG: "waku:nwaku*,waku:test*"
- name: Upload logs on failure
uses: actions/upload-artifact@v2
if: failure()
with:
name: go-waku-logs
path: log/
release_next:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'

View File

@ -64,7 +64,15 @@ export class DnsNodeDiscovery {
this._errorTolerance,
() => this._search(domain, context)
);
dbg("retrieved peers: ", peers);
dbg(
"retrieved peers: ",
peers.map((peer) => {
return {
id: peer.peerId?.toString(),
multiaddrs: peer.multiaddrs?.map((ma) => ma.toString()),
};
})
);
return peers;
}

View File

@ -99,6 +99,7 @@ describe("Wait for remote peer", function () {
relay: false,
lightpush: false,
filter: false,
persistMessages: true,
});
const multiAddrWithId = await nwaku.getMultiaddrWithId();
@ -125,6 +126,7 @@ describe("Wait for remote peer", function () {
relay: false,
lightpush: false,
filter: false,
persistMessages: true,
});
const multiAddrWithId = await nwaku.getMultiaddrWithId();

View File

@ -22,7 +22,7 @@ describe("Waku Filter", () => {
});
beforeEach(async function () {
this.timeout(10000);
this.timeout(15000);
nwaku = new Nwaku(makeLogFileName(this));
await nwaku.start({ filter: true, lightpush: true });
waku = await createWaku({
@ -46,6 +46,10 @@ describe("Waku Filter", () => {
expect(msg.payloadAsUtf8).to.eq(messageText);
};
await waku.filter.subscribe(callback, [TestContentTopic]);
// As the filter protocol does not cater for a ack of subscription
// we cannot know whether the subscription happened. Something we want to
// correct in future versions of the protocol.
await delay(200);
const message = await WakuMessage.fromUtf8String(
messageText,
TestContentTopic
@ -66,6 +70,7 @@ describe("Waku Filter", () => {
expect(msg.contentTopic).to.eq(TestContentTopic);
};
await waku.filter.subscribe(callback, [TestContentTopic]);
await delay(200);
await waku.lightPush.push(
await WakuMessage.fromUtf8String("Filtering works!", TestContentTopic)
);
@ -89,6 +94,7 @@ describe("Waku Filter", () => {
const unsubscribe = await waku.filter.subscribe(callback, [
TestContentTopic,
]);
await delay(200);
await waku.lightPush.push(
await WakuMessage.fromUtf8String(
"This should be received",
@ -97,6 +103,7 @@ describe("Waku Filter", () => {
);
await delay(100);
await unsubscribe();
await delay(200);
await waku.lightPush.push(
await WakuMessage.fromUtf8String(
"This should not be received",

View File

@ -18,6 +18,7 @@ import { WakuMessage } from "../lib/waku_message";
import * as proto from "../proto/message";
import { existsAsync, mkdirAsync, openAsync } from "./async_fs";
import { delay } from "./delay";
import waitForLine from "./log_file";
const dbg = debug("waku:nwaku");
@ -181,6 +182,7 @@ export class Nwaku {
dbg(`Waiting to see '${NODE_READY_LOG_LINE}' in nwaku logs`);
await this.waitForLog(NODE_READY_LOG_LINE, 15000);
if (process.env.CI) await delay(100);
dbg("nwaku node has been started");
}
@ -249,12 +251,19 @@ export class Nwaku {
async getAsymmetricKeyPair(): Promise<KeyPair> {
this.checkProcess();
const { seckey, pubkey } = await this.rpcCall<{
const { privateKey, publicKey, seckey, pubkey } = await this.rpcCall<{
seckey: string;
pubkey: string;
privateKey: string;
publicKey: string;
}>("get_waku_v2_private_v1_asymmetric_keypair", []);
// To be removed once https://github.com/vacp2p/rfc/issues/507 is fixed
if (seckey) {
return { privateKey: seckey, publicKey: pubkey };
} else {
return { privateKey, publicKey };
}
}
async postAsymmetricMessage(