Skip to content

Commit

Permalink
fix: Fix computation of genesisSlot time range and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
msarcev committed Feb 9, 2024
1 parent 2b32c89 commit 3aa8544
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions client/src/helpers/nova/novaTimeUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ describe("slotIndexToUnixTimestamp", () => {
test("should return genesis slot timestamp when passed a slotIndex lower than genesisSlot", () => {
let target = genesisSlot - 1; // 4
const expectedGenesisTimestampRange = {
from: genesisUnixTimestamp,
to: genesisUnixTimestamp + slotDurationInSeconds,
from: genesisUnixTimestamp - slotDurationInSeconds,
to: genesisUnixTimestamp,
};

let slotIndex = slotIndexToUnixTimeRange(target);
Expand Down
6 changes: 3 additions & 3 deletions client/src/helpers/nova/novaTimeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export function unixTimestampToSlotIndexConverter(protocolInfo: ProtocolInfo): (
export function slotIndexToUnixTimeRangeConverter(protocolInfo: ProtocolInfo): (targetSlotIndex: number) => { from: number; to: number } {
return (targetSlotIndex: number) => {
const genesisSlot = protocolInfo.parameters.genesisSlot;
const genesisUnixTimestamp = protocolInfo.parameters.genesisUnixTimestamp;
const genesisUnixTimestamp = Number(protocolInfo.parameters.genesisUnixTimestamp);
const slotDurationInSeconds = protocolInfo.parameters.slotDurationInSeconds;

if (targetSlotIndex < genesisSlot) {
return {
from: Number(genesisUnixTimestamp),
to: Number(genesisUnixTimestamp) + slotDurationInSeconds,
from: genesisUnixTimestamp - slotDurationInSeconds,
to: genesisUnixTimestamp,
};
}

Expand Down

0 comments on commit 3aa8544

Please sign in to comment.