Commit 5e83d597 authored by Éloïs's avatar Éloïs

[enh] add safe mode and refractor tests

parent d494c219
test.bin
test2.bin
native/target
native/index.node
native/artifacts.json
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -21,13 +21,13 @@ const FROM_3_LINKS_SENTRIES = 3;
const __OUTDISTANCED__ = true;
const __OK__ = false;
testSuite();
testSuite()
function testSuite() {
function newInstance(launchTests) {
function newInstance(launchUnsafeTests) {
return () => {
let wot = addon.newMemoryInstance(3);
launchTests(wot);
launchUnsafeTests(wot);
}
}
......@@ -58,9 +58,9 @@ function testSuite() {
// Add another
should.equal(wot.addNode(), 1);
should.equal(wot.getWoTSize(), 2);
var enabled = wot.getEnabled();
should.equal(enabled.length, 2);
should.equal(enabled[1], 1);
var enabled2 = wot.getEnabled();
should.equal(enabled2.length, 2);
should.equal(enabled2[1], 1);
should.equal(wot.getDisabled().length, 0);
// Add 10 nodes
for (let i = 0; i < 10; i++) {
......@@ -251,7 +251,7 @@ function testSuite() {
it('should drop this instance and create new instance with id zero', function() {
wot.clear();
var wot2 = addon.newMemoryInstance(100);
let wot2 = addon.newMemoryInstance(3);
should.equal(wot2.instanceID, 0);
wot2.clear()
});
......@@ -259,9 +259,8 @@ function testSuite() {
describe('Building a larger WoT', newInstance((wot) => {
before(() => {
/**
* We build WoT:
it('should build a larget WoT', function() {
/* We build WoT:
*
* 0 --> 1 --> 2 --> 4 --> 5 <==> 6 --> 7
* ^
......@@ -281,7 +280,6 @@ function testSuite() {
should.equal(wot.addLink(4, 5), 1);
should.equal(wot.addLink(5, 6), 1);
should.equal(wot.addLink(6, 7), 1);
should.equal(wot.addLink(6, 5), 2);
// 2n level
should.equal(wot.addLink(2, 3), 1);
should.equal(wot.addLink(3, 2), 2);
......@@ -298,7 +296,7 @@ function testSuite() {
return Promise.resolve();
});
it('should have an initial size of 0', function() {
it('should have an initial size of 12', function() {
should.equal(wot.getWoTSize(), 12);
});
......@@ -496,9 +494,10 @@ function testSuite() {
it('should add node, write and read new wot with 13 nodes', function() {
wot.addNode();
wot.setFilePath("test2.bin");
assert.equal(wot.write(), true)
wot.clear();
wot = addon.newFileInstance("test.bin", 3);
wot = addon.newFileInstance("test2.bin", 3);
should.equal(wot.getWoTSize(), 13);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment