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
1559b78e
Commit
1559b78e
authored
5 years ago
by
Cédric Moreau
Committed by
Éloïs
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1394
: add the test revealing the bug (joining with < sigQty valid certs)
parent
05818d14
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/integration/fork-resolution/coming-back-with-less-than-sigqty.ts
+97
-0
97 additions, 0 deletions
...tion/fork-resolution/coming-back-with-less-than-sigqty.ts
with
97 additions
and
0 deletions
test/integration/fork-resolution/coming-back-with-less-than-sigqty.ts
0 → 100644
+
97
−
0
View file @
1559b78e
// Source file from duniter: Crypto-currency software to manage libre currency such as Ğ1
// Copyright (C) 2018 Cedric Moreau <cem.moreau@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
import
{
assertEqual
,
writeBasicTestWithConfAnd2Users
}
from
"
../tools/test-framework
"
import
{
CommonConstants
}
from
"
../../../app/lib/common-libs/constants
"
const
currentVersion
=
CommonConstants
.
BLOCK_GENESIS_VERSION
describe
(
'
A member coming back with less than `sigQty` valid certs total
'
,
()
=>
writeBasicTestWithConfAnd2Users
({
sigQty
:
2
,
sigReplay
:
0
,
sigPeriod
:
0
,
sigValidity
:
10
,
dtDiffEval
:
1
,
forksize
:
0
,
},
(
test
)
=>
{
const
now
=
1500000000
test
(
'
(t = 0) should init with a 3 members WoT with bidirectionnal certs
'
,
async
(
s1
,
cat
,
tac
,
toc
)
=>
{
CommonConstants
.
BLOCK_GENESIS_VERSION
=
11
await
cat
.
createIdentity
()
await
tac
.
createIdentity
()
await
toc
.
createIdentity
()
await
cat
.
cert
(
tac
)
await
cat
.
cert
(
toc
)
await
tac
.
cert
(
cat
)
await
tac
.
cert
(
toc
)
await
toc
.
cert
(
cat
)
await
toc
.
cert
(
tac
)
await
cat
.
join
()
await
tac
.
join
()
await
toc
.
join
()
const
b0
=
await
s1
.
commit
({
time
:
now
})
assertEqual
(
b0
.
certifications
.
length
,
6
)
const
b1
=
await
s1
.
commit
({
time
:
now
})
assertEqual
(
b1
.
membersCount
,
3
)
})
test
(
'
(t = 5) cat & tac certify each other
'
,
async
(
s1
,
cat
,
tac
,
toc
)
=>
{
await
s1
.
commit
({
time
:
now
+
5
})
await
s1
.
commit
({
time
:
now
+
5
})
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
500
))
// cat and tac certify each other to stay in the WoT
await
tac
.
cert
(
cat
)
await
toc
.
cert
(
cat
)
// <-- toc adds the 2nd certification
const
b1
=
await
s1
.
commit
({
time
:
now
+
6
})
assertEqual
(
b1
.
certifications
.
length
,
2
)
await
cat
.
cert
(
tac
)
await
toc
.
cert
(
tac
)
// <-- toc adds the 2nd certification
const
b2
=
await
s1
.
commit
({
time
:
now
+
6
})
assertEqual
(
b2
.
certifications
.
length
,
2
)
// // /!\/!\/!\
// // toc gets certified by cat, to a have a remaining valid certification in the blockchain: THIS WONT BE ENOUGH!
await
cat
.
cert
(
toc
)
// // /!\/!\/!\
const
b4
=
await
s1
.
commit
({
time
:
now
+
6
})
assertEqual
(
b4
.
certifications
.
length
,
1
)
})
test
(
'
(t = 12) toc is excluded for lack of certifications
'
,
async
(
s1
,
cat
,
tac
,
toc
)
=>
{
await
s1
.
commit
({
time
:
now
+
12
})
await
s1
.
commit
({
time
:
now
+
12
})
const
b
=
await
s1
.
commit
({
time
:
now
+
12
})
assertEqual
(
b
.
excluded
.
length
,
1
)
assertEqual
(
b
.
excluded
[
0
],
toc
.
pub
)
})
test
(
'
(t = 13 #1) toc is coming back with 1 cert only! a renewal counted twice
'
,
async
(
s1
,
cat
,
tac
,
toc
)
=>
{
await
s1
.
commit
({
time
:
now
+
13
})
await
s1
.
commit
({
time
:
now
+
13
})
const
c1
=
await
cat
.
makeCert
(
toc
)
// <-- a renewal ==> this is what we want to observe
const
join
=
await
toc
.
makeMembership
(
'
IN
'
)
const
b
=
await
s1
.
commit
({
time
:
now
+
13
,
joiners
:
[
join
],
certifications
:
[
c1
]
})
assertEqual
(
b
.
membersCount
,
3
)
assertEqual
(
b
.
number
,
12
)
})
after
(()
=>
{
CommonConstants
.
BLOCK_GENESIS_VERSION
=
currentVersion
})
}))
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