|
2 | 2 |
|
3 | 3 | let DashGov = require("../");
|
4 | 4 |
|
| 5 | +let sb = 2126848; |
5 | 6 | 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], |
14 | 25 | ];
|
15 | 26 |
|
16 | 27 | 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]; |
19 | 31 |
|
20 |
| - let superblock = DashGov.getNextSuperblock(height); |
| 32 | + let superblock = DashGov.getNthNextSuperblock(height, offset); |
21 | 33 | if (superblock !== expected) {
|
22 | 34 | throw new Error(
|
23 | 35 | `expected superblock for height ${height} to be ${expected}, but got ${superblock}`,
|
24 | 36 | );
|
25 | 37 | }
|
26 | 38 | }
|
27 | 39 |
|
28 |
| -console.info(`PASS: DashGov.getNextSuperblock(height)`); |
| 40 | +console.info(`PASS: DashGov.getNthNextSuperblock(height)`); |
0 commit comments