Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wotb-rs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nodes
typescript
wotb-rs
Commits
252a4597
Commit
252a4597
authored
Apr 24, 2018
by
Éloïs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[enh] add method newEmptyFileInstance()
parent
1fc75139
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
lib/index.js
lib/index.js
+8
-0
tests/test.js
tests/test.js
+28
-0
No files found.
lib/index.js
View file @
252a4597
...
...
@@ -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
);
...
...
tests/test.js
View file @
252a4597
...
...
@@ -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
(()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment