Skip to content

Commit

Permalink
Remove invalid ping extension error
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML authored and ScottyPoi committed Feb 3, 2025
1 parent 315a209 commit 8369727
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 31 deletions.
13 changes: 0 additions & 13 deletions packages/portalnetwork/src/networks/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,6 @@ export abstract class BaseNetwork extends EventEmitter {

handlePing = async (src: INodeAddress, id: bigint, pingMessage: PingMessage) => {
if (!this.routingTable.getWithPending(src.nodeId)?.value) {
if (
pingMessage.payloadType !== PingPongPayloadExtensions.CLIENT_INFO_RADIUS_AND_CAPABILITIES
) {
const customPayload = ErrorPayload.serialize({
errorCode: PingPongErrorCodes.EXTENSION_NOT_SUPPORTED,
message: hexToBytes(
fromAscii(
`First PING message must be type 0: CLIENT_INFO_RADIUS_AND_CAPABILITIES. Received type ${pingMessage.payloadType}`,
),
),
})
return this.sendPong(src, id, customPayload, PingPongPayloadExtensions.ERROR_RESPONSE)
}
// Check to see if node is already in corresponding network routing table and add if not
const enr = this.findEnr(src.nodeId)
if (enr !== undefined) {
Expand Down
18 changes: 0 additions & 18 deletions packages/portalnetwork/test/integration/pingpong.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,6 @@ describe('PING/PONG', async () => {
)
}
})
it('should respond with ERROR_RESPONSE to type !== 0 PING from unknown node', async () => {
const pingPayload = network1.pingPongPayload(PingPongPayloadExtensions.HISTORY_RADIUS_PAYLOAD)
const pingMsg = {
enrSeq: 1n,
payloadType: PingPongPayloadExtensions.HISTORY_RADIUS_PAYLOAD,
customPayload: pingPayload,
}
const network1NodeAddress: INodeAddress = {
nodeId: node1.discv5.enr.nodeId,
socketAddr: initMa,
}
const pong = await network2.handlePing(network1NodeAddress, 1234n, pingMsg)
const pongMsg = PortalWireMessageType.deserialize(pong)
// const pongPayload = HistoryRadius.deserialize(
// (<any>pongMsg.value).customPayload,
// )
assert.equal((<any>pongMsg.value).payloadType, PingPongPayloadExtensions.ERROR_RESPONSE)
})
it('should exchange type 0 PING/PONG', async () => {
const pingpong = await network1.sendPing(network2?.enr!.toENR(), 0)
assert.exists(pingpong, 'should have received a pong')
Expand Down

0 comments on commit 8369727

Please sign in to comment.