Skip to content

Commit

Permalink
Resolve access errors from doc build process (#2898)
Browse files Browse the repository at this point in the history
  • Loading branch information
scorbajio committed Jul 18, 2023
1 parent 8946609 commit 9fec1f4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
19 changes: 11 additions & 8 deletions packages/devp2p/test/integration/rlpx-simulator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/devp2p/test/integration/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions packages/devp2p/test/rlpx-ecies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
})
Expand All @@ -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')
})
Expand All @@ -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')
})
Expand Down

0 comments on commit 9fec1f4

Please sign in to comment.