This commit is contained in:
parent
3c09493b00
commit
e939714557
34 changed files with 5752 additions and 628 deletions
|
|
@ -9,16 +9,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|||
const wasmPath = path.resolve(__dirname, "../wasm/pkg/mtp_wasm_bg.wasm");
|
||||
const wasmBytes = fs.readFileSync(wasmPath);
|
||||
const wasmModule = new WebAssembly.Module(wasmBytes);
|
||||
initSync(wasmModule);
|
||||
initSync({ module: wasmModule });
|
||||
|
||||
const relayFixtureCreatedAtMillis = BigInt(
|
||||
fs
|
||||
.readFileSync(
|
||||
path.resolve(__dirname, "../fixtures/relay-created-at-ms.txt"),
|
||||
"utf8",
|
||||
)
|
||||
.trim(),
|
||||
);
|
||||
const relayCreatedAtMillis = 1720000000123n;
|
||||
|
||||
const sdk = await import("../dist/sdk/index.js");
|
||||
const { MTPRatchet } = await import("../dist/sdk/ratchet.js");
|
||||
|
|
@ -2383,7 +2376,7 @@ await describe("Relay API invariants", async () => {
|
|||
assert.equal(content.data.ExampleType, "inherited-policy");
|
||||
});
|
||||
|
||||
await it("reports the shared relay CreatedAt fixture as bigint", async () => {
|
||||
await it("preserves relay CreatedAt milliseconds as bigint", async () => {
|
||||
const senderKeyring = sdk.crypto.generateKeyring();
|
||||
const recipientKeyring = sdk.crypto.generateKeyring();
|
||||
const frame = sdk.codec.decode(
|
||||
|
|
@ -2394,7 +2387,7 @@ await describe("Relay API invariants", async () => {
|
|||
42n,
|
||||
42n,
|
||||
"message-generic",
|
||||
relayFixtureCreatedAtMillis,
|
||||
relayCreatedAtMillis,
|
||||
bindings.encode_data_value({ ExampleType: "opaque-to-content-only-relays" }),
|
||||
senderKeyring,
|
||||
bindings.mtp_protection_signature_suite_dual(),
|
||||
|
|
@ -2418,7 +2411,7 @@ await describe("Relay API invariants", async () => {
|
|||
assert.equal(metadata.signerId, 11n);
|
||||
assert.equal(metadata.finalRecipientId, 42n);
|
||||
assert.equal(metadata.messageId, "message-generic");
|
||||
assert.equal(metadata.createdAt, relayFixtureCreatedAtMillis);
|
||||
assert.equal(metadata.createdAt, relayCreatedAtMillis);
|
||||
assert.deepEqual(metadata.metadata, {
|
||||
ExampleType: "opaque-to-content-only-relays",
|
||||
});
|
||||
|
|
@ -2430,7 +2423,7 @@ await describe("Relay API invariants", async () => {
|
|||
signerId: 11n,
|
||||
finalRecipientId: 42n,
|
||||
messageId: "message-generic",
|
||||
createdAt: relayFixtureCreatedAtMillis,
|
||||
createdAt: relayCreatedAtMillis,
|
||||
metadata: { ExampleType: "opaque-to-content-only-relays" },
|
||||
});
|
||||
});
|
||||
|
|
|
|||
81
test/package-boundary.mjs
Normal file
81
test/package-boundary.mjs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
import { access, readFile } from "node:fs/promises";
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import { test } from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const repositoryRoot = path.resolve(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"..",
|
||||
);
|
||||
|
||||
async function requireFile(relativePath) {
|
||||
try {
|
||||
await access(path.join(repositoryRoot, relativePath));
|
||||
} catch {
|
||||
assert.fail(`missing release file: ${relativePath}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function readJson(relativePath) {
|
||||
return JSON.parse(
|
||||
await readFile(path.join(repositoryRoot, relativePath), "utf8"),
|
||||
);
|
||||
}
|
||||
|
||||
test("published package boundary contains all release entry points", async () => {
|
||||
const packageJson = await readJson("package.json");
|
||||
const wasmPackageJson = await readJson("wasm/pkg/package.json");
|
||||
|
||||
for (const relativePath of [
|
||||
"dist/raw/index.js",
|
||||
"dist/raw/index.d.ts",
|
||||
"dist/sdk/index.js",
|
||||
"dist/sdk/index.d.ts",
|
||||
"dist/type-map/index.js",
|
||||
"dist/type-map/index.d.ts",
|
||||
"dist/vite/index.js",
|
||||
"dist/vite/index.d.ts",
|
||||
"wasm/pkg/mtp_wasm.js",
|
||||
"wasm/pkg/mtp_wasm.d.ts",
|
||||
"wasm/pkg/mtp_wasm_bg.wasm",
|
||||
]) {
|
||||
await requireFile(relativePath);
|
||||
}
|
||||
|
||||
let wasmIgnoreExists = true;
|
||||
try {
|
||||
await access(path.join(repositoryRoot, "wasm/pkg/.gitignore"));
|
||||
} catch {
|
||||
wasmIgnoreExists = false;
|
||||
}
|
||||
assert.equal(
|
||||
wasmIgnoreExists,
|
||||
false,
|
||||
"wasm/pkg/.gitignore would cause npm pack to omit the WASM files",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
packageJson.version,
|
||||
wasmPackageJson.version,
|
||||
"package and WASM versions must match",
|
||||
);
|
||||
|
||||
const rawModule = await readFile(
|
||||
path.join(repositoryRoot, "dist/raw/index.js"),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(
|
||||
rawModule,
|
||||
/\.\.\/\.\.\/wasm\/pkg\/mtp_wasm\.js/,
|
||||
"dist/raw must point at the packaged WASM module",
|
||||
);
|
||||
|
||||
for (const target of Object.values(packageJson.exports)) {
|
||||
const entry = typeof target === "string" ? target : target.import;
|
||||
await requireFile(entry.replace(/^\.\//, ""));
|
||||
if (typeof target === "object" && target.types) {
|
||||
await requireFile(target.types.replace(/^\.\//, ""));
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue