-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.test.js
More file actions
39 lines (34 loc) · 1.04 KB
/
core.test.js
File metadata and controls
39 lines (34 loc) · 1.04 KB
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
const test = require('tape')
const {graph1} = require ('./data/data')
const {
Map,
fromJS,
} = require("immutable")
const {
createGetNodeFeeFunc,
distributeReward
} = require('./core')
test('distributeReward', (t) => {
const initialState = graph1;
const block = Map({finderId :0, subsidy : 10, blockReward: 10})
const getNodeFee =createGetNodeFeeFunc(initialState.get('nodes'),0.1,0.5)
const state = distributeReward({state:initialState, block, getNodeFee})
const rewards = state.get('nodes').map(node=>fromJS({id:node.get('id'), reward : node.get('reward')}))
t.deepEqual(rewards.toJS(), [
{id:0,reward:1},
{id:1,reward:0.075},
{id:2,reward:0.118125},
{id:3,reward:1.5},
{id:4,reward:1.5},
{id:5,reward:1.5},
{id:6,reward:0.39375},
{id:7,reward:0.39375},
{id:8,reward:0.7875},
{id:9,reward:0.075},
{id:10,reward:0.15},
{id:11,reward:0.05},
{id:12,reward:0.05},
{id:13,reward:0.05}
])
t.end()
})