From 2c49f07ec38ab6f9fe1583efba343b3e976b4292 Mon Sep 17 00:00:00 2001 From: AnilChinchawale Date: Fri, 26 Oct 2018 15:55:32 +0530 Subject: [PATCH] fix test reward --- contracts/utils.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contracts/utils.go b/contracts/utils.go index 2234d84a24..ea899c3647 100644 --- a/contracts/utils.go +++ b/contracts/utils.go @@ -201,12 +201,18 @@ func GetRewardBalancesRate(masterAddr common.Address, totalReward *big.Int, vali log.Error("Fail to get vote capacity", "error", err) return nil, err } + totalCap.Add(totalCap, voterCap) voterCaps[voteAddr] = voterCap } for addr, voteCap := range voterCaps { - balances[addr] = new(big.Int).Mul(totalVoterReward, voteCap) - balances[addr] = new(big.Int).Div(balances[addr], totalCap) + rcap := new(big.Int).Mul(totalVoterReward, voteCap) + rcap = new(big.Int).Div(rcap, totalCap) + if balances[addr] != nil { + balances[addr].Add(balances[addr], rcap) + } else { + balances[addr] = rcap + } } }