les: fix unit tests

This commit is contained in:
rjl493456442 2019-10-31 15:13:34 +08:00
parent e7daae4d0a
commit 58e19dc15d
2 changed files with 3 additions and 5 deletions

View file

@ -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 {

View file

@ -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")
@ -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: