Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wotb-rs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
typescript
wotb-rs
Commits
252a4597
Commit
252a4597
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[enh] add method newEmptyFileInstance()
parent
1fc75139
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/index.js
+8
-0
8 additions, 0 deletions
lib/index.js
tests/test.js
+28
-0
28 additions, 0 deletions
tests/test.js
with
36 additions
and
0 deletions
lib/index.js
+
8
−
0
View file @
252a4597
...
@@ -18,6 +18,14 @@ module.exports = {
...
@@ -18,6 +18,14 @@ module.exports = {
return
instance
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
)
=>
{
newMemoryInstance
:
(
sigStock
)
=>
{
const
instance
=
Object
.
create
(
WotB
)
const
instance
=
Object
.
create
(
WotB
)
const
id
=
binding
.
new_memory_instance
(
sigStock
);
const
id
=
binding
.
new_memory_instance
(
sigStock
);
...
...
This diff is collapsed.
Click to expand it.
tests/test.js
+
28
−
0
View file @
252a4597
...
@@ -6,6 +6,7 @@ var fs = require('fs');
...
@@ -6,6 +6,7 @@ var fs = require('fs');
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
should
=
require
(
'
should
'
);
var
should
=
require
(
'
should
'
);
const
EMPTY_FILE
=
path
.
join
(
__dirname
,
'
wotb.bin
'
);
const
FILE
=
path
.
join
(
__dirname
,
'
g1_genesis.bin
'
);
const
FILE
=
path
.
join
(
__dirname
,
'
g1_genesis.bin
'
);
const
X_PERCENT
=
1.0
;
const
X_PERCENT
=
1.0
;
const
_100_PERCENT
=
1.0
;
const
_100_PERCENT
=
1.0
;
...
@@ -479,6 +480,33 @@ function testSuite() {
...
@@ -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
)
=>
{
describe
(
'
tests g1 genesis wot
'
,
newInstance
((
wot
)
=>
{
before
(()
=>
{
before
(()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment