Test that the zkgroup serverPublicParams are up to date
This commit is contained in:
parent
0b5d643b9a
commit
d15ae63396
1 changed files with 38 additions and 0 deletions
38
ts/test-node/util/zkgroup_test.ts
Normal file
38
ts/test-node/util/zkgroup_test.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright 2022 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { assert } from 'chai';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { ServerPublicParams } from '@signalapp/libsignal-client/zkgroup';
|
||||||
|
|
||||||
|
describe('zkgroup', () => {
|
||||||
|
describe('serverPublicParams', () => {
|
||||||
|
const configDir = 'config';
|
||||||
|
|
||||||
|
for (const file of fs.readdirSync(configDir)) {
|
||||||
|
if (!file.endsWith('.json')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const contents = fs.readFileSync(path.join(configDir, file), {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
});
|
||||||
|
const serverPublicParamsBase64: string | undefined =
|
||||||
|
JSON.parse(contents).serverPublicParams;
|
||||||
|
|
||||||
|
let test: (() => void) | undefined;
|
||||||
|
if (serverPublicParamsBase64 !== undefined) {
|
||||||
|
test = () => {
|
||||||
|
const serverPublicParams = new ServerPublicParams(
|
||||||
|
Buffer.from(serverPublicParamsBase64, 'base64')
|
||||||
|
);
|
||||||
|
assert(serverPublicParams);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Mark as "pending" / skipped to show we didn't miss a file.
|
||||||
|
test = undefined;
|
||||||
|
}
|
||||||
|
it(`valid in ${file}`, test);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue