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
94073df8
Commit
94073df8
authored
7 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1029
blockstamp in raw documents incoherence
parent
9dee9797
No related branches found
No related tags found
1 merge request
!1049
[fix]#1029 blockstamp in raw documents incoherence
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/service/PeeringService.ts
+1
-0
1 addition, 0 deletions
app/service/PeeringService.ts
test/integration/network-update.js
+112
-0
112 additions, 0 deletions
test/integration/network-update.js
test/integration/peers-same-pubkey.js
+40
-0
40 additions, 0 deletions
test/integration/peers-same-pubkey.js
with
153 additions
and
0 deletions
app/service/PeeringService.ts
+
1
−
0
View file @
94073df8
...
@@ -130,6 +130,7 @@ export class PeeringService {
...
@@ -130,6 +130,7 @@ export class PeeringService {
peerEntityOld
.
endpoints
=
thePeer
.
endpoints
peerEntityOld
.
endpoints
=
thePeer
.
endpoints
peerEntityOld
.
status
=
thePeer
.
status
peerEntityOld
.
status
=
thePeer
.
status
peerEntityOld
.
signature
=
thePeer
.
signature
peerEntityOld
.
signature
=
thePeer
.
signature
peerEntityOld
.
blockstamp
=
thePeer
.
block
}
}
// Set the peer as UP again
// Set the peer as UP again
const
peerEntity
=
peerEntityOld
.
toDBPeer
()
const
peerEntity
=
peerEntityOld
.
toDBPeer
()
...
...
This diff is collapsed.
Click to expand it.
test/integration/network-update.js
0 → 100644
+
112
−
0
View file @
94073df8
"
use strict
"
;
const
co
=
require
(
'
co
'
);
const
_
=
require
(
'
underscore
'
);
const
rp
=
require
(
'
request-promise
'
);
const
httpTest
=
require
(
'
./tools/http
'
);
const
node
=
require
(
'
./tools/node
'
);
const
user
=
require
(
'
./tools/user
'
);
const
commit
=
require
(
'
./tools/commit
'
);
const
sync
=
require
(
'
./tools/sync
'
);
const
until
=
require
(
'
./tools/until
'
);
const
toolbox
=
require
(
'
./tools/toolbox
'
);
const
BlockDTO
=
require
(
"
../../app/lib/dto/BlockDTO
"
);
const
expectHttpCode
=
httpTest
.
expectHttpCode
;
const
expectAnswer
=
httpTest
.
expectAnswer
;
const
MEMORY_MODE
=
true
;
const
commonConf
=
{
ipv4
:
'
127.0.0.1
'
,
remoteipv4
:
'
127.0.0.1
'
,
currency
:
'
bb
'
,
httpLogs
:
true
,
forksize
:
3
,
sigQty
:
1
};
const
catKeyPair
=
{
pair
:
{
pub
:
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
,
sec
:
'
51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP
'
}
};
const
tocKeyPair
=
{
pair
:
{
pub
:
'
DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo
'
,
sec
:
'
64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F
'
}
};
const
s1
=
toolbox
.
server
(
_
.
clone
(
catKeyPair
));
const
s2
=
toolbox
.
server
(
_
.
clone
(
tocKeyPair
));
const
cat
=
user
(
'
cat
'
,
{
pub
:
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
,
sec
:
'
51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP
'
},
{
server
:
s1
});
const
toc
=
user
(
'
toc
'
,
{
pub
:
'
DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo
'
,
sec
:
'
64EYRvdPpTfLGGmaX5nijLXRqWXaVz8r1Z1GtaahXwVSJGQRn7tqkxLb288zwSYzELMEG5ZhXSBYSxsTsz1m9y8F
'
},
{
server
:
s1
});
describe
(
"
Network updating
"
,
function
()
{
before
(
function
()
{
return
co
(
function
*
()
{
const
commitS1
=
commit
(
s1
);
const
commitS2
=
commit
(
s2
);
yield
[
s1
,
s2
].
reduce
((
p
,
server
)
=>
co
(
function
*
()
{
yield
p
;
yield
server
.
initDalBmaConnections
()
require
(
'
../../app/modules/router
'
).
duniter
.
methods
.
routeToNetwork
(
server
);
}),
Promise
.
resolve
());
// Server 1
yield
cat
.
createIdentity
();
yield
toc
.
createIdentity
();
yield
toc
.
cert
(
cat
);
yield
cat
.
cert
(
toc
);
yield
cat
.
join
();
yield
toc
.
join
();
for
(
const
i
in
_
.
range
(
32
))
{
yield
commitS1
();
// block#0
}
// // s2 syncs from s1
yield
sync
(
0
,
31
,
s1
,
s2
);
const
b2
=
yield
s1
.
makeNext
({});
yield
s1
.
postBlock
(
b2
);
yield
s2
.
postBlock
(
b2
);
yield
s1
.
recomputeSelfPeer
();
// peer#1
yield
s1
.
sharePeeringWith
(
s2
);
const
b3
=
yield
s1
.
makeNext
({});
yield
s1
.
postBlock
(
b3
);
yield
s2
.
postBlock
(
b3
);
yield
s1
.
recomputeSelfPeer
();
// peer#1
yield
s1
.
sharePeeringWith
(
s2
);
});
});
describe
(
"
Server 1 /network/peering
"
,
function
()
{
it
(
'
/peers?leaf=LEAFDATA
'
,
()
=>
co
(
function
*
()
{
const
data
=
yield
s1
.
get
(
'
/network/peering/peers?leaves=true
'
);
const
leaf
=
data
.
leaves
[
0
];
const
res
=
yield
s1
.
get
(
'
/network/peering/peers?leaf=
'
+
leaf
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
raw
"
).
match
(
new
RegExp
(
'
.*Block: 3-.*
'
));
}));
});
describe
(
"
Server 2 /network/peering
"
,
function
()
{
it
(
'
/peers?leaf=LEAFDATA
'
,
()
=>
co
(
function
*
()
{
const
data
=
yield
s2
.
get
(
'
/network/peering/peers?leaves=true
'
);
const
leaf
=
data
.
leaves
[
0
];
const
res
=
yield
s2
.
get
(
'
/network/peering/peers?leaf=
'
+
leaf
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
DKpQPUL4ckzXYdnDRvCRKAm1gNvSdmAXnTrJZ7LvM5Qo
'
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^0-
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
raw
"
).
match
(
new
RegExp
(
'
.*Block: 0-.*
'
));
}));
});
});
This diff is collapsed.
Click to expand it.
test/integration/peers-same-pubkey.js
+
40
−
0
View file @
94073df8
...
@@ -100,6 +100,24 @@ describe("Peer document", function() {
...
@@ -100,6 +100,24 @@ describe("Peer document", function() {
leavesCount
:
1
leavesCount
:
1
}));
}));
it
(
'
leaf data
'
,
()
=>
co
(
function
*
()
{
const
data
=
yield
s1
.
get
(
'
/network/peering/peers?leaves=true
'
);
const
leaf
=
data
.
leaves
[
0
];
const
res
=
yield
s1
.
get
(
'
/network/peering/peers?leaf=
'
+
leaf
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
raw
"
).
match
(
new
RegExp
(
'
.*Block: 3-.*
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
endpoints
"
).
length
(
3
);
}));
it
(
'
peers
'
,
()
=>
s1
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
should
.
have
.
property
(
"
endpoints
"
).
length
(
3
);
}));
it
(
'
peering should have been updated by node 1
'
,
()
=>
s1
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
it
(
'
peering should have been updated by node 1
'
,
()
=>
s1
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
...
@@ -118,6 +136,18 @@ describe("Peer document", function() {
...
@@ -118,6 +136,18 @@ describe("Peer document", function() {
leavesCount
:
1
leavesCount
:
1
}));
}));
it
(
'
leaf data
'
,
()
=>
co
(
function
*
()
{
const
data
=
yield
s2
.
get
(
'
/network/peering/peers?leaves=true
'
);
const
leaf
=
data
.
leaves
[
0
];
const
res
=
yield
s2
.
get
(
'
/network/peering/peers?leaf=
'
+
leaf
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
raw
"
).
match
(
new
RegExp
(
'
.*Block: 3-.*
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
endpoints
"
).
length
(
3
);
}));
it
(
'
peering should have been updated by node 1
'
,
()
=>
s2
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
it
(
'
peering should have been updated by node 1
'
,
()
=>
s2
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
...
@@ -136,6 +166,16 @@ describe("Peer document", function() {
...
@@ -136,6 +166,16 @@ describe("Peer document", function() {
leavesCount
:
1
leavesCount
:
1
}));
}));
it
(
'
leaf data
'
,
()
=>
co
(
function
*
()
{
const
data
=
yield
s3
.
get
(
'
/network/peering/peers?leaves=true
'
);
const
leaf
=
data
.
leaves
[
0
];
const
res
=
yield
s3
.
get
(
'
/network/peering/peers?leaf=
'
+
leaf
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
leaf
.
value
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
raw
"
).
match
(
new
RegExp
(
'
.*Block: 3-.*
'
));
res
.
leaf
.
value
.
should
.
have
.
property
(
"
endpoints
"
).
length
(
3
);
}));
it
(
'
peering should have been updated by node 1
'
,
()
=>
s3
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
it
(
'
peering should have been updated by node 1
'
,
()
=>
s3
.
expectThat
(
'
/network/peering
'
,
(
res
)
=>
{
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
pubkey
"
).
equal
(
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
);
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
res
.
should
.
have
.
property
(
"
block
"
).
match
(
new
RegExp
(
'
^3-
'
));
...
...
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