Skip to content

Commit

Permalink
fix: persistentCheckpointsCache.test.ts unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Mar 4, 2024
1 parent e75af9a commit ae47128
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ describe("PersistentCheckpointStateCache", function () {

it("pruneFinalized and getStateOrBytes", async function () {
cache.add(cp2, states["cp2"]);
expect(await cache.getStateOrBytes(cp0bHex)).toEqual(states["cp0b"]);
expect(((await cache.getStateOrBytes(cp0bHex)) as CachedBeaconStateAllForks).hashTreeRoot()).toEqual(
states["cp0b"].hashTreeRoot()
);
expect(await cache.processState(toHexString(cp2.root), states["cp2"])).toEqual(1);
// cp0 is persisted
expect(fileApisBuffer.size).toEqual(1);
Expand Down Expand Up @@ -222,7 +224,7 @@ describe("PersistentCheckpointStateCache", function () {
});
});

describe("processState, maxEpochsInMemory = 2", () => {
describe.only("processState, maxEpochsInMemory = 2", () => {
beforeEach(() => {
fileApisBuffer = new Map();
const datastore = getTestDatastore(fileApisBuffer);
Expand Down Expand Up @@ -484,7 +486,9 @@ describe("PersistentCheckpointStateCache", function () {

// regen needs to reload cp0b
cache.add(cp0b, states["cp0b"]);
expect(await cache.getStateOrBytes(cp0bHex)).toEqual(states["cp0b"]);
expect(((await cache.getStateOrBytes(cp0bHex)) as CachedBeaconStateAllForks).hashTreeRoot()).toEqual(
states["cp0b"].hashTreeRoot()
);

// regen generates cp1b
const cp1b = {epoch: 21, root: root0b};
Expand Down Expand Up @@ -670,7 +674,9 @@ describe("PersistentCheckpointStateCache", function () {

// simulate regen
cache.add(cp0b, states["cp0b"]);
expect(await cache.getStateOrBytes(cp0bHex)).toEqual(states["cp0b"]);
expect(((await cache.getStateOrBytes(cp0bHex)) as CachedBeaconStateAllForks).hashTreeRoot()).toEqual(
states["cp0b"]
);
// root2, regen cp0b
const cp1bState = states["cp0b"].clone();
cp1bState.slot = 21 * SLOTS_PER_EPOCH;
Expand Down

0 comments on commit ae47128

Please sign in to comment.