This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
chainsafe-bls/test/switch.ts

33 lines
827 B
TypeScript
Raw Normal View History

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) {
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
callback(bls, implementation);
});
2020-11-19 13:22:41 +00:00
}
}