Skip to content

Commit cda0024

Browse files
committed
Test raw tunnels with larger chunks & streams
1 parent 48554c1 commit cda0024

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/integration/subscriptions/raw-passthrough-events.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@ nodeOnly(() => {
110110
expect(fourthDataEvent.eventTimestamp).to.be.greaterThan(thirdDataEvent.eventTimestamp);
111111
});
112112

113+
it("should expose large received data", async () => {
114+
const openDeferred = getDeferred<RawPassthroughEvent>();
115+
let receivedDataEvents = [] as RawPassthroughDataEvent[];
116+
117+
await server.on('raw-passthrough-opened', (e) => openDeferred.resolve(e));
118+
await server.on('raw-passthrough-data', (e) => {
119+
if (e.direction === 'received') {
120+
receivedDataEvents.push(e)
121+
}
122+
});
123+
124+
const socksSocket = await openSocksSocket(server, 'localhost', remotePort);
125+
126+
const message = 'hello'.repeat(20_000); // =100KB each
127+
128+
// Write 500KB in 100KB chunks with a brief delay. Larger than one TCP packet (65K)
129+
// in all cases, should cause some weirdness.
130+
for (let i = 0; i < 5; i++) {
131+
socksSocket.write(message);
132+
await delay(0);
133+
}
134+
135+
await openDeferred;
136+
await delay(10);
137+
138+
const totalLength = receivedDataEvents.reduce((sum, e) => sum + e.content.toString().length, 0);
139+
expect(totalLength).to.equal(500_000);
140+
expect(receivedDataEvents[0].content.slice(0, 5).toString()).to.equal('hello');
141+
expect(receivedDataEvents[receivedDataEvents.length - 1].content.slice(-5).toString()).to.equal('hello');
142+
});
143+
113144
describe("with a remote client", () => {
114145
const adminServer = getAdminServer();
115146
const remoteClient = getRemote({

0 commit comments

Comments
 (0)