-
Notifications
You must be signed in to change notification settings - Fork 10
100% test coverage for validation.go #379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ing test coverage for validateFileContracts
…teV2FileContractsValidateRevisionClosure
|
Fixing the failing Lint tests now. |
|
@Alrighttt once this is ready make sure to assign PJ, Nate and me as reviewers. |
|
This is already a beast to review, so I will continue with providing 100% test coverage in subsequent pull requests. |
There was a problem hiding this 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.
n8mgr
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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") { | |||
There was a problem hiding this comment.
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
peterjan
left a comment
There was a problem hiding this 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 😳
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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" { | |||
There was a problem hiding this comment.
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{}, |
There was a problem hiding this comment.
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 (?)
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.