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.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What code is this referencing?

@Alrighttt
Copy link
Contributor Author

I addressed all review comments.

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)

if err := ValidateBlock(cs, corruptBlock, db.supplementTipBlock(corruptBlock)); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

All of these now return commitment hash mismatch:

validation_test.go:1638: double spend of non-parent siacoin output: commitment hash mismatch
validation_test.go:1638: double spend of non-parent siafund output: commitment hash mismatch
validation_test.go:1638: revision after proof height: commitment hash mismatch
validation_test.go:1638: storage proof expiration at wrong proof height: commitment hash mismatch
validation_test.go:1638: file contract expiration submitted before expiration height: commitment hash mismatch
validation_test.go:1638: file contract renewal with invalid final revision: commitment hash mismatch
validation_test.go:1638: file contract renewal with invalid initial revision: commitment hash mismatch
validation_test.go:1638: invalid commitment: commitment hash mismatch

Altering the block and not updating the commitment makes all the cases fail with commitment hash mismatch instead of the intended error. Not really the point of the test and somehow doesn't appear to have reduced test coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, silly mistake. Thank you for catching that. I updated the test to actually check the errors similar to other tests.

I additionally added another function to modify the block after the commitment has been generated. It's not the cleanest, but it's certainly better than checking against the test name. I don't mind making a standalone test for this single case if this isn't sufficient.

… case; Make each case run as a distinct test and verify that the error message matches
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