-
Notifications
You must be signed in to change notification settings - Fork 232
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
Tests check sequence verify #1793
base: v0.11.1-dev
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## v0.11.0-dev #1793 +/- ##
===============================================
+ Coverage 58.71% 62.00% +3.29%
===============================================
Files 582 596 +14
Lines 22924 26766 +3842
===============================================
+ Hits 13459 16596 +3137
- Misses 7318 7924 +606
- Partials 2147 2246 +99
Continue to review full report at Codecov.
|
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.
I've only reviewed the first test properly, the rest of the tests have similar problems, so please fix all of them.
Also, please try to find as much common code between the tests and extract that into methods.
} | ||
defer teardown(false) | ||
|
||
blockAHash, _, err := testConsensus.AddBlock([]*externalapi.DomainHash{testConsensus.DAGParams().GenesisHash}, nil, nil) |
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.
Please add a comment explaining the structure of DAG you are building, and why
} | ||
fees := uint64(1) | ||
// Create a CSV script | ||
numOfDAAScoreToWait := uint64(10) |
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.
Please rename num -> number
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.
Alternatively, you can just rename to daaScoreToWait
@@ -0,0 +1,524 @@ | |||
package consensus_test |
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.
The filename should be all_lower_case (same for timelock_cltv_test.go
)
if err != nil { | ||
t.Fatalf("Error creating blockE: %v", err) | ||
} | ||
// bit 62 of sequence defines if it's conditioned by DAA score(set to 0) or by time (set to 1). |
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.
These are implementation details that you are leaking outside where they are supposed to be.
To mitigate, do one of the following:
- Either convert sequenceTypeFlag to boolean.
- Or do some magic with
constants.SequenceLockTimeIsSeconds
. I don't have a concrete plan what to do, discuss with me if you prefer this path/
if err != nil { | ||
t.Fatalf("Error creating transactionThatSpentTheLockedOutput: %v", err) | ||
} | ||
// Add a block that contains a transaction that spends the locked output before the time, and therefore should be failed. |
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.
Not failed, but rather - rejected
if err != nil { | ||
t.Fatalf("The block should be valid since the output is not locked anymore. but got an error: %v", err) | ||
} | ||
validBlockStatus, err := testConsensus.BlockStatusStore().Get(testConsensus.DatabaseContext(), stagingArea, |
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 not valid yet. It's only expected to be valid.
Please rename to actualBlockStatus
or just blockStatus
if err != nil { | ||
t.Fatalf("Error creating blockA: %v", err) | ||
} | ||
blockBHash, _, err := testConsensus.AddBlock([]*externalapi.DomainHash{blockAHash}, nil, nil) |
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.
You are creating 4 blocks one after the other. Please use a loop
} | ||
|
||
// TestRelativeTimeOnCheckSequenceVerify verifies that if the relative target is set to be X DAA score, | ||
// and the absolute DAA score is X before having X DAA score more than the time the UTXO was mined, then the output will remain locked. |
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.
and the absolute DAA score is
There's no such things as "the absolute DAA score", there's "the actual DAA score" or something similar.
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.
Also the rest of the sentance is really hard to understand, please revise (Talk to me if need someone to brainstorm with)
if err != nil { | ||
return nil, err | ||
} | ||
stamp := uint64(lockedOutputBlock.Header.TimeInMilliseconds()) |
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.
Please rename to timestamp
testConsensus *testapi.TestConsensus) (*externalapi.DomainTransaction, error) { | ||
|
||
var lockTime, sequence uint64 | ||
if sequenceTypeFlag == 1 { // Conditioned by time: |
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.
Please take as much lines as possible out of the if
754c80d
to
cc52481
Compare
is this an important test, or why is it still in the PRs while being so old? |
The second part of #1257
Tests for CSV (conditioned by time and DAA score).