Skip to content
Snippets Groups Projects
Commit 9d5d804d authored by nanocryk's avatar nanocryk
Browse files

tests

parent 645b16e5
No related branches found
No related tags found
No related merge requests found
......@@ -10,3 +10,5 @@ native/artifacts.json
*.wot
build/
\.vscode/
......@@ -114,7 +114,7 @@ export class MemoryWebOfTrust implements WebOfTrust {
}
resetWoT(): void {
this.wot = new NativeWebOfTrust(this.wot.getMaxCert())
}
}
......@@ -123,8 +123,10 @@ export class AtomicFileWebOfTrust implements WebOfTrust {
filePath: String;
constructor (path: String) {
console.log("before")
this.wot = new NativeWebOfTrust(path);
this.filePath = path;
console.log("after")
}
toFile(path: String): Boolean {
......@@ -217,6 +219,8 @@ export class AtomicFileWebOfTrust implements WebOfTrust {
}
resetWoT(): void {
this.wot = new NativeWebOfTrust(this.wot.getMaxCert())
}
}
var test = new AtomicFileWebOfTrust("test.wot");
\ No newline at end of file
......@@ -4,7 +4,10 @@
extern crate neon;
extern crate duniter_rs_wotb;
use neon::js::{Value, JsInteger, JsString, JsBoolean, JsFunction, JsArray, JsNumber, JsObject, Object};
use std::path::Path;
use neon::js::{Value, JsInteger, JsString, JsBoolean, JsFunction, JsArray, JsNumber, JsObject,
Object};
use neon::js::class::{Class, JsClass};
use neon::mem::Handle;
use neon::vm::{Throw, Lock};
......@@ -29,10 +32,16 @@ declare_types! {
} else if let Some(path) = arg0.downcast::<JsString>() {
let path = path.value();
if !Path::new(&path).exists() {
let wot = WebOfTrust::new(0);
wot.to_file(&path);
Ok(wot)
} else {
match WebOfTrust::from_file(path.as_str()) {
Some(wot) => Ok(wot),
None => Err(Throw),
}
}
} else {
Err(Throw)
}
......
......@@ -6,7 +6,7 @@ var assert = require('assert');
var path = require('path');
var fs = require('fs');
const FILE = path.join(__dirname, 'wot.bin');
const FILE = path.join(__dirname, 'wot.wot');
const X_PERCENT = 1.0;
const _100_PERCENT = 1.0;
const MAX_DISTANCE_1 = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment