mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-12 09:14:25 -05:00
add default veilid config to the api
This commit is contained in:
parent
31bb8018f6
commit
8818e63dc0
@ -88,6 +88,11 @@ pub fn veilid_version() -> (u32, u32, u32) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the default veilid config as a json object
|
||||||
|
pub fn default_veilid_config() -> String {
|
||||||
|
serialize_json(VeilidConfigInner::default())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub use intf::android::veilid_core_setup_android;
|
pub use intf::android::veilid_core_setup_android;
|
||||||
|
|
||||||
|
@ -120,6 +120,7 @@ pub enum RequestOp {
|
|||||||
},
|
},
|
||||||
VeilidVersionString,
|
VeilidVersionString,
|
||||||
VeilidVersion,
|
VeilidVersion,
|
||||||
|
DefaultVeilidConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
@ -230,6 +231,9 @@ pub enum ResponseOp {
|
|||||||
minor: u32,
|
minor: u32,
|
||||||
patch: u32,
|
patch: u32,
|
||||||
},
|
},
|
||||||
|
DefaultVeilidConfig {
|
||||||
|
value: String,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
|
@ -792,6 +792,9 @@ impl JsonRequestProcessor {
|
|||||||
patch,
|
patch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RequestOp::DefaultVeilidConfig => ResponseOp::DefaultVeilidConfig {
|
||||||
|
value: default_veilid_config(),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Response { id, op }
|
Response { id, op }
|
||||||
|
@ -58,136 +58,135 @@ int getRemoteMaxStorageSpaceMb() {
|
|||||||
return 256;
|
return 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<VeilidConfig> getDefaultVeilidConfig(String programName) async {
|
Future<VeilidConfig> getDefaultVeilidConfig(String programName,
|
||||||
// ignore: do_not_use_environment
|
{String bootstrap = ''}) async =>
|
||||||
const bootstrap = String.fromEnvironment('BOOTSTRAP');
|
VeilidConfig(
|
||||||
return VeilidConfig(
|
programName: programName,
|
||||||
programName: programName,
|
namespace: '',
|
||||||
namespace: '',
|
capabilities: const VeilidConfigCapabilities(disable: []),
|
||||||
capabilities: const VeilidConfigCapabilities(disable: []),
|
protectedStore: const VeilidConfigProtectedStore(
|
||||||
protectedStore: const VeilidConfigProtectedStore(
|
allowInsecureFallback: false,
|
||||||
allowInsecureFallback: false,
|
alwaysUseInsecureStorage: false,
|
||||||
alwaysUseInsecureStorage: false,
|
directory: '',
|
||||||
directory: '',
|
delete: false,
|
||||||
delete: false,
|
deviceEncryptionKeyPassword: '',
|
||||||
deviceEncryptionKeyPassword: '',
|
|
||||||
),
|
|
||||||
tableStore: VeilidConfigTableStore(
|
|
||||||
directory: kIsWeb
|
|
||||||
? ''
|
|
||||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
|
||||||
'table_store'),
|
|
||||||
delete: false,
|
|
||||||
),
|
|
||||||
blockStore: VeilidConfigBlockStore(
|
|
||||||
directory: kIsWeb
|
|
||||||
? ''
|
|
||||||
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
|
||||||
'block_store'),
|
|
||||||
delete: false,
|
|
||||||
),
|
|
||||||
network: VeilidConfigNetwork(
|
|
||||||
connectionInitialTimeoutMs: 2000,
|
|
||||||
connectionInactivityTimeoutMs: 60000,
|
|
||||||
maxConnectionsPerIp4: 32,
|
|
||||||
maxConnectionsPerIp6Prefix: 32,
|
|
||||||
maxConnectionsPerIp6PrefixSize: 56,
|
|
||||||
maxConnectionFrequencyPerMin: 128,
|
|
||||||
clientAllowlistTimeoutMs: 300000,
|
|
||||||
reverseConnectionReceiptTimeMs: 5000,
|
|
||||||
holePunchReceiptTimeMs: 5000,
|
|
||||||
routingTable: VeilidConfigRoutingTable(
|
|
||||||
nodeId: [],
|
|
||||||
nodeIdSecret: [],
|
|
||||||
bootstrap: bootstrap.isNotEmpty
|
|
||||||
? bootstrap.split(',')
|
|
||||||
: (kIsWeb
|
|
||||||
? ['ws://bootstrap.veilid.net:5150/ws']
|
|
||||||
: ['bootstrap.veilid.net']),
|
|
||||||
limitOverAttached: 64,
|
|
||||||
limitFullyAttached: 32,
|
|
||||||
limitAttachedStrong: 16,
|
|
||||||
limitAttachedGood: 8,
|
|
||||||
limitAttachedWeak: 4,
|
|
||||||
),
|
),
|
||||||
rpc: const VeilidConfigRPC(
|
tableStore: VeilidConfigTableStore(
|
||||||
concurrency: 0,
|
directory: kIsWeb
|
||||||
queueSize: 1024,
|
? ''
|
||||||
maxTimestampBehindMs: 10000,
|
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||||
maxTimestampAheadMs: 10000,
|
'table_store'),
|
||||||
timeoutMs: 5000,
|
delete: false,
|
||||||
maxRouteHopCount: 4,
|
|
||||||
defaultRouteHopCount: 1,
|
|
||||||
),
|
),
|
||||||
dht: VeilidConfigDHT(
|
blockStore: VeilidConfigBlockStore(
|
||||||
maxFindNodeCount: 20,
|
directory: kIsWeb
|
||||||
resolveNodeTimeoutMs: 10000,
|
? ''
|
||||||
resolveNodeCount: 1,
|
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
||||||
resolveNodeFanout: 4,
|
'block_store'),
|
||||||
getValueTimeoutMs: 10000,
|
delete: false,
|
||||||
getValueCount: 3,
|
),
|
||||||
getValueFanout: 4,
|
network: VeilidConfigNetwork(
|
||||||
setValueTimeoutMs: 10000,
|
|
||||||
setValueCount: 5,
|
|
||||||
setValueFanout: 4,
|
|
||||||
minPeerCount: 20,
|
|
||||||
minPeerRefreshTimeMs: 60000,
|
|
||||||
validateDialInfoReceiptTimeMs: 2000,
|
|
||||||
localSubkeyCacheSize: getLocalSubkeyCacheSize(),
|
|
||||||
localMaxSubkeyCacheMemoryMb: await getLocalMaxSubkeyCacheMemoryMb(),
|
|
||||||
remoteSubkeyCacheSize: getRemoteSubkeyCacheSize(),
|
|
||||||
remoteMaxRecords: getRemoteMaxRecords(),
|
|
||||||
remoteMaxSubkeyCacheMemoryMb: await getRemoteMaxSubkeyCacheMemoryMb(),
|
|
||||||
remoteMaxStorageSpaceMb: getRemoteMaxStorageSpaceMb(),
|
|
||||||
publicWatchLimit: 32,
|
|
||||||
memberWatchLimit: 8,
|
|
||||||
maxWatchExpirationMs: 600000),
|
|
||||||
upnp: true,
|
|
||||||
detectAddressChanges: true,
|
|
||||||
restrictedNatRetries: 0,
|
|
||||||
tls: const VeilidConfigTLS(
|
|
||||||
certificatePath: '',
|
|
||||||
privateKeyPath: '',
|
|
||||||
connectionInitialTimeoutMs: 2000,
|
connectionInitialTimeoutMs: 2000,
|
||||||
),
|
connectionInactivityTimeoutMs: 60000,
|
||||||
application: const VeilidConfigApplication(
|
maxConnectionsPerIp4: 32,
|
||||||
https: VeilidConfigHTTPS(
|
maxConnectionsPerIp6Prefix: 32,
|
||||||
enabled: false,
|
maxConnectionsPerIp6PrefixSize: 56,
|
||||||
|
maxConnectionFrequencyPerMin: 128,
|
||||||
|
clientAllowlistTimeoutMs: 300000,
|
||||||
|
reverseConnectionReceiptTimeMs: 5000,
|
||||||
|
holePunchReceiptTimeMs: 5000,
|
||||||
|
routingTable: VeilidConfigRoutingTable(
|
||||||
|
nodeId: [],
|
||||||
|
nodeIdSecret: [],
|
||||||
|
bootstrap: bootstrap.isNotEmpty
|
||||||
|
? bootstrap.split(',')
|
||||||
|
: (kIsWeb
|
||||||
|
? ['ws://bootstrap.veilid.net:5150/ws']
|
||||||
|
: ['bootstrap.veilid.net']),
|
||||||
|
limitOverAttached: 64,
|
||||||
|
limitFullyAttached: 32,
|
||||||
|
limitAttachedStrong: 16,
|
||||||
|
limitAttachedGood: 8,
|
||||||
|
limitAttachedWeak: 4,
|
||||||
|
),
|
||||||
|
rpc: const VeilidConfigRPC(
|
||||||
|
concurrency: 0,
|
||||||
|
queueSize: 1024,
|
||||||
|
maxTimestampBehindMs: 10000,
|
||||||
|
maxTimestampAheadMs: 10000,
|
||||||
|
timeoutMs: 5000,
|
||||||
|
maxRouteHopCount: 4,
|
||||||
|
defaultRouteHopCount: 1,
|
||||||
|
),
|
||||||
|
dht: VeilidConfigDHT(
|
||||||
|
maxFindNodeCount: 20,
|
||||||
|
resolveNodeTimeoutMs: 10000,
|
||||||
|
resolveNodeCount: 1,
|
||||||
|
resolveNodeFanout: 4,
|
||||||
|
getValueTimeoutMs: 10000,
|
||||||
|
getValueCount: 3,
|
||||||
|
getValueFanout: 4,
|
||||||
|
setValueTimeoutMs: 10000,
|
||||||
|
setValueCount: 5,
|
||||||
|
setValueFanout: 4,
|
||||||
|
minPeerCount: 20,
|
||||||
|
minPeerRefreshTimeMs: 60000,
|
||||||
|
validateDialInfoReceiptTimeMs: 2000,
|
||||||
|
localSubkeyCacheSize: getLocalSubkeyCacheSize(),
|
||||||
|
localMaxSubkeyCacheMemoryMb: await getLocalMaxSubkeyCacheMemoryMb(),
|
||||||
|
remoteSubkeyCacheSize: getRemoteSubkeyCacheSize(),
|
||||||
|
remoteMaxRecords: getRemoteMaxRecords(),
|
||||||
|
remoteMaxSubkeyCacheMemoryMb:
|
||||||
|
await getRemoteMaxSubkeyCacheMemoryMb(),
|
||||||
|
remoteMaxStorageSpaceMb: getRemoteMaxStorageSpaceMb(),
|
||||||
|
publicWatchLimit: 32,
|
||||||
|
memberWatchLimit: 8,
|
||||||
|
maxWatchExpirationMs: 600000),
|
||||||
|
upnp: true,
|
||||||
|
detectAddressChanges: true,
|
||||||
|
restrictedNatRetries: 0,
|
||||||
|
tls: const VeilidConfigTLS(
|
||||||
|
certificatePath: '',
|
||||||
|
privateKeyPath: '',
|
||||||
|
connectionInitialTimeoutMs: 2000,
|
||||||
|
),
|
||||||
|
application: const VeilidConfigApplication(
|
||||||
|
https: VeilidConfigHTTPS(
|
||||||
|
enabled: false,
|
||||||
|
listenAddress: '',
|
||||||
|
path: '',
|
||||||
|
),
|
||||||
|
http: VeilidConfigHTTP(
|
||||||
|
enabled: false,
|
||||||
|
listenAddress: '',
|
||||||
|
path: '',
|
||||||
|
)),
|
||||||
|
protocol: const VeilidConfigProtocol(
|
||||||
|
udp: VeilidConfigUDP(
|
||||||
|
enabled: !kIsWeb,
|
||||||
|
socketPoolSize: 0,
|
||||||
listenAddress: '',
|
listenAddress: '',
|
||||||
path: '',
|
|
||||||
),
|
),
|
||||||
http: VeilidConfigHTTP(
|
tcp: VeilidConfigTCP(
|
||||||
enabled: false,
|
connect: !kIsWeb,
|
||||||
|
listen: !kIsWeb,
|
||||||
|
maxConnections: 32,
|
||||||
listenAddress: '',
|
listenAddress: '',
|
||||||
path: '',
|
),
|
||||||
)),
|
ws: VeilidConfigWS(
|
||||||
protocol: const VeilidConfigProtocol(
|
connect: true,
|
||||||
udp: VeilidConfigUDP(
|
listen: !kIsWeb,
|
||||||
enabled: !kIsWeb,
|
maxConnections: 32,
|
||||||
socketPoolSize: 0,
|
listenAddress: '',
|
||||||
listenAddress: '',
|
path: 'ws',
|
||||||
),
|
),
|
||||||
tcp: VeilidConfigTCP(
|
wss: VeilidConfigWSS(
|
||||||
connect: !kIsWeb,
|
connect: true,
|
||||||
listen: !kIsWeb,
|
listen: false,
|
||||||
maxConnections: 32,
|
maxConnections: 32,
|
||||||
listenAddress: '',
|
listenAddress: '',
|
||||||
),
|
path: 'ws',
|
||||||
ws: VeilidConfigWS(
|
),
|
||||||
connect: true,
|
|
||||||
listen: !kIsWeb,
|
|
||||||
maxConnections: 32,
|
|
||||||
listenAddress: '',
|
|
||||||
path: 'ws',
|
|
||||||
),
|
|
||||||
wss: VeilidConfigWSS(
|
|
||||||
connect: true,
|
|
||||||
listen: false,
|
|
||||||
maxConnections: 32,
|
|
||||||
listenAddress: '',
|
|
||||||
path: 'ws',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
@ -162,5 +162,6 @@ abstract class Veilid {
|
|||||||
Timestamp now();
|
Timestamp now();
|
||||||
String veilidVersionString();
|
String veilidVersionString();
|
||||||
VeilidVersion veilidVersion();
|
VeilidVersion veilidVersion();
|
||||||
|
String defaultVeilidConfig();
|
||||||
Future<String> debug(String command);
|
Future<String> debug(String command);
|
||||||
}
|
}
|
||||||
|
@ -235,6 +235,9 @@ final class VeilidVersionFFI extends Struct {
|
|||||||
|
|
||||||
typedef _VeilidVersionDart = VeilidVersionFFI Function();
|
typedef _VeilidVersionDart = VeilidVersionFFI Function();
|
||||||
|
|
||||||
|
// fn default_veilid_config() -> *mut c_char
|
||||||
|
typedef _DefaultVeilidConfigDart = Pointer<Utf8> Function();
|
||||||
|
|
||||||
// Async message types
|
// Async message types
|
||||||
const int messageOk = 0;
|
const int messageOk = 0;
|
||||||
const int messageErr = 1;
|
const int messageErr = 1;
|
||||||
@ -1388,7 +1391,9 @@ class VeilidFFI extends Veilid {
|
|||||||
_veilidVersionString = dylib.lookupFunction<Pointer<Utf8> Function(),
|
_veilidVersionString = dylib.lookupFunction<Pointer<Utf8> Function(),
|
||||||
_VeilidVersionStringDart>('veilid_version_string'),
|
_VeilidVersionStringDart>('veilid_version_string'),
|
||||||
_veilidVersion = dylib.lookupFunction<VeilidVersionFFI Function(),
|
_veilidVersion = dylib.lookupFunction<VeilidVersionFFI Function(),
|
||||||
_VeilidVersionDart>('veilid_version') {
|
_VeilidVersionDart>('veilid_version'),
|
||||||
|
_defaultVeilidConfig = dylib.lookupFunction<Pointer<Utf8> Function(),
|
||||||
|
_DefaultVeilidConfigDart>('default_veilid_config') {
|
||||||
// Get veilid_flutter initializer
|
// Get veilid_flutter initializer
|
||||||
final initializeVeilidFlutter = _dylib.lookupFunction<
|
final initializeVeilidFlutter = _dylib.lookupFunction<
|
||||||
Void Function(Pointer<_DartPostCObject>),
|
Void Function(Pointer<_DartPostCObject>),
|
||||||
@ -1481,6 +1486,7 @@ class VeilidFFI extends Veilid {
|
|||||||
final _DebugDart _debug;
|
final _DebugDart _debug;
|
||||||
final _VeilidVersionStringDart _veilidVersionString;
|
final _VeilidVersionStringDart _veilidVersionString;
|
||||||
final _VeilidVersionDart _veilidVersion;
|
final _VeilidVersionDart _veilidVersion;
|
||||||
|
final _DefaultVeilidConfigDart _defaultVeilidConfig;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initializeVeilidCore(Map<String, dynamic> platformConfigJson) {
|
void initializeVeilidCore(Map<String, dynamic> platformConfigJson) {
|
||||||
@ -1714,4 +1720,12 @@ class VeilidFFI extends Veilid {
|
|||||||
version.patch,
|
version.patch,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String defaultVeilidConfig() {
|
||||||
|
final defaultVeilidConfig = _defaultVeilidConfig();
|
||||||
|
final ret = defaultVeilidConfig.toDartString();
|
||||||
|
_freeString(defaultVeilidConfig);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,4 +705,8 @@ class VeilidJS extends Veilid {
|
|||||||
return VeilidVersion(jsonVersion['major'] as int,
|
return VeilidVersion(jsonVersion['major'] as int,
|
||||||
jsonVersion['minor'] as int, jsonVersion['patch'] as int);
|
jsonVersion['minor'] as int, jsonVersion['patch'] as int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String defaultVeilidConfig() =>
|
||||||
|
js_util.callMethod(wasm, 'default_veilid_config', []);
|
||||||
}
|
}
|
||||||
|
@ -1765,3 +1765,8 @@ pub extern "C" fn veilid_version() -> VeilidVersion {
|
|||||||
patch,
|
patch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn default_veilid_config() -> *mut c_char {
|
||||||
|
veilid_core::default_veilid_config().into_ffi_value()
|
||||||
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# Basic veilid tests
|
# Basic veilid tests
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
import json
|
||||||
|
import dataclasses
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import veilid
|
import veilid
|
||||||
@ -40,3 +42,19 @@ async def test_version(api_connection: veilid.VeilidAPI):
|
|||||||
|
|
||||||
vstr = await api_connection.veilid_version_string()
|
vstr = await api_connection.veilid_version_string()
|
||||||
print(f"veilid_version_string: {vstr}")
|
print(f"veilid_version_string: {vstr}")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_config(api_connection: veilid.VeilidAPI):
|
||||||
|
cfgstr = await api_connection.default_veilid_config()
|
||||||
|
print(f"default_veilid_config:\n{cfgstr}")
|
||||||
|
cfgjson = json.loads(cfgstr)
|
||||||
|
|
||||||
|
veilidConfigInstance = veilid.VeilidConfig(**cfgjson)
|
||||||
|
cfgstr2 = json.dumps(dataclasses.asdict(veilidConfigInstance))
|
||||||
|
|
||||||
|
cfgjson2 = json.loads(cfgstr2)
|
||||||
|
veilidConfigInstance2 = veilid.VeilidConfig(**cfgjson2)
|
||||||
|
|
||||||
|
assert veilidConfigInstance == veilidConfigInstance2
|
||||||
|
|
||||||
|
@ -396,3 +396,7 @@ class VeilidAPI(ABC):
|
|||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def veilid_version(self) -> types.VeilidVersion:
|
async def veilid_version(self) -> types.VeilidVersion:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def default_veilid_config(self) -> str:
|
||||||
|
pass
|
||||||
|
@ -432,6 +432,9 @@ class _JsonVeilidAPI(VeilidAPI):
|
|||||||
v = await self.send_ndjson_request(Operation.VEILID_VERSION)
|
v = await self.send_ndjson_request(Operation.VEILID_VERSION)
|
||||||
return VeilidVersion(v["major"], v["minor"], v["patch"])
|
return VeilidVersion(v["major"], v["minor"], v["patch"])
|
||||||
|
|
||||||
|
async def default_veilid_config(self) -> str:
|
||||||
|
return raise_api_result(await self.send_ndjson_request(Operation.DEFAULT_VEILID_CONFIG))
|
||||||
|
|
||||||
|
|
||||||
######################################################
|
######################################################
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ class Operation(StrEnum):
|
|||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
VEILID_VERSION_STRING = "VeilidVersionString"
|
VEILID_VERSION_STRING = "VeilidVersionString"
|
||||||
VEILID_VERSION = "VeilidVersion"
|
VEILID_VERSION = "VeilidVersion"
|
||||||
|
DEFAULT_VEILID_CONFIG = "DefaultVeilidConfig"
|
||||||
|
|
||||||
|
|
||||||
class RoutingContextOperation(StrEnum):
|
class RoutingContextOperation(StrEnum):
|
||||||
|
@ -2349,6 +2349,24 @@
|
|||||||
"minimum": 0.0
|
"minimum": 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"op",
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"op": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"DefaultVeilidConfig"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -1499,6 +1499,20 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"op"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"op": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"DefaultVeilidConfig"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -1624,3 +1624,8 @@ pub fn veilid_version() -> JsValue {
|
|||||||
};
|
};
|
||||||
<JsValue as JsValueSerdeExt>::from_serde(&vv).unwrap()
|
<JsValue as JsValueSerdeExt>::from_serde(&vv).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen()]
|
||||||
|
pub fn default_veilid_config() -> String {
|
||||||
|
veilid_core::default_veilid_config()
|
||||||
|
}
|
||||||
|
@ -178,4 +178,9 @@ impl VeilidClient {
|
|||||||
pub fn versionString() -> String {
|
pub fn versionString() -> String {
|
||||||
veilid_core::veilid_version_string()
|
veilid_core::veilid_version_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the default veilid configuration in json string format.
|
||||||
|
pub fn defaultConfig() -> String {
|
||||||
|
veilid_core::default_veilid_config()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,19 @@ describe('veilidClient', () => {
|
|||||||
expect(version.length).toBeGreaterThan(0);
|
expect(version.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should get config string', async () => {
|
||||||
|
const defaultConfig = veilidClient.defaultConfig();
|
||||||
|
expect(typeof defaultConfig).toBe('string');
|
||||||
|
expect(defaultConfig.length).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const cfgObject1 = JSON.parse(defaultConfig);
|
||||||
|
const defaultConfigStr = JSON.stringify(cfgObject1);
|
||||||
|
const cfgObject2 = JSON.parse(defaultConfigStr);
|
||||||
|
const defaultConfigStr2 = JSON.stringify(cfgObject2);
|
||||||
|
|
||||||
|
expect(defaultConfigStr).toEqual(defaultConfigStr2);
|
||||||
|
});
|
||||||
|
|
||||||
it('should attach and detach', async () => {
|
it('should attach and detach', async () => {
|
||||||
await veilidClient.attach();
|
await veilidClient.attach();
|
||||||
await waitForMs(2000);
|
await waitForMs(2000);
|
||||||
|
Loading…
Reference in New Issue
Block a user