| 2 | import path from "path"; |
| 3 | |
| 4 | async function testBlobs() { |
| 5 | const dataDirectoryIndex = process.argv.indexOf("-D") + 1; |
| 6 | if (dataDirectoryIndex <= 0) { |
| 7 | throw new Error("Please provide path to a blobs file using -D"); |
| 8 | } |
| 9 | const dataDirectory = process.argv[dataDirectoryIndex]; |
| 10 | const blobs = JSON.parse(await readFile(path.join(dataDirectory, "Data", "WasmSceneManager", "simple.blobs.json"))); |
| 11 | const vtkWASM = await globalThis.createVTKWASM({}) |
| 12 | const remoteSession = new vtkWASM.vtkRemoteSession(); |
| 13 | |
| 14 | for (let hash in blobs) { |
| 15 | if (!remoteSession.registerBlob(hash, new Uint8Array(blobs[hash].bytes))) { |
| 16 | throw new Error(`Failed to register blob with hash=${hash}`); |
| 17 | } |
| 18 | } |
| 19 | for (let hash in blobs) { |
| 20 | const blob = remoteSession.getBlob(hash); |
| 21 | if (!(blob instanceof Uint8Array)) { |
| 22 | throw new Error(`getBlob did not return a Uint8Array for hash=${hash}`); |
| 23 | } |
| 24 | if (blob.toString() !== blobs[hash].bytes.toString()) { |
| 25 | throw new Error(`blob for hash=${hash} does not match registered blob.`); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | const tests = [ |
| 31 | { |