Skip to content

Commit

Permalink
add mls wasm + unit test (#1906)
Browse files Browse the repository at this point in the history
let's add this to the main branch

adds a super simple unit test to verify that the imports are working
  • Loading branch information
erikolsson authored Dec 23, 2024
1 parent ca71797 commit 01a8743
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,18 @@
"args": ["run", "${fileBasename}", "--config", "vitest.config.ts"],
"console": "integratedTerminal",
},
{
"name": "Vitest: current file in 'packages/sdk/' (unit)",
"type": "node",
"request": "launch",
"env": { "NODE_ENV": "development", "DEBUG": "csb:*,test:*", "DEBUG_DEPTH":"10" },
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
"cwd": "${workspaceFolder}/packages/sdk",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"smartStep": true,
"args": ["run", "${fileBasename}", "--config", "vitest.config.unit.ts"],
"console": "integratedTerminal",
}
]
}
2 changes: 1 addition & 1 deletion packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"vite": "^5.3.1",
"vite-plugin-checker": "^0.8.0",
"vite-plugin-replace": "^0.1.1",
"vite-plugin-wasm": "^3.3.0",
"vite-plugin-wasm": "^3.4.1",
"vite-tsconfig-paths": "^5.1.3"
}
}
5 changes: 3 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@river-build/dlog": "workspace:^",
"@river-build/encryption": "workspace:^",
"@river-build/generated": "workspace:^",
"@river-build/mls-rs-wasm": "^0.0.7",
"@river-build/mls-rs-wasm": "^0.0.9",
"@river-build/proto": "workspace:^",
"@river-build/web3": "workspace:^",
"browser-or-node": "^3.0.0",
Expand Down Expand Up @@ -61,7 +61,8 @@
"msgpackr": "^1.10.1",
"seedrandom": "^3.0.5",
"typed-emitter": "^2.1.0",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"vite-plugin-wasm": "^3.4.1"
},
"files": [
"/dist"
Expand Down
15 changes: 15 additions & 0 deletions packages/sdk/src/tests/unit/mls.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @group main
*/

import { Client as MlsClient } from '@river-build/mls-rs-wasm'
import { randomBytes } from 'crypto'

describe('mls', () => {
test('initialize mls group', async () => {
const deviceKey = new Uint8Array(randomBytes(32))
const client = await MlsClient.create(deviceKey)
const group = await client.createGroup()
expect(group).toBeDefined()
})
})
7 changes: 7 additions & 0 deletions packages/sdk/vitest.config.unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import wasm from 'vite-plugin-wasm'
import { rootConfig } from '../../vitest.config.mjs'

export default mergeConfig(
Expand All @@ -10,6 +11,12 @@ export default mergeConfig(
hookTimeout: 120_000,
testTimeout: 120_000,
setupFiles: './vitest.setup.ts',
server: {
deps: {
inline: ['@river-build/mls-rs-wasm'],
},
},
},
plugins: [wasm()],
}),
)
25 changes: 13 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6452,7 +6452,7 @@ __metadata:
dependencies:
"@openzeppelin/contracts": ^5.1.0
solady: ^0.0.281
checksum: 2666668787f50af79a76004ccea89798fb362f07eea88557cdcf13a70d1164b2ad58c9278fd19ff5b304d9fc1439d097d57e03676b6c1dfeeb98535dd5059b50
checksum: 3884bdab0e68b6f64293404a8e3670280d5ad6255f905c189121e2c34d210ec7fa3d9ffda67447a08d060c02564591d0ee0923ae9f13a3d71c0ddfd46e898ff7
languageName: node
linkType: hard

Expand Down Expand Up @@ -6549,10 +6549,10 @@ __metadata:
languageName: node
linkType: hard

"@river-build/mls-rs-wasm@npm:^0.0.7":
version: 0.0.7
resolution: "@river-build/mls-rs-wasm@npm:0.0.7"
checksum: 1e91e7b2f9d16562c676e692809cc46d2d88f58afd61990740c5685120ae11fe75c810b1cb8cc4038e93012b732051f394ac47691613d516ea9e46fa40c7b64b
"@river-build/mls-rs-wasm@npm:^0.0.9":
version: 0.0.9
resolution: "@river-build/mls-rs-wasm@npm:0.0.9"
checksum: c0221954de5c0b981f656b497e9b72ac3a3c82cb7810c389f4cb25a84ffb1727718342eafc186edeb1b3d14580ff7a1dfb2fbac576cf792ac1054f04b4659cbb
languageName: node
linkType: hard

Expand Down Expand Up @@ -6611,7 +6611,7 @@ __metadata:
vite-plugin-checker: ^0.8.0
vite-plugin-node-polyfills: ^0.22.0
vite-plugin-replace: ^0.1.1
vite-plugin-wasm: ^3.3.0
vite-plugin-wasm: ^3.4.1
vite-tsconfig-paths: ^5.1.3
wagmi: ^2.13.0
zod: ^3.21.4
Expand Down Expand Up @@ -6693,7 +6693,7 @@ __metadata:
"@river-build/dlog": "workspace:^"
"@river-build/encryption": "workspace:^"
"@river-build/generated": "workspace:^"
"@river-build/mls-rs-wasm": ^0.0.7
"@river-build/mls-rs-wasm": ^0.0.9
"@river-build/proto": "workspace:^"
"@river-build/web3": "workspace:^"
"@testing-library/react": ^14.2.1
Expand Down Expand Up @@ -6722,6 +6722,7 @@ __metadata:
seedrandom: ^3.0.5
typed-emitter: ^2.1.0
typescript: ^5.1.6
vite-plugin-wasm: ^3.4.1
vitest: ^2.1.5
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -29868,12 +29869,12 @@ __metadata:
languageName: node
linkType: hard

"vite-plugin-wasm@npm:^3.3.0":
version: 3.3.0
resolution: "vite-plugin-wasm@npm:3.3.0"
"vite-plugin-wasm@npm:^3.4.1":
version: 3.4.1
resolution: "vite-plugin-wasm@npm:3.4.1"
peerDependencies:
vite: ^2 || ^3 || ^4 || ^5
checksum: 844034955d6650f89988eebb543e4b3307a54d7b800365052f5b97683223d3b99640ecb22d1fd770e768239576629d975bdefc0c9545999564e206b331f0ac3b
vite: ^2 || ^3 || ^4 || ^5 || ^6
checksum: 50176a45ae9c185bab8922874d7ab74e85a008cc4896cfff3f2b155c482d8efb5caa50559f0458b1974ac374e52787fa1e979af870a083eedb81a3f512c65b1d
languageName: node
linkType: hard

Expand Down

0 comments on commit 01a8743

Please sign in to comment.