Skip to content

Commit

Permalink
les: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Oct 31, 2019
1 parent e7daae4 commit 58e19dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions les/clientpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ func newClientPool(db ethdb.Database, freeClientCap uint64, clock mclock.Clock,
// delete this entry.
ndb.nbEvictCallBack = func(now mclock.AbsTime, b negBalance) bool {
balance := math.Exp(float64(b.logValue-pool.logOffset(now)) / fixedPointMultiplier)
if balance <= 1 {
return true
}
return false
return balance <= 1
}
go func() {
for {
Expand Down
3 changes: 2 additions & 1 deletion les/clientpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func TestFreeClientKickedOut(t *testing.T) {

for i := 0; i < 10; i++ {
pool.connect(poolTestPeer(i), 1)
clock.Run(time.Millisecond)
clock.Run(100 * time.Millisecond)
}
if pool.connect(poolTestPeer(11), 1) {
t.Fatalf("New free client should be rejected")
Expand Down Expand Up @@ -498,6 +498,7 @@ func TestNodeDBExpiration(t *testing.T) {
for _, c := range cases {
ndb.setNB(c.ip, c.balance)
}
time.Sleep(100 * time.Millisecond) // Ensure the db expirer is registered.
clock.Run(time.Hour + time.Minute)
select {
case <-done:
Expand Down

0 comments on commit 58e19dc

Please sign in to comment.