-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate.test.js
executable file
·72 lines (59 loc) · 2.39 KB
/
calculate.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const { createMassRewardTXs, calculateRewardForHeightRange, AttachmentEnum } = require('./helpers');
const NEUTRINO_DECIMAL = 1e6;
const neutrinoPrice = 95; // Like 0.95$
const nodeMinedNeutrino = 5 * NEUTRINO_DECIMAL;
const testStaker = '3PQSC3ysFKPvYba86VK84ZZKhS5ZRb725vz';
const testJsonRoute = 'https://api.myjson.com/bins/cf7og';
const assetId = 'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p';
describe('test rewards', () => {
const testJson = {
'3P1wriMwcpkHHrz5SGRuwn7wrrGKNC9HxK4': 500000000,
'3P1xpPEXy5VCiV34zHtX7UZFKhie4Guz8NJ': 1532520,
'3P1xvwUD5tZLGbnVAVadf5nxqQb89J5KcNt': 0,
'3P1y1bpDE67zjnBaVnPiEaGNQ9vEV4LN6Fd': 2112952797,
'3P1ySeZitc5V5hkLQYWyhJwqsXpXLgJMuCW': 897298,
'3P1zdekqXGZ5zokGroupT42L6jV7t9ixDVG': 483563086,
'3P22FqkfbQ5QL4fVYfV11Reepkx2cAWKMma': 3718941,
'3P23HcJ8wvpNktk5PxWNaxbUaCi1SMhyzx4': 575024905,
'3P24DP4oB4MuxAVRuome95UZWhRZVpss1ET': 0,
'3P2512s7ebiM8GeviKVsKWoFmN3DXeWUiEr': 0,
'3P25Dr55mHoWYGSWeBQtfdZnN7tSUe574jh': 14110854,
'3P25WoPH6EA8P5Kf7YzCYhtkpxN6Vv2vxGZ': 10368576,
'3P25nRnyaeZDoJVXVHHZdeUzsoWpPeAUdGi': 0,
'3P26h9N164TbaYm3CPXQbexPXpxyVjZorQA': 0,
};
it('compute direct reward', async () => {
const balances = testJson;
const totalProfit = 1000 * NEUTRINO_DECIMAL;
const lastPaymentHeight = 1983858; // 22.03.2020, 17:56:09
const currentHeight = 1900000;
const rewards = calculateRewardForHeightRange(
totalProfit,
currentHeight,
lastPaymentHeight,
balances
);
const transactions = createMassRewardTXs(rewards, {
attachment: AttachmentEnum.direct,
assetId: assetId,
});
console.log(transactions);
});
it('compute referral reward', async () => {
const balances = testJson;
const totalProfit = 1000 * NEUTRINO_DECIMAL;
const lastPaymentHeight = 1983858; // 22.03.2020, 17:56:09
const currentHeight = 1900000;
const rewards = calculateRewardForHeightRange(
totalProfit,
currentHeight,
lastPaymentHeight,
balances
);
const transactions = createMassRewardTXs(rewards, {
attachment: AttachmentEnum.referral,
assetId: assetId,
});
console.log(transactions);
});
});