mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-11-21 16:37:39 -06:00
Merge branch 'fix-wasm-tests' into 'main'
Fix wasm tests See merge request veilid/veilid!326
This commit is contained in:
commit
d88236b97f
@ -76,7 +76,7 @@ pub async fn test_attach_detach() {
|
||||
|
||||
pub async fn test_startup_shutdown_multiple() {
|
||||
trace!("test_startup_shutdown_multiple: starting");
|
||||
let namespaces = (0..10).map(|x| format!("ns_{}", x)).collect::<Vec<_>>();
|
||||
let namespaces = (0..3).map(|x| format!("ns_{}", x)).collect::<Vec<_>>();
|
||||
|
||||
let mut apis = vec![];
|
||||
for ns in &namespaces {
|
||||
@ -96,7 +96,7 @@ pub async fn test_startup_shutdown_multiple() {
|
||||
pub async fn test_startup_shutdown_from_config_multiple() {
|
||||
trace!("test_startup_from_config_multiple: starting");
|
||||
|
||||
let namespaces = (0..10).map(|x| format!("ns_{}", x)).collect::<Vec<_>>();
|
||||
let namespaces = (0..3).map(|x| format!("ns_{}", x)).collect::<Vec<_>>();
|
||||
let mut apis = vec![];
|
||||
for ns in &namespaces {
|
||||
let config = VeilidConfigInner {
|
||||
@ -136,7 +136,7 @@ pub async fn test_startup_shutdown_from_config_multiple() {
|
||||
|
||||
pub async fn test_attach_detach_multiple() {
|
||||
trace!("test_attach_detach_multiple: --- test normal order ---");
|
||||
let namespaces = (0..10).map(|x| format!("ns_{}", x)).collect::<Vec<_>>();
|
||||
let namespaces = (0..3).map(|x| format!("ns_{}", x)).collect::<Vec<_>>();
|
||||
let mut apis = vec![];
|
||||
for ns in &namespaces {
|
||||
let (update_callback, config_callback) = setup_veilid_core_with_namespace(ns);
|
||||
|
@ -4,6 +4,7 @@ name = "veilid-wasm"
|
||||
version = "0.3.4"
|
||||
# ---
|
||||
description = "Veilid bindings for WebAssembly"
|
||||
repository = "https://gitlab.com/veilid/veilid"
|
||||
authors = ["Veilid Team <contact@veilid.com>"]
|
||||
license = "MPL-2.0"
|
||||
edition = "2021"
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
veilidCrypto,
|
||||
} from 'veilid-wasm';
|
||||
import { textEncoder, textDecoder } from './utils/marshalling-utils';
|
||||
import { asyncCallWithTimeout, waitForPublicAttachment } from './utils/wait-utils';
|
||||
import { asyncCallWithTimeout, waitForPublicAttachment, waitForOfflineSubkeyWrite } from './utils/wait-utils';
|
||||
|
||||
describe('VeilidRoutingContext', () => {
|
||||
before('veilid startup', async () => {
|
||||
@ -255,10 +255,13 @@ describe('VeilidRoutingContext', () => {
|
||||
"Local",
|
||||
);
|
||||
expect(inspectRes).toBeDefined();
|
||||
expect(inspectRes.subkeys).toEqual([[0, 0]]);
|
||||
expect(inspectRes.subkeys.concat(inspectRes.offline_subkeys)).toEqual([[0, 0]]);
|
||||
expect(inspectRes.local_seqs).toEqual([0]);
|
||||
expect(inspectRes.network_seqs).toEqual([]);
|
||||
|
||||
// Wait for synchronization
|
||||
await waitForOfflineSubkeyWrite(routingContext, dhtRecord.key);
|
||||
|
||||
// Inspect network
|
||||
const inspectRes2 = await routingContext.inspectDhtRecord(
|
||||
dhtRecord.key,
|
||||
@ -266,7 +269,8 @@ describe('VeilidRoutingContext', () => {
|
||||
"SyncGet",
|
||||
);
|
||||
expect(inspectRes2).toBeDefined();
|
||||
expect(inspectRes2.subkeys).toEqual([[0, 0]]);
|
||||
expect(inspectRes.subkeys).toEqual([[0, 0]]);
|
||||
expect(inspectRes.offline_subkeys).toEqual([]);
|
||||
expect(inspectRes2.local_seqs).toEqual([0]);
|
||||
expect(inspectRes2.network_seqs).toEqual([0]);
|
||||
});
|
||||
@ -284,7 +288,7 @@ describe('VeilidRoutingContext', () => {
|
||||
dhtRecord.key,
|
||||
);
|
||||
expect(inspectRes).toBeDefined();
|
||||
expect(inspectRes.subkeys).toEqual([[0, 0]]);
|
||||
expect(inspectRes.subkeys.concat(inspectRes.offline_subkeys)).toEqual([[0, 0]]);
|
||||
expect(inspectRes.local_seqs).toEqual([0]);
|
||||
expect(inspectRes.network_seqs).toEqual([]);
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { veilidClient } from 'veilid-wasm';
|
||||
import { veilidClient, VeilidRoutingContext, TypedKey } from 'veilid-wasm';
|
||||
|
||||
export const waitForMs = (milliseconds: number) => {
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||
@ -59,3 +59,9 @@ export const waitForDetached = async () => {
|
||||
await waitForMs(1000);
|
||||
}
|
||||
}
|
||||
|
||||
export const waitForOfflineSubkeyWrite = async (routingContext: VeilidRoutingContext, key: TypedKey) => {
|
||||
while ((await routingContext.inspectDhtRecord(key)).offline_subkeys.length != 0) {
|
||||
await waitForMs(200);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user