Skip to content

Commit 91f8711

Browse files
committed
test: .getNthNextSuperblock()
1 parent 5a92786 commit 91f8711

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

tests/calc-next-superblock.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@
22

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

5+
let sb = 2126848;
56
let tests = [
6-
[
7-
2115106 - DashGov.SUPERBLOCK_INTERVAL,
8-
2126848 - DashGov.SUPERBLOCK_INTERVAL,
9-
],
10-
[2115106, 2126848],
11-
[2126847, 2126848],
12-
[2126848, 2126848 + DashGov.SUPERBLOCK_INTERVAL],
13-
[2126849, 2126848 + DashGov.SUPERBLOCK_INTERVAL],
7+
// Previous Cycle (past)
8+
[-1, sb - 2, sb - 2 * DashGov.SUPERBLOCK_INTERVAL],
9+
[-1, sb - 1, sb - 2 * DashGov.SUPERBLOCK_INTERVAL],
10+
[-1, sb + 0, sb - DashGov.SUPERBLOCK_INTERVAL],
11+
[-1, sb + 1, sb - DashGov.SUPERBLOCK_INTERVAL],
12+
[-1, sb + 2, sb - DashGov.SUPERBLOCK_INTERVAL],
13+
// Current Cycle (past / exact present)
14+
[0, sb - 2, sb - DashGov.SUPERBLOCK_INTERVAL],
15+
[0, sb - 1, sb - DashGov.SUPERBLOCK_INTERVAL],
16+
[0, sb + 0, sb],
17+
[0, sb + 1, sb],
18+
[0, sb + 2, sb],
19+
// Upcoming Cycle
20+
[+1, sb - 2, sb],
21+
[+1, sb - 1, sb],
22+
[+1, sb + 0, sb + DashGov.SUPERBLOCK_INTERVAL],
23+
[+1, sb + 1, sb + DashGov.SUPERBLOCK_INTERVAL],
24+
[+1, sb + 2, sb + DashGov.SUPERBLOCK_INTERVAL],
1425
];
1526

1627
for (let test of tests) {
17-
let height = test[0];
18-
let expected = test[1];
28+
let offset = test[0];
29+
let height = test[1];
30+
let expected = test[2];
1931

20-
let superblock = DashGov.getNextSuperblock(height);
32+
let superblock = DashGov.getNthNextSuperblock(height, offset);
2133
if (superblock !== expected) {
2234
throw new Error(
2335
`expected superblock for height ${height} to be ${expected}, but got ${superblock}`,
2436
);
2537
}
2638
}
2739

28-
console.info(`PASS: DashGov.getNextSuperblock(height)`);
40+
console.info(`PASS: DashGov.getNthNextSuperblock(height)`);

0 commit comments

Comments
 (0)