Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
afd605a2
Commit
afd605a2
authored
1 year ago
by
Benoit Lavenier
Browse files
Options
Downloads
Patches
Plain Diff
fix(1447): Sindex not well trimmed
parent
ef5707e6
No related branches found
No related tags found
No related merge requests found
Pipeline
#32304
failed
1 year ago
Stage: tests
Stage: package
Stage: integration
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/dal/triming-dal.ts
+23
-7
23 additions, 7 deletions
test/dal/triming-dal.ts
with
23 additions
and
7 deletions
test/dal/triming-dal.ts
+
23
−
7
View file @
afd605a2
...
...
@@ -130,24 +130,40 @@ describe("Triming", function(){
})
it
(
'
should be able to trim the sindex
'
,
async
()
=>
{
// Triming
const
sindexDAL
=
dal
.
sindexDAL
as
LevelDBSindex
;
// First triming before b#140 => should kept some sources
await
dal
.
trimIndexes
(
140
);
(
await
dal
.
sindexDAL
.
findByIdentifier
(
'
SOURCE_1
'
)).
should
.
have
.
length
(
0
);
(
await
dal
.
sindexDAL
.
getAvailableForConditions
(
'
COND(SOURCE_1)
'
)).
should
.
have
.
length
(
0
);
(
await
dal
.
sindexDAL
.
getAvailableForConditions
(
'
COND(SOURCE_2)
'
)).
should
.
have
.
length
(
1
);
(
await
dal
.
sindexDAL
.
getAvailableForPubkey
(
'
PUB_1
'
)).
should
.
have
.
length
(
1
);
(
await
dal
.
sindexDAL
.
findByPos
(
4
)).
should
.
have
.
length
(
2
);
// Consumed all, then trim again. => All sub indices should be empty
// Check internal index
// FIXME another issue here
/*for (let index of sindexDAL.getInternalIndexes()) {
const res = await index.findAllKeys();
res.should.not.containEql("COND(SOURCE_1)")
res.should.not.containEql("0000000126")
}*/
// Now we consume all sources
await
dal
.
sindexDAL
.
insertBatch
([
{
op
:
'
UPDATE
'
,
identifier
:
'
SOURCE_2
'
,
pos
:
4
,
written_on
:
'
140-H
'
,
writtenOn
:
140
,
written_time
:
5000
,
consumed
:
true
,
conditions
:
'
COND(SOURCE_2)
'
},
{
op
:
'
UPDATE
'
,
identifier
:
'
SOURCE_3
'
,
pos
:
4
,
written_on
:
'
140-H
'
,
writtenOn
:
140
,
written_time
:
5000
,
consumed
:
true
,
conditions
:
'
SIG(PUB_1)
'
}
]
as
any
);
// Second triming => should remove all sources
await
dal
.
trimIndexes
(
141
);
if
(
dal
.
sindexDAL
instanceof
LevelDBSindex
)
{
for
(
let
index
of
dal
.
sindexDAL
.
getInternalIndexes
())
{
const
res
=
await
index
.
findAllKeys
();
res
.
should
.
have
.
length
(
0
,
`index
${
index
[
'
name
'
]}
should have been trimmed`
);
}
(
await
dal
.
sindexDAL
.
getAvailableForConditions
(
'
COND(SOURCE_2)
'
)).
should
.
have
.
length
(
0
);
(
await
dal
.
sindexDAL
.
getAvailableForPubkey
(
'
PUB_1
'
)).
should
.
have
.
length
(
0
);
(
await
dal
.
sindexDAL
.
findByPos
(
4
)).
should
.
have
.
length
(
0
);
// All sub index should be empty
for
(
let
index
of
sindexDAL
.
getInternalIndexes
())
{
const
res
=
await
index
.
findAllKeys
();
res
.
should
.
have
.
length
(
0
,
`index
${
index
[
'
name
'
]}
should have been trimmed`
);
}
})
...
...
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