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 252a4597 authored by Éloïs's avatar Éloïs

[enh] add method newEmptyFileInstance()

parent 1fc75139
......@@ -18,6 +18,14 @@ module.exports = {
return instance
},
newEmptyFileInstance: (filePath, sigStock) => {
const instance = Object.create(WotB)
const id = binding.new_memory_instance(sigStock);
instance.init(id)
instance.setFilePath(filePath)
return instance
},
newMemoryInstance: (sigStock) => {
const instance = Object.create(WotB)
const id = binding.new_memory_instance(sigStock);
......
......@@ -6,6 +6,7 @@ var fs = require('fs');
var path = require('path');
var should = require('should');
const EMPTY_FILE = path.join(__dirname, 'wotb.bin');
const FILE = path.join(__dirname, 'g1_genesis.bin');
const X_PERCENT = 1.0;
const _100_PERCENT = 1.0;
......@@ -479,6 +480,33 @@ function testSuite() {
});
}));
describe('tests open written wot file', newInstance((wot) => {
before(() => {
wot.clear();
wot = addon.newFileInstance("test.bin", 3);
});
it('should have an instanceID zero', function() {
assert.equal(wot.instanceID, 0)
});
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();
assert.equal(wot.write(), true)
wot.clear();
wot = addon.newFileInstance("test.bin", 3);
should.equal(wot.getWoTSize(), 13);
});
after(() => {
wot.clear();
});
}));
describe('tests g1 genesis wot', newInstance((wot) => {
before(() => {
......
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