mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-25 07:19:26 -05:00
add inspect test to wasm
This commit is contained in:
parent
ee54358c27
commit
d586748333
@ -879,7 +879,15 @@ impl RoutingTable {
|
|||||||
// does it have some dial info we need?
|
// does it have some dial info we need?
|
||||||
let filter = |n: &NodeInfo| {
|
let filter = |n: &NodeInfo| {
|
||||||
let mut keep = false;
|
let mut keep = false;
|
||||||
|
// Bootstraps must have -only- inbound capable network class
|
||||||
|
if !matches!(n.network_class(), NetworkClass::InboundCapable) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
for did in n.dial_info_detail_list() {
|
for did in n.dial_info_detail_list() {
|
||||||
|
// Bootstraps must have -only- direct dial info
|
||||||
|
if !matches!(did.class, DialInfoClass::Direct) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if matches!(did.dial_info.address_type(), AddressType::IPV4) {
|
if matches!(did.dial_info.address_type(), AddressType::IPV4) {
|
||||||
for (n, protocol_type) in protocol_types.iter().enumerate() {
|
for (n, protocol_type) in protocol_types.iter().enumerate() {
|
||||||
if nodes_proto_v4[n] < max_per_type
|
if nodes_proto_v4[n] < max_per_type
|
||||||
|
@ -286,8 +286,7 @@ impl RoutingTable {
|
|||||||
{
|
{
|
||||||
Ok(NodeContactMethod::Direct(v)) => v,
|
Ok(NodeContactMethod::Direct(v)) => v,
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
log_rtab!(warn "invalid contact method for bootstrap, restarting network: {:?}", v);
|
log_rtab!(warn "invalid contact method for bootstrap, ignoring peer: {:?}", v);
|
||||||
routing_table.network_manager().restart_network();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -407,10 +407,12 @@ impl VeilidRoutingContext {
|
|||||||
pub async fn inspectDhtRecord(
|
pub async fn inspectDhtRecord(
|
||||||
&self,
|
&self,
|
||||||
key: String,
|
key: String,
|
||||||
subkeys: ValueSubkeyRangeSet,
|
subkeys: Option<ValueSubkeyRangeSet>,
|
||||||
scope: DHTReportScope,
|
scope: Option<DHTReportScope>,
|
||||||
) -> APIResult<DHTRecordReport> {
|
) -> APIResult<DHTRecordReport> {
|
||||||
let key = TypedKey::from_str(&key)?;
|
let key = TypedKey::from_str(&key)?;
|
||||||
|
let subkeys = subkeys.unwrap_or_default();
|
||||||
|
let scope = scope.unwrap_or_default();
|
||||||
|
|
||||||
let routing_context = self.getRoutingContext()?;
|
let routing_context = self.getRoutingContext()?;
|
||||||
let res = routing_context
|
let res = routing_context
|
||||||
|
@ -240,6 +240,54 @@ describe('VeilidRoutingContext', () => {
|
|||||||
expect(cancelValueRes).toEqual(false);
|
expect(cancelValueRes).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set a value and inspect it', async () => {
|
||||||
|
const setValueRes = await routingContext.setDhtValue(
|
||||||
|
dhtRecord.key,
|
||||||
|
0,
|
||||||
|
textEncoder.encode(data)
|
||||||
|
);
|
||||||
|
expect(setValueRes).toBeUndefined();
|
||||||
|
|
||||||
|
// Inspect locally
|
||||||
|
const inspectRes = await routingContext.inspectDhtRecord(
|
||||||
|
dhtRecord.key,
|
||||||
|
[[0, 0]],
|
||||||
|
"Local",
|
||||||
|
);
|
||||||
|
expect(inspectRes).toBeDefined();
|
||||||
|
expect(inspectRes.subkeys).toEqual([[0, 0]]);
|
||||||
|
expect(inspectRes.local_seqs).toEqual([0]);
|
||||||
|
expect(inspectRes.network_seqs).toEqual([]);
|
||||||
|
|
||||||
|
// Inspect network
|
||||||
|
const inspectRes2 = await routingContext.inspectDhtRecord(
|
||||||
|
dhtRecord.key,
|
||||||
|
[[0, 0]],
|
||||||
|
"SyncGet",
|
||||||
|
);
|
||||||
|
expect(inspectRes2).toBeDefined();
|
||||||
|
expect(inspectRes2.subkeys).toEqual([[0, 0]]);
|
||||||
|
expect(inspectRes2.local_seqs).toEqual([0]);
|
||||||
|
expect(inspectRes2.network_seqs).toEqual([0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set a value and inspect it with defaults', async () => {
|
||||||
|
const setValueRes = await routingContext.setDhtValue(
|
||||||
|
dhtRecord.key,
|
||||||
|
0,
|
||||||
|
textEncoder.encode(data)
|
||||||
|
);
|
||||||
|
expect(setValueRes).toBeUndefined();
|
||||||
|
|
||||||
|
// Inspect locally
|
||||||
|
const inspectRes = await routingContext.inspectDhtRecord(
|
||||||
|
dhtRecord.key,
|
||||||
|
);
|
||||||
|
expect(inspectRes).toBeDefined();
|
||||||
|
expect(inspectRes.subkeys).toEqual([[0, 0]]);
|
||||||
|
expect(inspectRes.local_seqs).toEqual([0]);
|
||||||
|
expect(inspectRes.network_seqs).toEqual([]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,5 @@ export const veilidCoreInitConfig: VeilidWASMConfig = {
|
|||||||
export var veilidCoreStartupConfig = (() => {
|
export var veilidCoreStartupConfig = (() => {
|
||||||
var defaultConfig = JSON.parse(veilidClient.defaultConfig());
|
var defaultConfig = JSON.parse(veilidClient.defaultConfig());
|
||||||
defaultConfig.program_name = 'veilid-wasm-test';
|
defaultConfig.program_name = 'veilid-wasm-test';
|
||||||
defaultConfig.network.routing_table.bootstrap = ['ws://bootstrap.dev.veilid.net:5150/ws'];
|
|
||||||
defaultConfig.network.network_key_password = 'dev';
|
|
||||||
return defaultConfig;
|
return defaultConfig;
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user