-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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] Add prioritisetransaction RPC test #7063
[Tests] Add prioritisetransaction RPC test #7063
Conversation
mempool = self.nodes[0].getrawmempool() | ||
assert(txids[0][0] not in mempool) | ||
assert(txids[0][1] in mempool) | ||
print "Prioritised transaction mined: success" |
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: Shouldn't the print
appear in front of assert
? So when it fails, we know where it did (Not just by line 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.
Well then it would be printing something incorrect if the assertion failed. I guess I could add a different print statement above the asserts, but not sure it's worth it? If the assertion fails I think the stack trace is informative enough, and I don't think the style here is inconsistent with the rest of the tests.
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.
Where would you put a comment, when you had put one? Then just replace the #
with print
and you get in L109:
print "Assert that prioritised transaction was mined"
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.
rest of the tests
I see no reason to do this. You could as well just remove the print
completely.
utACK |
4c6b6f3
to
596e839
Compare
Rebased, moved prints |
Merged via 6abf6eb (needed trivial rebase change in rpc-tests.py) |
utACK 6abf6eb |
PR can be closed!? |
@morcos mentioned in #6898 (comment) that there's no rpc test for
prioritisetransaction
. This adds a simple test to exercise this logic.In writing this test I discovered something unusual -- if you try to set a fee delta using
prioritisetransaction
that is negative and greater in magnitude than the transaction's fee, you get incorrect results. TheCFeeRate
constructor that takes a fee and size doesn't work if you pass in a negative fee. I don't really understand the details of how conversion and type promotion work in this kind of situation, but as far as I can tell, on my machine, I think the compiler promotes theint64_t nFeePaid
to auint64_t
(nSize
is asize_t
):Link to the code:
bitcoin/src/amount.cpp
Line 15 in c983d6f
I think this arithmetic may work on a 32-bit platform, because it looked to me like doing arithmetic with an
unsigned int
rather than asize_t
appeared to work.Anyway I expect that #6898 will fix
prioritisetransaction
to work properly with fee deltas that bring the modified fee below 0, so I just avoided that issue for now in this test; I can update it in the future to include that case after #6898.