Mise à jour de GitLab prévue ce dimanche 25 octobre 2020 à partir de 9h00 CEST | GitLab upgrade planned this Sunday 25rd of October 2020 from 9:00 AM CEST

Commit f9a7afaa authored by Éloïs's avatar Éloïs

improve tests

parent 281f43f8
Pipeline #2006 passed with stage
in 2 minutes and 25 seconds
test.bin
test2.bin
native/target
native/index.node
......
......@@ -55,15 +55,16 @@ module.exports = {
return instance
},
newSafeMemoryInstance: (sigStock) => {
newEmptySafeMemoryInstance: (sigStock) => {
var instance = Object.create(SafeWoTB)
instance.setFilePath("")
instance.setMaxCert(sigStock)
instance.nodes = new Array()
instance.issued_count = new Array()
instance.sources = new Array()
let instance_content = binding.new_safe_empty_instance();
instance.nodes = instance_content.nodes;
instance.issued_count = instance_content.issued_count;
instance.sources = instance_content.sources;
return instance
},
}
};
const UnsafeWoTB = {
......
File added
......@@ -28,7 +28,7 @@ testsSafe()
function testsSafe() {
function newInstance(launchSafeTests) {
return () => {
let wot = addon.newSafeMemoryInstance(3);
let wot = addon.newEmptySafeMemoryInstance(3);
launchSafeTests(wot);
}
}
......@@ -250,14 +250,47 @@ function testsSafe() {
describe('tests open written wot file', newInstance((wot) => {
describe('Building a larger WoT', newInstance((wot) => {
before(() => {
wot = addon.newSafeFileInstance("test.bin", 3);
});
it('should have a wot size of 12', function() {
/*it('should build a larget WoT', function() {
/* We build WoT:
*
* 0 --> 1 --> 2 --> 4 --> 5 <==> 6 --> 7
* ^
* ||
* ##==> 3 <-- 8 <-- 9 <========##
* | ||
* `> 10 <==> 11 <===##
*//*
// Add nodes
for (let i = 0; i < 12; i++) {
should.equal(wot.addNode(), i);
}
// First line
should.equal(wot.addLink(0, 1), 1);
should.equal(wot.addLink(1, 2), 1);
should.equal(wot.addLink(2, 4), 1);
should.equal(wot.addLink(4, 5), 1);
should.equal(wot.addLink(5, 6), 1);
should.equal(wot.addLink(6, 7), 1);
// 2n level
should.equal(wot.addLink(2, 3), 1);
should.equal(wot.addLink(3, 2), 2);
should.equal(wot.addLink(8, 3), 2);
should.equal(wot.addLink(9, 8), 1);
// 3rd level
should.equal(wot.addLink(8, 10), 1);
should.equal(wot.addLink(10, 11), 1);
should.equal(wot.addLink(11, 10), 2);
should.equal(wot.addLink(11, 9), 1);
should.equal(wot.addLink(9, 11), 2);
should.equal(wot.getWoTSize(), 12);
});
return Promise.resolve();
});*/
describe('testing around 2 with d = 1', () => {
......@@ -428,12 +461,23 @@ function testsSafe() {
should.equal(wot.isOutdistanced(2, FROM_3_LINKS_SENTRIES, MAX_DISTANCE_5, 0.01), __OK__);
});
});
}));
describe('tests open written wot file', newInstance((wot) => {
before(() => {
wot = addon.newFileInstance("test.bin", 3);
});
it('should have a wot size of 12', function() {
should.equal(wot.getWoTSize(), 12);
});
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 = addon.newSafeFileInstance("test2.bin", 3);
wot.clear();
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