-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Good test vectors for signed transactions #1018
Comments
Please note that we now have Bitcoin regtest in trezor-user-env (trezor/trezor-user-env#99) and also a first test using this in Suite 🎉 (trezor/trezor-suite#4540). Also note that @karliatto was responsible for making the first test (in another words set up the infrastructure) and I would like QA to expand the tests furthermore after our new Head of QA starts in ~February. |
some notes: (a) Using regtest is impractical.
(b) We are reasonably happy with the current tests. Except for the bad data, the process works pretty much as intended. Fixing the bad data might be tedious (or we might write a supporting tool to make it easier -- note to self, libcst to the rescue?) but we expect it to be a one-time thing. Action items: (1) Enable checking (2) Get a list of all available transactions:
Make a script that does this, so we can later adapt it for Bcash/Bgold/etc. if needed. From (2) we should hopefully be able to pick appropriate inputs to fix the failing tests. |
(c) We have two kinds of tests:
Although nice to have, we do not need real-world transactions to test (2). Depending on which tests are failing and what data we have available, we still might go with synthetic transactions as inputs for those tests. |
Action item 1: |
Many transaction test vectors in our testsuite aren't actually valid transactions: they are spending outputs that do not exist, have mismatched amounts, or belong to different addresses.
In general, the majority of transaction test vectors only validate our implementation in core vs legacy, and check that no regressions in the signing code happened. As there is currently no good way to validate transactions against the real cryptocurrency implementation, there could be invisible serialization bugs and such.
The goal of this issue is to improve the test suite in this regard.
The Platonic ideal of a test vector is one that you can copy-paste from the test suite and spend on-chain directly. This is of course impossible.
The next best thing is validating that a Trezor-generated transaction comes out identical to a transaction that has already been accepted by the network. We have several such testcases, but we've lost many of them because, e.g., they are using invalid BIP32 paths.
It is rather difficult to generate such transactions as needed, because one needs to create live transaction to serve as inputs, a live transaction that spends them, that costs money and time and some amount of bookkeeping.
As an intermediate goal, it would be good to have a "full feature set" of transactions that have been accepted by Testnet (or the respective testnets of different altcoins). This removes the need to spend real money and limits the amount of necessary bookkeeping to "get coins from faucet, return coins to faucet".
Another option is to run a blockchain internally.
Finally, we can explore ways to take advantage of
testmempoolaccept
(and equivalents?), possibly coupled with reverting the node to a block at particular height, so that the UTXOs being used are unspent at that time. This would allow us to independently check the validity of the test vectors.The text was updated successfully, but these errors were encountered: