From 9fec1f405a36e94d176e6cc4b497fc0afbdaea71 Mon Sep 17 00:00:00 2001 From: Scorbajio Date: Tue, 18 Jul 2023 12:15:19 -0700 Subject: [PATCH] Resolve access errors from doc build process (#2898) --- .../test/integration/rlpx-simulator.spec.ts | 19 ++++++++++-------- packages/devp2p/test/integration/util.ts | 2 +- packages/devp2p/test/rlpx-ecies.spec.ts | 20 +++++++++---------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/devp2p/test/integration/rlpx-simulator.spec.ts b/packages/devp2p/test/integration/rlpx-simulator.spec.ts index 8213fdc3fa..9e1eac148f 100644 --- a/packages/devp2p/test/integration/rlpx-simulator.spec.ts +++ b/packages/devp2p/test/integration/rlpx-simulator.spec.ts @@ -34,11 +34,14 @@ describe('RLPx simulator tests', () => { tcpPort: null, } assert.notOk( - rlpxs[0]._dpt!.banlist.has(peer), + rlpxs[0]['_dpt']!['_banlist'].has(peer), 'should not be in ban list before bad peer discovered' ) - rlpxs[0]._dpt!.emit('peer:new', peer) - assert.ok(rlpxs[0]._dpt!.banlist.has(peer), 'should be in ban list after bad peer discovered') + rlpxs[0]['_dpt']!.emit('peer:new', peer) + assert.ok( + rlpxs[0]['_dpt']!['_banlist'].has(peer), + 'should be in ban list after bad peer discovered' + ) await util.delay(500) util.destroyRLPXs(rlpxs) }) @@ -70,22 +73,22 @@ describe('RLPx simulator tests', () => { const basePort = 60661 const rlpxs = util.getTestRLPXs(3, 1, basePort) const peer = { address: util.localhost, udpPort: basePort + 1, tcpPort: basePort + 1 } - rlpxs[0]._dpt!.addPeer(peer) + rlpxs[0]['_dpt']!.addPeer(peer) try { rlpxs[0].on('peer:added', async (peer) => { if (peer._socket._peername.port === basePort + 1) { - assert.equal(rlpxs[0]._peersQueue.length, 0, 'peers queue should contain no peers') + assert.equal(rlpxs[0]['_peersQueue'].length, 0, 'peers queue should contain no peers') const peer2 = { address: util.localhost, udpPort: basePort + 2, tcpPort: basePort + 2, } - rlpxs[0]._dpt!.addPeer(peer2) + rlpxs[0]['_dpt']!.addPeer(peer2) await util.delay(500) - assert.equal(rlpxs[0]._peersQueue.length, 1, 'peers queue should contain one peer') + assert.equal(rlpxs[0]['_peersQueue'].length, 1, 'peers queue should contain one peer') } if (peer._socket._peername.port === basePort + 2) { - assert.equal(rlpxs[0]._peersQueue.length, 0, 'peers queue should contain no peers') + assert.equal(rlpxs[0]['_peersQueue'].length, 0, 'peers queue should contain no peers') util.destroyRLPXs(rlpxs) } }) diff --git a/packages/devp2p/test/integration/util.ts b/packages/devp2p/test/integration/util.ts index 7316e78704..4a5913a83a 100644 --- a/packages/devp2p/test/integration/util.ts +++ b/packages/devp2p/test/integration/util.ts @@ -106,7 +106,7 @@ export function initTwoPeerRLPXSetup( ) { const rlpxs = getTestRLPXs(2, maxPeers, basePort, capabilities, common) const peer = { address: localhost, udpPort: basePort + 1, tcpPort: basePort + 1 } - rlpxs[0]._dpt!.addPeer(peer).catch(() => { + rlpxs[0]['_dpt']!.addPeer(peer).catch(() => { /* Silently catch rejections here since not an actual test error */ }) return rlpxs diff --git a/packages/devp2p/test/rlpx-ecies.spec.ts b/packages/devp2p/test/rlpx-ecies.spec.ts index 7b3808aef6..fc67c63fbf 100644 --- a/packages/devp2p/test/rlpx-ecies.spec.ts +++ b/packages/devp2p/test/rlpx-ecies.spec.ts @@ -72,12 +72,12 @@ it( randomBefore((t: EciesTestContext) => { assert.doesNotThrow(() => { const auth = t.context.a.createAuthNonEIP8() - t.context.b._gotEIP8Auth = false + t.context.b['_gotEIP8Auth'] = false t.context.b.parseAuthPlain(auth as Uint8Array) }, 'should not throw on auth creation/parsing') assert.doesNotThrow(() => { - t.context.b._gotEIP8Ack = false + t.context.b['_gotEIP8Ack'] = false const ack = t.context.b.createAckOld() t.context.a.parseAckPlain(ack as Uint8Array) }, 'should not throw on ack creation/parsing') @@ -97,13 +97,13 @@ it( randomBefore((t: EciesTestContext) => { assert.doesNotThrow(() => { const auth = t.context.a.createAuthEIP8() - t.context.b._gotEIP8Auth = true + t.context.b['_gotEIP8Auth'] = true t.context.b.parseAuthEIP8(auth as Uint8Array) }, 'should not throw on auth creation/parsing') assert.doesNotThrow(() => { const ack = t.context.b.createAckEIP8() - t.context.a._gotEIP8Ack = true + t.context.a['_gotEIP8Ack'] = true t.context.a.parseAckEIP8(ack as Uint8Array) }, 'should not throw on ack creation/parsing') }) @@ -113,13 +113,13 @@ it( 'Testdata: auth -> ack (old format/no EIP8)', testdataBefore((t: EciesTestContext) => { assert.doesNotThrow(() => { - t.context.b._gotEIP8Auth = false + t.context.b['_gotEIP8Auth'] = false t.context.b.parseAuthPlain(t.context.h0?.auth as Uint8Array) - t.context.a._initMsg = t.context.h0?.auth + t.context.a['_initMsg'] = t.context.h0?.auth }, 'should not throw on auth parsing') assert.doesNotThrow(() => { - t.context.a._gotEIP8Ack = false + t.context.a['_gotEIP8Ack'] = false t.context.a.parseAckPlain(t.context.h0?.ack as Uint8Array) }, 'should not throw on ack parsing') }) @@ -129,12 +129,12 @@ it( 'Testdata: auth -> ack (EIP8)', testdataBefore((t: EciesTestContext) => { assert.doesNotThrow(() => { - t.context.b._gotEIP8Auth = true + t.context.b['_gotEIP8Auth'] = true t.context.b.parseAuthEIP8(t.context.h1?.auth as Uint8Array) - t.context.a._initMsg = t.context.h1?.auth + t.context.a['_initMsg'] = t.context.h1?.auth }, 'should not throw on auth parsing') assert.doesNotThrow(() => { - t.context.a._gotEIP8Ack = true + t.context.a['_gotEIP8Ack'] = true t.context.a.parseAckEIP8(t.context.h1?.ack as Uint8Array) }, 'should not throw on ack parsing') })