Skip to content

Commit

Permalink
test: DashGov.estimateNthNextGovCycle(snapshot, secsPerBlock, offset)
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Aug 2, 2024
1 parent e5793ad commit 4e2ff00
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/calc-nth-gov-cycle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"use strict";

let Assert = require("assert/strict");

let DashGov = require("../");

let currentBlockHeight = 2114623;
let currentBlockMs = Date.parse("2024-08-01T22:01:00Z");
let snapshot = { block: currentBlockHeight, ms: currentBlockMs };

let tests = [
[
-1,
{
voteHeight: 2091954,
voteIso: "2024-06-21T19:44:00.268Z",
voteMs: 1718999040268,
voteDelta: -22669,
voteDeltaMs: -3572218838.0476646,
superblockHeight: 2093616,
superblockDelta: -21007,
superblockIso: "2024-06-24T20:29:01.895Z",
superblockMs: 1719260941895,
superblockDeltaMs: -3310318105.380356,
},
],
[
0,
{
voteHeight: 2108570,
voteIso: "2024-07-22T03:03:37.268Z",
voteMs: 1721617417268,
voteDelta: -6053,
voteDeltaMs: -953841838.0476648,
superblockHeight: 2110232,
superblockDelta: -4391,
superblockIso: "2024-07-25T03:48:38.895Z",
superblockMs: 1721879318895,
superblockDeltaMs: -691941105.3803562,
},
],
[
1,
{
voteHeight: 2125186,
voteIso: "2024-08-21T10:23:14.268Z",
voteMs: 1724235794268,
voteDelta: 10563,
voteDeltaMs: 1664535161.952335,
superblockHeight: 2126848,
superblockDelta: 12225,
superblockIso: "2024-08-24T11:08:15.894Z",
superblockMs: 1724497695894,
superblockDeltaMs: 1926435894.6196434,
},
],
];

for (let test of tests) {
let offset = test[0];
let expected = test[1];
let estimate = DashGov.estimateNthNextGovCycle(
snapshot,
DashGov._AVG_SECS_PER_BLOCK,
offset,
);
Assert.deepEqual(estimate, expected);
}

console.info(
`PASS: DashGov.estimateNthNextGovCycle(snapshot, secsPerBlock, offset)`,
);

0 comments on commit 4e2ff00

Please sign in to comment.