2022-04-11 15:08:15 +00:00
|
|
|
import blst from "../src/blst-native/index.js";
|
|
|
|
import herumi from "../src/herumi/index.js";
|
|
|
|
import {IBls} from "../src/interface.js";
|
2020-11-19 13:22:41 +00:00
|
|
|
|
|
|
|
export type Implementation = "blst" | "herumi";
|
|
|
|
|
2020-11-20 12:27:30 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
2020-11-20 19:03:17 +00:00
|
|
|
export function getBls(implementation: Implementation): IBls {
|
2020-11-19 13:22:41 +00:00
|
|
|
switch (implementation) {
|
|
|
|
case "blst":
|
|
|
|
return blst;
|
|
|
|
case "herumi":
|
|
|
|
return herumi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-20 19:35:32 +00:00
|
|
|
export async function runForAllImplementations(
|
2020-11-29 22:23:48 +00:00
|
|
|
callback: (bls: IBls, implementation: Implementation) => void
|
2020-11-20 19:35:32 +00:00
|
|
|
): Promise<void> {
|
|
|
|
for (const implementation of ["blst", "herumi"] as Implementation[]) {
|
|
|
|
const bls = getBls(implementation);
|
2020-11-29 22:23:48 +00:00
|
|
|
await bls.init();
|
|
|
|
callback(bls, implementation);
|
2020-11-20 19:35:32 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-19 13:22:41 +00:00
|
|
|
|
2020-11-20 19:35:32 +00:00
|
|
|
export function describeForAllImplementations(callback: (bls: IBls) => void): void {
|
|
|
|
runForAllImplementations((bls, implementation) => {
|
2020-12-14 09:13:56 +00:00
|
|
|
describe(implementation, function () {
|
2020-11-20 19:03:17 +00:00
|
|
|
before(async () => {
|
2020-11-25 16:09:44 +00:00
|
|
|
await bls.init();
|
2020-11-20 19:03:17 +00:00
|
|
|
});
|
2020-11-19 13:22:41 +00:00
|
|
|
|
2020-12-14 09:13:56 +00:00
|
|
|
try {
|
|
|
|
callback(bls);
|
|
|
|
} catch (e) {
|
|
|
|
it("Error generating test cases", function (done) {
|
|
|
|
done(e);
|
|
|
|
});
|
|
|
|
}
|
2020-11-19 14:41:45 +00:00
|
|
|
});
|
2020-11-20 19:35:32 +00:00
|
|
|
});
|
2020-11-19 13:22:41 +00:00
|
|
|
}
|