Skip to content

Commit e559d84

Browse files
committed
chore: use random bytes for echo
Ensures that where bufs are split for sending, they are reassembled in the correct order.
1 parent cbfda2c commit e559d84

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/interface-compliance-tests/src/transport

packages/interface-compliance-tests/src/transport/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { randomBytes } from '@libp2p/crypto'
12
import { stop, TimeoutError } from '@libp2p/interface'
23
import { prefixLogger } from '@libp2p/logger'
34
import { expect } from 'aegir/chai'
@@ -10,6 +11,7 @@ import pRetry from 'p-retry'
1011
import pWaitFor from 'p-wait-for'
1112
import { raceSignal } from 'race-signal'
1213
import { Uint8ArrayList } from 'uint8arraylist'
14+
import { concat as uint8ArrayConcat } from 'uint8arrays'
1315
import { isValidTick } from '../is-valid-tick.js'
1416
import { createPeer, getTransportManager, getUpgrader } from './utils.ts'
1517
import type { TestSetup } from '../index.js'
@@ -333,7 +335,7 @@ export default (common: TestSetup<TransportTestFixtures>): void => {
333335

334336
const connection = await dialer.dial(dialAddrs[0])
335337

336-
const input = new Uint8Array(1024).fill(5)
338+
const input = randomBytes(1024)
337339
const output = await dialer.services.echo.echo(connection.remotePeer, input, {
338340
signal: AbortSignal.timeout(timeout)
339341
})
@@ -349,7 +351,7 @@ export default (common: TestSetup<TransportTestFixtures>): void => {
349351

350352
const connection = await dialer.dial(dialAddrs[0])
351353

352-
const input = new Uint8Array(1024 * 1024 * 10).fill(5)
354+
const input = uint8ArrayConcat(new Array(160).fill(0).map(() => randomBytes(65535)))
353355
const output = await dialer.services.echo.echo(connection.remotePeer, input, {
354356
signal: AbortSignal.timeout(timeout)
355357
})

0 commit comments

Comments
 (0)