Skip to content

Commit

Permalink
Add remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Nov 4, 2024
1 parent 89fa079 commit 1ada05c
Show file tree
Hide file tree
Showing 3 changed files with 474 additions and 100 deletions.
9 changes: 8 additions & 1 deletion activation/wire/malfeasance_invalid_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func NewInvalidPostProof(
return nil, errors.New("ATX is not a merged ATX, but NodeID is different from SmesherID")
}

if nipostIndex < 0 || nipostIndex >= len(atx.NIPosts) {
return nil, errors.New("invalid NIPoST index")
}

postIndex := 0
var marriageProof *MarriageProof
if atx.SmesherID != nodeID {
Expand All @@ -65,7 +69,7 @@ func NewInvalidPostProof(
return post.MarriageIndex == proof.NodeIDMarryProof.CertificateIndex
})
if postIndex == -1 {
return nil, errors.New("marriage index not found in PoSTs of ATX")
return nil, fmt.Errorf("no PoST from %s in ATX", nodeID.ShortString())
}
}

Expand Down Expand Up @@ -234,6 +238,9 @@ func createInvalidPostProof(
if nipostIndex < 0 || nipostIndex >= len(atx.NIPosts) {
return InvalidPostProof{}, errors.New("invalid NIPoST index")
}

Check warning on line 240 in activation/wire/malfeasance_invalid_post.go

View check run for this annotation

Codecov / codecov/patch

activation/wire/malfeasance_invalid_post.go#L239-L240

Added lines #L239 - L240 were not covered by tests
if postIndex < 0 || postIndex >= len(atx.NIPosts[nipostIndex].Posts) {
return InvalidPostProof{}, errors.New("invalid PoST index")
}

Check warning on line 243 in activation/wire/malfeasance_invalid_post.go

View check run for this annotation

Codecov / codecov/patch

activation/wire/malfeasance_invalid_post.go#L242-L243

Added lines #L242 - L243 were not covered by tests

return InvalidPostProof{
NIPostsRoot: atx.NIPosts.Root(atx.PreviousATXs),
Expand Down
Loading

0 comments on commit 1ada05c

Please sign in to comment.