Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott authored and hsanjuan committed Oct 5, 2020
1 parent 71c4729 commit 159bf04
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion chain/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TimeOfRound(period time.Duration, genesis int64, round uint64) int64 {
return TimeOfRoundErrorValue
}

periodBits := math.Log2(float64(period.Seconds()) + 1) // require x >=1 in log2(x)
periodBits := math.Log2(period.Seconds() + 1) // require x >=1 in log2(x)
if round >= (math.MaxUint64 >> (int(periodBits) + 2)) { // +1 for mul overflow, +1 for casting int64
return TimeOfRoundErrorValue
}
Expand Down
4 changes: 2 additions & 2 deletions chain/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func TestTimeOverflow(t *testing.T) {
t.Fatal("future rounds should not allow previous times.")
}

overflowRound := TimeOfRound(period, start, math.MaxUint64 >> 3)
overflowRound := TimeOfRound(period, start, math.MaxUint64>>3)
if overflowRound != TimeOfRoundErrorValue {
t.Fatal("overflow shoud return error.")
}

overflowRound2 := TimeOfRound(period + 2 * time.Second, start, (math.MaxUint64 >> 3) - 1)
overflowRound2 := TimeOfRound(period+2*time.Second, start, (math.MaxUint64>>3)-1)
if overflowRound2 != TimeOfRoundErrorValue {
t.Fatal("overflow shoud return error.")
}
Expand Down
2 changes: 1 addition & 1 deletion core/drand_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func (d *Drand) StartFollowChain(req *drand.StartFollowRequest, stream drand.Con
return fmt.Errorf("invalid hash info hex: %v", err)
}
if !bytes.Equal(info.Hash(), hash) {
return errors.New("invalid chain info hash!")
return errors.New("invalid chain info hash")
}

store, err := d.createBoltStore()
Expand Down
9 changes: 3 additions & 6 deletions core/drand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,23 +468,20 @@ func TestDrandPublicStream(t *testing.T) {
}
func TestDrandFollowChain(tt *testing.T) {
n := 4
thr := key.DefaultThreshold(n)
p := 1 * time.Second
dt := NewDrandTest2(tt, n, thr, p)
dt := NewDrandTest2(tt, n, key.DefaultThreshold(n), p)
defer dt.Cleanup()
group := dt.RunDKG()
time.Sleep(getSleepDuration())
root := dt.nodes[0]
rootID := root.drand.priv.Public
rootID := dt.nodes[0].drand.priv.Public

dt.MoveToTime(group.GenesisTime)
// do a few periods
for i := 0; i < 6; i++ {
dt.MoveTime(group.Period)
}

cm := root.drand.opts.certmanager
client := net.NewGrpcClientFromCertManager(cm)
client := net.NewGrpcClientFromCertManager(dt.nodes[0].drand.opts.certmanager)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// get last round first
Expand Down

0 comments on commit 159bf04

Please sign in to comment.