Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Aug 28, 2024
1 parent a746641 commit f8ccb11
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
19 changes: 10 additions & 9 deletions fetch/wire_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ type MaliciousIDs struct {
}

type EpochData struct {
// When changing this value also check
// - the size of `ResponseMessage.Data` above
// - the size of `Response.Data` in `p2p/server/server.go`
// - the size of `NodeIDs` in `MaliciousIDs` above
// - the size of `Set` in `EpochActiveSet` in common/types/activation.go
// - the size of `EligibilityProofs` in the type `Ballot` in common/types/ballot.go
// - the size of `Rewards` in the type `InnerBlock` in common/types/block.go
// - the size of `Ballots` in the type `LayerData` below
// - the size of `Proposals` in the type `Value` in hare3/types.go
// When changing this value also check the size of
// - `ResponseMessage.Data` above
// - `Response.Data` in `p2p/server/server.go`
// - `NodeIDs` in `MaliciousIDs` above
// - `Set` in `EpochActiveSet` in common/types/activation.go
// - `EligibilityProofs` in the type `Ballot` in common/types/ballot.go
// - `Rewards` in the type `InnerBlock` in common/types/block.go
// - `Ballots` in the type `LayerData` below
// - `Proposals` in the type `Value` in hare3/types.go
// - `Proposals` and `CompactProposals` in the type `Value` in hare4/types.go
AtxIDs []types.ATXID `scale:"max=8000000"`
}

Expand Down
6 changes: 4 additions & 2 deletions hare3/hare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func withProposals(fraction float64) clusterOpt {
}

// withSigners creates N signers in addition to regular active nodes.
// this signeres will be partitioned in fair fashion across regular active nodes.
// this signers will be partitioned in fair fashion across regular active nodes.
func withSigners(n int) clusterOpt {
return func(cluster *lockstepCluster) {
cluster.signersCount = n
Expand Down Expand Up @@ -912,7 +912,9 @@ func TestProposals(t *testing.T) {
atxsdata.AddFromAtx(&atx, false)
}
for _, proposal := range tc.proposals {
proposals.Add(proposal)
if err := proposals.Add(proposal); err != nil {
panic(err)
}
}
for _, id := range tc.malicious {
require.NoError(t, identities.SetMalicious(db, id, []byte("non empty"), time.Time{}))
Expand Down
20 changes: 9 additions & 11 deletions hare4/hare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ import (

const layersPerEpoch = 4

var wait = 10 * time.Second

func TestMain(m *testing.M) {
types.SetLayersPerEpoch(layersPerEpoch)
res := m.Run()
Expand Down Expand Up @@ -323,7 +321,7 @@ func withProposals(fraction float64) clusterOpt {
}

// withSigners creates N signers in addition to regular active nodes.
// this signeres will be partitioned in fair fashion across regular active nodes.
// this signers will be partitioned in fair fashion across regular active nodes.
func withSigners(n int) clusterOpt {
return func(cluster *lockstepCluster) {
cluster.signersCount = n
Expand Down Expand Up @@ -451,7 +449,7 @@ func (cl *lockstepCluster) genProposalNode(lid types.LayerID, node int) {
active := cl.activeSet()
n := cl.nodes[node]
if n.atx == nil {
panic("shouldnt happen")
panic("shouldn't happen")
}
proposal := &types.Proposal{}
proposal.Layer = lid
Expand Down Expand Up @@ -655,15 +653,15 @@ func sendWithTimeout[T any](t testing.TB, value T, ch chan<- T, timeout time.Dur
}

func (t *testTracer) waitStopped() types.LayerID {
return waitForChan(t.TB, t.stopped, wait, "didn't stop")
return waitForChan(t.TB, t.stopped, 10*time.Second, "didn't stop")
}

func (t *testTracer) waitEligibility() []*types.HareEligibility {
return waitForChan(t.TB, t.eligibility, wait, "no eligibility")
return waitForChan(t.TB, t.eligibility, 10*time.Second, "no eligibility")
}

func (t *testTracer) waitSent() *Message {
return waitForChan(t.TB, t.sent, wait, "no message")
return waitForChan(t.TB, t.sent, 10*time.Second, "no message")
}

func (*testTracer) OnStart(types.LayerID) {}
Expand All @@ -676,21 +674,21 @@ func (t *testTracer) OnStop(lid types.LayerID) {
}

func (t *testTracer) OnActive(el []*types.HareEligibility) {
sendWithTimeout(t.TB, el, t.eligibility, wait, "eligibility can't be sent")
sendWithTimeout(t.TB, el, t.eligibility, 10*time.Second, "eligibility can't be sent")
}

func (t *testTracer) OnMessageSent(m *Message) {
sendWithTimeout(t.TB, m, t.sent, wait, "message can't be sent")
sendWithTimeout(t.TB, m, t.sent, 10*time.Second, "message can't be sent")
}

func (*testTracer) OnMessageReceived(*Message) {}

func (t *testTracer) OnCompactIdRequest(*CompactIdRequest) {
sendWithTimeout(t.TB, struct{}{}, t.compactReq, wait, "compact req can't be sent")
sendWithTimeout(t.TB, struct{}{}, t.compactReq, 10*time.Second, "compact req can't be sent")
}

func (t *testTracer) OnCompactIdResponse(*CompactIdResponse) {
sendWithTimeout(t.TB, struct{}{}, t.compactResp, wait, "compact resp can't be sent")
sendWithTimeout(t.TB, struct{}{}, t.compactResp, 10*time.Second, "compact resp can't be sent")
}

func testHare(t *testing.T, active, inactive, equivocators int, opts ...clusterOpt) {
Expand Down

0 comments on commit f8ccb11

Please sign in to comment.