mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
fix unit test
This commit is contained in:
parent
7e4db6e904
commit
3aba8f4c26
3 changed files with 14 additions and 7 deletions
|
|
@ -903,7 +903,7 @@ func (c *Posv) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.HookReward != nil && number%rCheckpoint == 0 {
|
if c.HookReward != nil && number%rCheckpoint == 0 {
|
||||||
if !c.EnableCache && c.BlockSigners.Len() >= 2700 {
|
if !c.EnableCache && uint64(c.BlockSigners.Len()) >= (rCheckpoint*3) {
|
||||||
fmt.Println("EnableCache true c.BlockSigners.Len()", c.BlockSigners.Len())
|
fmt.Println("EnableCache true c.BlockSigners.Len()", c.BlockSigners.Len())
|
||||||
c.EnableCache = true
|
c.EnableCache = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, blockSign
|
||||||
} else {
|
} else {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
squeue := make(chan []common.Address, 1)
|
squeue := make(chan []common.Address, 1)
|
||||||
wg.Add(900)
|
wg.Add(int(rCheckpoint))
|
||||||
|
|
||||||
for i := startBlockNumber; i <= endBlockNumber; i++ {
|
for i := startBlockNumber; i <= endBlockNumber; i++ {
|
||||||
go func(i uint64) {
|
go func(i uint64) {
|
||||||
|
|
@ -484,6 +484,7 @@ func GetRewardBalancesRate(c *posv.Posv, foudationWalletAddr common.Address, mas
|
||||||
vote.Masternode = masterAddr
|
vote.Masternode = masterAddr
|
||||||
vote.Voter = voteAddr
|
vote.Voter = voteAddr
|
||||||
|
|
||||||
|
if c != nil {
|
||||||
if vCap, ok := c.Votes.Get(vote); ok {
|
if vCap, ok := c.Votes.Get(vote); ok {
|
||||||
voterCap = vCap.(*big.Int)
|
voterCap = vCap.(*big.Int)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -494,6 +495,12 @@ func GetRewardBalancesRate(c *posv.Posv, foudationWalletAddr common.Address, mas
|
||||||
fmt.Println("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String())
|
fmt.Println("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String())
|
||||||
c.Votes.Add(vote, voterCap)
|
c.Votes.Add(vote, voterCap)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
voterCap, err = validator.GetVoterCap(opts, masterAddr, voteAddr)
|
||||||
|
if err != nil {
|
||||||
|
log.Crit("Fail to get vote capacity", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
totalCap.Add(totalCap, voterCap)
|
totalCap.Add(totalCap, voterCap)
|
||||||
voterCaps[voteAddr] = voterCap
|
voterCaps[voteAddr] = voterCap
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ func TestRewardBalance(t *testing.T) {
|
||||||
|
|
||||||
foundationAddr := common.HexToAddress(common.FoudationAddr)
|
foundationAddr := common.HexToAddress(common.FoudationAddr)
|
||||||
totalReward := new(big.Int).SetInt64(15 * 1000)
|
totalReward := new(big.Int).SetInt64(15 * 1000)
|
||||||
rewards, err := contracts.GetRewardBalancesRate(foundationAddr, acc3Addr, totalReward, baseValidator)
|
rewards, err := contracts.GetRewardBalancesRate(nil, foundationAddr, acc3Addr, totalReward, baseValidator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("Fail to get reward balances rate.", err)
|
t.Error("Fail to get reward balances rate.", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue