-
Notifications
You must be signed in to change notification settings - Fork 473
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
Convenient and High-fidelity Transaction Processing Tests #2730
Conversation
447c46e
to
a3129f6
Compare
This refactors some of the `ledger` code so that it's convenient to write short tests that operate on a fairly complete ledger, including rewards payouts. Previously, tests used genesis(), but genesis() build the genesis block internally "by hand" rather than using MakeGenesisBlock, so it missed some details (like setting up RewardsState). Presumably, this was because MakeGenesisBlock was in the `data` package, and could not be imported. That is the motivation behind moving it, and some related code, to bookkeeping (where various Genesis related code already existed). The txntest packaged is motivated purely by a desire for more concise tests. It allows for the construction of transaction.Transaction objects concisely, and we can add all sort of conveneince routines here that would not make sense in the production code (turning these into SignedTxns, SignedTxnWithADs, TransactionGroups, etc).
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.
Shouldn't spend some time after merging it and unify some tests to new functions?
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.
Like the change! I think it will make testing transactions much simpler
return ad | ||
} | ||
|
||
func (eval *BlockEvaluator) txn(t testing.TB, txn *txntest.Txn) { |
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.
Is it possible to rename this to something more detailed than txn
or txns
? Unfortunately I don't have a much better suggestion myself than signAndTestTxn
.
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 doesn't sign them. It's a big lie.
I might not object to testTxn, except there is already testTransaction(). testTransaction() does a bunch of tests, but does not actually push it through the evaluator.
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 see, just read the comment above about the unsigned SignedTxn()
. Maybe something like prepareAndTestTxn
? If not, we can leave it
8b9c2a6
to
fecb795
Compare
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.
Looks good to me. Let's someone from other teams be familiar with new test harness.
@tolikzinovyev mind checking how does |
Codecov Report
@@ Coverage Diff @@
## master #2730 +/- ##
==========================================
+ Coverage 47.11% 47.13% +0.01%
==========================================
Files 350 349 -1
Lines 56321 56321
==========================================
+ Hits 26538 26545 +7
+ Misses 26810 26804 -6
+ Partials 2973 2972 -1
Continue to review full report at Codecov.
|
Adds commentary based on context found in algorand#2730.
Adds commentary based on context found in #2730.
This refactors some of the
ledger
code so that it's convenientto write short tests that operate on a fairly complete ledger,
including rewards payouts. Previously, tests used genesis(), but
genesis() build the genesis block internally "by hand" rather
than using MakeGenesisBlock, so it missed some details (like
setting up RewardsState). Presumably, this was because
MakeGenesisBlock was in the
data
package, and could not beimported. That is the motivation behind moving it, and some
related code, to bookkeeping (where various Genesis related code
already existed).
The txntest packaged is motivated purely by a desire for more
concise tests. It allows for the construction of
transaction.Transaction objects concisely, and we can add all
sort of conveneince routines here that would not make sense in
the production code (turning these into SignedTxns,
SignedTxnWithADs, TransactionGroups, etc).