Make current integration tests pass - Closes #971 and addresses #900 #1048
Conversation
…esult when a peer wants our peer list
…ned at the beginning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create issue for each todo
you added?
Also, there is lint problem
ERROR: (ordered-imports) /home/lisk/workspace/lisk-elements_PR-1048/packages/lisk-p2p/src/peer_discovery.ts[16, 1]: Import sources within a group must be alphabetized.
ERROR: (ordered-imports) /home/lisk/workspace/lisk-elements_PR-1048/packages/lisk-p2p/src/peer_selection.ts[17, 1]: Import sources within a group must be alphabetized.
ERROR: (ordered-imports) /home/lisk/workspace/lisk-elements_PR-1048/packages/lisk-p2p/src/sanitization.ts[18, 10]: Named imports must be alphabetized.
packages/lisk-p2p/src/p2p.ts
Outdated
|
||
private _nodeInfo: P2PNodeInfo; | ||
private _nodeInfo: P2PNodeInfo | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this undefinable?
shouldn't information always supplied in constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to provide nodeInfo to the constructor but then I think we should be clear about how it's provided to the constructor; maybe by adding an explicit nodeInfo
field. I think this makes sense actually. nodeInfo
will be information which may be used internally by the node and which should be exposed publicly to other nodes.
/* | ||
* Copyright © 2018 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did this file came back? i think name changed to validation
packages/lisk-p2p/test/_setup.ts
Outdated
global.sandbox = sinon.createSandbox({}); | ||
} else { | ||
global.sandbox = sinon.createSandbox({ | ||
useFakeTimers: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe below is cleaner?
global.sandbox = sinon.createSandbox({
useFakeTimers: process.env.USE_REAL_TIMERS !== 'true',
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe its not a good idea to expose isTriedPeer
field to the user as its more low level concept of managing peer bucket. Maybe its better if we could have a separate P2PPeerInfo
without isTriedPeer
and we can extend it to have a internal PeerInfo definition that will hold more fields related to peer bucket management and selection algo like isBannedPeer
from LIP
@ishantiw About |
…andom subset of peers to send back
…tried peers; that is a higher level concern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
What was the problem?
Core integration tests related to launching a node, connecting to seed peers and doing the first round of discovery were failing. We hadn't yet brought the node into a verifiable working state.
How did I fix it?
getNetworkStatus
).P2PPeerInfo
andP2PNodeInfo
to be more generic; added anoptions
field which can be used to specify custom fields/values onP2PPeerInfo
/P2PNodeInfo
objects. This allows the P2P module to support more different kinds of applications.P2PNodeInfo
andP2PPeerInfo
throughoutP2P -> PeerPool -> Peer
.TODO
comments.selectForConnection
work withP2PPeerInfo
objects instead ofPeer
objects; it doesn't make sense to filterPeer
objects if we are yet to connect to them; it forced us to instantiatePeer
objects before we needed them. We should think about other selection functions as well if we want to useP2PPeerInfo
instead ofPeer
; theP2PPeerInfo
is safer to expose to users but may offer less control/flexibility in certain scenarios.selectPeers
function is now used by thelist
endpoint because we can't send back our full peer list and theselectPeers
function seemed like a good way to do that type of filtering. As a result of this,selectPeers
was changed to only return tried peers for which we have complete info.How to test it?
npm run test:integration
Review checklist