Skip to content

Commit

Permalink
test: ensure float value is an allotment function base case
Browse files Browse the repository at this point in the history
  • Loading branch information
lapets committed Feb 20, 2025
1 parent 8fd115b commit fdc0276
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nillion/nilql",
"version": "0.0.0-alpha.11",
"version": "0.0.0-alpha.12",
"description": "Library for working with encrypted data within NilDB queries and replies.",
"license": "MIT",
"homepage": "https://github.com/nillionnetwork/nilql-ts",
Expand Down
4 changes: 2 additions & 2 deletions src/nilql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,8 @@ async function decrypt(
function allot(document: object): object[] {
// Values and `null` are base cases.
if (
typeof document === "number" ||
typeof document === "boolean" ||
typeof document === "number" ||
typeof document === "string" ||
document === null
) {
Expand Down Expand Up @@ -975,7 +975,7 @@ function allot(document: object): object[] {
}

throw new TypeError(
"number, boolean, string, array, null, or object expected",
"boolean, number, string, array, null, or object expected",
);
}

Expand Down
6 changes: 4 additions & 2 deletions tests/nilql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,13 +979,14 @@ describe("end-to-end workflows involving share allotment and unification", () =>
});

test("allotment and unification of objects with nested arrays of shares for a multi-node cluster", async () => {
const data: { [k: string]: object | null } = {
const data: { [k: string]: object | null | number } = {
a: [1n, [2n, 3n]],
b: [4n, [5n, 6n]],
c: null,
d: 1.23,
};
const secretKey = await nilql.SecretKey.generate(cluster, { store: true });
const encrypted: { [k: string]: object | null } = {};
const encrypted: { [k: string]: object | null | number } = {};
for (const key of ["a", "b"]) {
encrypted[key] = {
"%allot": [
Expand All @@ -1004,6 +1005,7 @@ describe("end-to-end workflows involving share allotment and unification", () =>
};
}
encrypted.c = null;
encrypted.d = 1.23;
const shares = nilql.allot(encrypted) as Array<{
[key: string]: string | object;
}>;
Expand Down

0 comments on commit fdc0276

Please sign in to comment.