-
Notifications
You must be signed in to change notification settings - Fork 39
feat: add TLSNotary alpha.15 proving modes #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d7a596c
feat: add TLSNotary alpha.15 proving modes
Step7750 a4c5f30
fix: route alpha.15 clients through the v15 path
Step7750 90e258e
chore: consume the published alpha.15 WASM package
Step7750 5475bfc
chore: leave extension versioning to release automation
Step7750 ef5c43f
Merge branch 'master' into feat/tlsn-alpha15-migration
Step7750 0c2fdbc
fix comment
Step7750 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import {afterEach, beforeEach, describe, expect, it} from 'vitest'; | ||
| import {WebSocketIoChannel} from './io_channel'; | ||
|
|
||
| class FakeWebSocket extends EventTarget { | ||
| static readonly CONNECTING = 0; | ||
| static readonly OPEN = 1; | ||
| static readonly CLOSING = 2; | ||
| static readonly CLOSED = 3; | ||
| static latest?: FakeWebSocket; | ||
|
|
||
| readonly sent: Uint8Array[] = []; | ||
| binaryType: BinaryType = 'blob'; | ||
| readyState = FakeWebSocket.CONNECTING; | ||
|
|
||
| constructor(readonly url: string) { | ||
| super(); | ||
| FakeWebSocket.latest = this; | ||
| } | ||
|
|
||
| open(): void { | ||
| this.readyState = FakeWebSocket.OPEN; | ||
| this.dispatchEvent(new Event('open')); | ||
| } | ||
|
|
||
| message(data: ArrayBuffer): void { | ||
| const event = new Event('message'); | ||
| Object.defineProperty(event, 'data', {value: data}); | ||
| this.dispatchEvent(event); | ||
| } | ||
|
|
||
| send(data: ArrayBufferView | ArrayBuffer): void { | ||
| const bytes = | ||
| data instanceof ArrayBuffer | ||
| ? new Uint8Array(data) | ||
| : new Uint8Array(data.buffer, data.byteOffset, data.byteLength); | ||
| this.sent.push(new Uint8Array(bytes)); | ||
| } | ||
|
|
||
| close(): void { | ||
| if (this.readyState === FakeWebSocket.CLOSED) { | ||
| return; | ||
| } | ||
| this.readyState = FakeWebSocket.CLOSED; | ||
| this.dispatchEvent(new Event('close')); | ||
| } | ||
| } | ||
|
|
||
| const originalWebSocket = globalThis.WebSocket; | ||
|
|
||
| describe('WebSocketIoChannel', () => { | ||
| beforeEach(() => { | ||
| FakeWebSocket.latest = undefined; | ||
| globalThis.WebSocket = FakeWebSocket as unknown as typeof WebSocket; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| globalThis.WebSocket = originalWebSocket; | ||
| }); | ||
|
|
||
| it('rejects when the socket closes before opening', async () => { | ||
| const channelPromise = WebSocketIoChannel.connect('wss://notary.test/verifier'); | ||
| const socket = FakeWebSocket.latest!; | ||
|
|
||
| socket.close(); | ||
|
|
||
| await expect(channelPromise).rejects.toThrow('closed before opening'); | ||
| }); | ||
|
|
||
| it('queues binary messages and returns EOF on close', async () => { | ||
| const channelPromise = WebSocketIoChannel.connect('wss://notary.test/verifier'); | ||
| const socket = FakeWebSocket.latest!; | ||
| socket.open(); | ||
| const channel = await channelPromise; | ||
|
|
||
| socket.message(new Uint8Array([1, 2, 3]).buffer); | ||
| await expect(channel.read()).resolves.toEqual(new Uint8Array([1, 2, 3])); | ||
|
|
||
| const pendingRead = channel.read(); | ||
| socket.close(); | ||
| await expect(pendingRead).resolves.toBeNull(); | ||
| await expect(channel.read()).resolves.toBeNull(); | ||
| }); | ||
|
|
||
| it('preserves write order and rejects writes after close', async () => { | ||
| const channelPromise = WebSocketIoChannel.connect('wss://notary.test/verifier'); | ||
| const socket = FakeWebSocket.latest!; | ||
| socket.open(); | ||
| const channel = await channelPromise; | ||
|
|
||
| await channel.write(new Uint8Array([1])); | ||
| await channel.write(new Uint8Array([2])); | ||
| expect(socket.sent).toEqual([new Uint8Array([1]), new Uint8Array([2])]); | ||
|
|
||
| await channel.close(); | ||
| await expect(channel.write(new Uint8Array([3]))).rejects.toThrow('closed'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.