Skip to content

Commit 92b03b8

Browse files
committed
test: DashGov.estimateNthNextGovCycle(snapshot, secsPerBlock, offset)
1 parent 7e3e53b commit 92b03b8

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tests/calc-nth-gov-cycle.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"use strict";
2+
3+
let Assert = require("assert/strict");
4+
5+
let DashGov = require("../");
6+
7+
let currentBlockHeight = 2114623;
8+
let currentBlockMs = Date.parse("2024-08-01T22:01:00Z");
9+
let snapshot = { block: currentBlockHeight, ms: currentBlockMs };
10+
11+
let tests = [
12+
[
13+
-1,
14+
{
15+
voteHeight: 2091954,
16+
voteIso: "2024-06-21T13:44:00.273Z",
17+
voteMs: 1718977440273,
18+
voteDelta: -22669,
19+
voteDeltaMs: -3572218769.8332934,
20+
superblockHeight: 2093616,
21+
superblockDelta: -21007,
22+
superblockIso: "2024-06-24T14:29:01.958Z",
23+
superblockMs: 1719239341958,
24+
superblockDeltaMs: -3310318042.1671886,
25+
},
26+
],
27+
[
28+
0,
29+
{
30+
voteHeight: 2108570,
31+
voteIso: "2024-07-21T21:03:37.273Z",
32+
voteMs: 1721595817273,
33+
voteDelta: -6053,
34+
voteDeltaMs: -953841819.8332933,
35+
superblockHeight: 2110232,
36+
superblockDelta: -4391,
37+
superblockIso: "2024-07-24T21:48:38.908Z",
38+
superblockMs: 1721857718908,
39+
superblockDeltaMs: -691941092.1671883,
40+
},
41+
],
42+
[
43+
1,
44+
{
45+
voteHeight: 2125186,
46+
voteIso: "2024-08-21T04:23:14.273Z",
47+
voteMs: 1724214194273,
48+
voteDelta: 10563,
49+
voteDeltaMs: 1664535130.166707,
50+
superblockHeight: 2126848,
51+
superblockDelta: 12225,
52+
superblockIso: "2024-08-24T05:08:15.857Z",
53+
superblockMs: 1724476095857,
54+
superblockDeltaMs: 1926435857.832812,
55+
},
56+
],
57+
];
58+
59+
for (let test of tests) {
60+
let offset = test[0];
61+
let expected = test[1];
62+
let estimate = DashGov.estimateNthNextGovCycle(
63+
snapshot,
64+
DashGov._AVG_SECS_PER_BLOCK,
65+
offset,
66+
);
67+
Assert.deepEqual(estimate, expected);
68+
}
69+
70+
console.info(
71+
`PASS: DashGov.estimateNthNextGovCycle(snapshot, secsPerBlock, offset)`,
72+
);

0 commit comments

Comments
 (0)