Skip to content

Conversation

@Alrighttt
Copy link
Contributor

This pull request adds test coverage for any remaining cases within validation.go.

Some tests are non-exhaustive and only add test cases that were previously missing. These are noted with developer comments.

@github-project-automation github-project-automation bot moved this to In Progress in Sia Jan 20, 2026
@Alrighttt
Copy link
Contributor Author

Fixing the failing Lint tests now.

@ChrisSchinnerl
Copy link
Member

@Alrighttt once this is ready make sure to assign PJ, Nate and me as reviewers.

@Alrighttt
Copy link
Contributor Author

This is already a beast to review, so I will continue with providing 100% test coverage in subsequent pull requests.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@n8mgr n8mgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two duplicate test cases for "storage proof conflicts" you didn't add them, but might as well remove them.

Also this file is pretty large. I wouldn't move any existing tests, but if you added any new ones see if they might make sense in a new file i,.e. validation_txn_test.go. We should move existing tests in a follow-up so the diff isn't polluted.

{
"invalid commitment",
func(b *types.Block) {
// commitment is later set to 00..00 for this case
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably safe to adjust the test execution ordering so corrupt can also corrupt the commitment.

i.e.

corruptBlock := deepCopyBlock(validBlock)
signTxn(cs, &corruptBlock.V2.Transactions[0])
if len(corruptBlock.MinerPayouts) > 0 {
    corruptBlock.V2.Commitment = cs.Commitment(corruptBlock.MinerPayouts[0].Address, corruptBlock.Transactions, corruptBlock.V2Transactions())
}
test.corrupt(&corruptBlock)
findBlockNonce(cs, &corruptBlock)

@@ -2166,6 +2258,13 @@ func TestV2RenewalResolution(t *testing.T) {
sigHash := cs.RenewalSigHash(*resolution)
resolution.RenterSignature = pk.SignHash(sigHash)
resolution.HostSignature = pk.SignHash(sigHash)

if strings.HasSuffix(test.desc, "invalid host signature") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this one. I'd see if you can either add a new modification fn to the tests or reorder the existing ones over being hacky with test names

Copy link
Member

@peterjan peterjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments, LGTM otherwise. I must admit though I didn't read through every line here 😳

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case doesn't make sense. Since we're updating this file anyway we might as well take this along.

{
desc: "invalid renewal - invalid host signature",
renewFn: func(vt *types.V2Transaction) {
// signatures are created after this function is called
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// signatures are created after this function is called
// signatures are created after this function is called

{
desc: "invalid renewal - invalid renter signature",
renewFn: func(vt *types.V2Transaction) {
// signatures are created after this function is called
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// signatures are created after this function is called
// signatures are created after this function is called

@@ -1555,6 +1630,9 @@ func TestValidateV2Block(t *testing.T) {
if len(corruptBlock.MinerPayouts) > 0 {
corruptBlock.V2.Commitment = cs.Commitment(corruptBlock.MinerPayouts[0].Address, corruptBlock.Transactions, corruptBlock.V2Transactions())
}
if test.desc == "invalid commitment" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as Nate had here https://github.com/SiaFoundation/core/pull/379/changes#r2722905264 - this is a little fragile

},
// Initialize any V2BlockData to trigger `if v.V2 != nil` condition
V2: &types.V2BlockData{
// Transactions: []types.V2Transaction{},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit get rid of this commented out line (?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

5 participants