Skip to content
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

test: Implement unit tests for CWallet::CreateTransaction #3667

Merged
merged 8 commits into from
Sep 4, 2020

Conversation

xdustinface
Copy link

@xdustinface xdustinface commented Aug 22, 2020

I decided to add this because i worked on a fix for CreateTransaction and while doing that i figured its very hard to say for sure by just manual test/reviewing if things are still good since this is quite complex method imo with a lot possible routes. I think this should catch all currently possible cases in there. If someone can think about any improvement or more test cases, let me know!

Requires #3666 and #3668 to pass all the tests.

@xdustinface xdustinface marked this pull request as draft August 22, 2020 17:37
@xdustinface xdustinface marked this pull request as ready for review August 24, 2020 08:49
@xdustinface
Copy link
Author

Ready for review!

@PastaPastaPasta
Copy link
Member

You should probably move #3668 into this PR, cause unit tests need to be passing for us to merge this

@xdustinface
Copy link
Author

Requires #3666 and #3668 to pass all the tests.

Hmm imo separating them makes sense (depending on what will happen during review process :D). Why not just merge #3666 and #3668 first and then rebase this one as the others still pass without this PR. You can still verify #3668 locally with this PR for now. Still prefer a merge? Let me know!

@UdjinM6
Copy link

UdjinM6 commented Aug 24, 2020

I'd prefer rebasing this on top of develop after 3668 is merged.

@UdjinM6 UdjinM6 added this to the 16 milestone Aug 26, 2020
return false;
}
// Verify the number of requested outputs does match the resulting outputs
CheckEqual(vecEntries.size(), wtx.tx->vout.size() - (nChangePos != -1 ? 1 : 0));
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use BOOST_CHECK_EQUAL here?

Copy link
Author

@xdustinface xdustinface Sep 3, 2020

Choose a reason for hiding this comment

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

What about 29b9e0f? Saves one line :D

Comment on lines 857 to 862
BOOST_CHECK(CreateTransaction({{10, false}}, false));
BOOST_CHECK(CreateTransaction({{10, true}}, false));
BOOST_CHECK(CreateTransaction({{100, false}}, false));
BOOST_CHECK(CreateTransaction({{100, true}}, false));
BOOST_CHECK(CreateTransaction({{10000, true}, {100, true}}, false));
BOOST_CHECK(CreateTransaction({{10000, false}, {100, false}}, false));
Copy link
Member

Choose a reason for hiding this comment

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

probably should just dust - 1, dust, and dust+1

Copy link
Author

Choose a reason for hiding this comment

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

Hm i just dropped those initial tests, c7e34f5. They are anyway covered in the rest of the test cases.

@xdustinface xdustinface force-pushed the pr-test-createtransaction branch from c7e34f5 to 2190f80 Compare September 4, 2020 12:02
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK

@UdjinM6 UdjinM6 merged commit 4510378 into dashpay:develop Sep 4, 2020
xdustinface added a commit to xdustinface/dash that referenced this pull request Sep 12, 2020
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
xdustinface added a commit to xdustinface/dash that referenced this pull request Sep 12, 2020
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
xdustinface added a commit to xdustinface/dash that referenced this pull request Sep 12, 2020
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
xdustinface added a commit to xdustinface/dash that referenced this pull request Sep 12, 2020
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 11, 2022
* test: Implement unit tests for CWallet::CreateTransaction

* test: Reset minRelayTxFee in CreateTransactionTest

At this point its modified from an other test when running all unit 
tests which lets this test fail unexpectedly.

* test: Lock cs_main/cs_wallet when required in CreateTransactionTest

* test: Add new test in CreateTransactionTest

Test if the wallet creation fails properly with the correct error
messages.

* test: Fixed expected test results for some CreateTransactionTest cases

* test: Fail if CreateTransaction runs into "Exceed max tries" case

* test: Adjust last return in CreateTransaction

* test: Drop dust tests
PastaPastaPasta pushed a commit that referenced this pull request Feb 9, 2024
…hify help text, undashify code comments (#5852)

## Issue being fixed or feature implemented
This pull request is a follow-up to
[some](#5834 (comment))
[feedback](#5834 (comment))
received on [dash#5834](#5834) as
the patterns highlighted were present in different parts of the codebase
and hence not corrected within the PR itself but addressed separately.

This is that separate PR 🙂 (with some additional cleanup of my own)

## What was done?
* This pull request will remain a draft until
[dash#5834](#5834) as it will
introduce more changes that will need to be corrected in this PR.
* Code introduced that is unique to Dash Core (CoinJoin, InstantSend,
etc.) has been excluded from un-Dashification as the purpose of it is to
reduce backport conflicts, which don't apply in those cases.
* `CWallet::CreateTransaction` and the `CreateTransactionTest` fixture
have been excluded as the former originates from
[dash#3668](#3668) and the latter
from [dash#3667](#3667) and are
distinct enough to be unique to Dash Core.
* There are certain Dashifications and SegWit-removals that prove
frustrating as it would break compatibility with programs that rely on
the naming of certain keys
* `getrawmempool`, `getmempoolancestors`, `getmempooldescendants` and
`getmempoolentry` return `vsize` which is currently an alias of `size`.
I have been advised to retain `vsize` in lieu of potential future
developments. (this was originally remedied in
219a1d0 but has since been dropped)
* `getaddressmempool`, `getaddressutxos` and `getaddressdeltas` all
return a value with the key `satoshis`. This is frustrating to rename to
`duffs` for compatibility reasons.
* `decodepsbt` returns (if applicable) `non_witness_utxo` which is
frustrating to rename simply to `utxo` for the same reason.
* `analyzepsbt` returns (if applicable) `estimated_vsize` which
frustrating to rename to `estimated_size` for the same reason.

## How Has This Been Tested?

## Breaking Changes
None

## Checklist:
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e
tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants