Skip to content

Commit

Permalink
chore(core-state): remove unused clear method on stateStore (#4336)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastijankuzner authored Feb 26, 2021
1 parent 17ec422 commit c20652e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
20 changes: 2 additions & 18 deletions __tests__/unit/core-state/stores/state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ let factory: FactoryBuilder;
let logger: jest.SpyInstance;
let dispatchSpy: jest.SpyInstance;

beforeAll(async () => {
beforeEach(async () => {
const initialEnv = await setUp();
factory = initialEnv.factory;
logger = initialEnv.spies.logger.info;
dispatchSpy = initialEnv.spies.dispatchSpy;
stateStorage = initialEnv.sandbox.app.get(Container.Identifiers.StateStore);
});

beforeEach(() => {
blocks = makeChainedBlocks(101, factory.get("Block"));
stateStorage.clear();
});

afterAll(() => jest.clearAllMocks());
Expand Down Expand Up @@ -426,18 +422,6 @@ describe("State Storage", () => {
});
});

describe("clear", () => {
it("should clear the last blocks", () => {
for (let i = 0; i < 100; i++) {
stateStorage.setLastBlock(blocks[i]);
}

expect(stateStorage.getLastBlocks()).toHaveLength(100);
stateStorage.clear();
expect(stateStorage.getLastBlocks()).toHaveLength(0);
});
});

describe("reset", () => {
it("should reset initial blockchain state", () => {
const mockBlockChainMachine = {
Expand Down Expand Up @@ -539,7 +523,7 @@ describe("State Storage", () => {

stateStorage.pushPingBlock(blocks[5].data, true);
expect(logger).toHaveBeenCalledWith(
`Previous block ${blocks[3].data.height.toLocaleString()} pinged blockchain 1 times`,
`Previous block ${blocks[3].data.height.toLocaleString()} pinged blockchain 0 times`,
);

const blockPing = stateStorage.getBlockPing()!;
Expand Down
5 changes: 0 additions & 5 deletions packages/core-kernel/src/contracts/state/state-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ export interface StateStore {

reset(blockchainMachine): void;

/**
* Clear last blocks.
*/
clear(): void;

/**
* Is wakeup timeout set.
*/
Expand Down
8 changes: 0 additions & 8 deletions packages/core-state/src/stores/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ export class StateStore implements Contracts.State.StateStore {
this.blockchain = blockchainMachine.initialState;
}

/**
* Clear last blocks.
*/
public clear(): void {
this.lastBlocks = this.lastBlocks.clear();
this.cachedTransactionIds = this.cachedTransactionIds.clear();
}

public isWakeUpTimeoutSet(): boolean {
return !!this.wakeUpTimeout;
}
Expand Down

0 comments on commit c20652e

Please sign in to comment.