Skip to content

Commit

Permalink
Add unit test against current master
Browse files Browse the repository at this point in the history
  • Loading branch information
dapplion committed Apr 9, 2021
1 parent c16420a commit 5d691aa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ import {BenchmarkRunner} from "../runner";

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async function () {
const config = {
params: {
// eslint-disable-next-line @typescript-eslint/naming-convention
SHUFFLE_ROUND_COUNT: 90,
},
} as IBeaconConfig;
// eslint-disable-next-line @typescript-eslint/naming-convention
const config = {params: {SHUFFLE_ROUND_COUNT: 90}} as IBeaconConfig;
const seed = new Uint8Array([42, 32]);

const runner = new BenchmarkRunner("shuffle list", {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {IBeaconConfig} from "@chainsafe/lodestar-config";
import {expect} from "chai";
import {unshuffleList} from "../../../../src";

describe("util / shuffle", () => {
const testCases: {
id: string;
input: number[];
res: number[];
}[] = [
// Values from `unshuffleList()` at commit https://github.com/ChainSafe/lodestar/commit/ec065635ca7da7f3788da018bd68c4900f0427d2
{
id: "8 elements",
input: [0, 1, 2, 3, 4, 5, 6, 7],
res: [6, 3, 4, 0, 1, 5, 7, 2],
},
{
id: "16 elements",
input: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
res: [8, 4, 11, 7, 10, 6, 0, 3, 15, 12, 5, 14, 1, 9, 13, 2],
},
];

// eslint-disable-next-line @typescript-eslint/naming-convention
const config = {params: {SHUFFLE_ROUND_COUNT: 90}} as IBeaconConfig;
const seed = new Uint8Array([42, 32]);

for (const {id, input, res} of testCases) {
it(id, () => {
unshuffleList(config, input, seed);
expect(input).to.deep.equal(res);
});
}
});

0 comments on commit 5d691aa

Please sign in to comment.