2020-11-19 13:22:41 +00:00
|
|
|
import blst from "../src/blst";
|
|
|
|
import herumi from "../src/herumi";
|
2020-11-20 19:03:17 +00:00
|
|
|
import {IBls} from "../src/interface";
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function forEachImplementation(
|
2020-11-20 19:03:17 +00:00
|
|
|
implementations: Implementation[],
|
2020-11-19 13:22:41 +00:00
|
|
|
callback: (bls: ReturnType<typeof getBls>, implementation: Implementation) => void
|
|
|
|
): void {
|
|
|
|
for (const implementation of implementations) {
|
2020-11-19 14:41:45 +00:00
|
|
|
describe(implementation, () => {
|
|
|
|
const bls = getBls(implementation);
|
2020-11-19 13:22:41 +00:00
|
|
|
|
2020-11-20 19:03:17 +00:00
|
|
|
before(async () => {
|
|
|
|
await bls.initBLS();
|
|
|
|
});
|
2020-11-19 13:22:41 +00:00
|
|
|
|
2020-11-19 14:41:45 +00:00
|
|
|
callback(bls, implementation);
|
|
|
|
});
|
2020-11-19 13:22:41 +00:00
|
|
|
}
|
|
|
|
}
|