-
Notifications
You must be signed in to change notification settings - Fork 125
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
RandomImprove : Test covering fees correctly #254
Conversation
…h funds to cover the fees
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.
/check
Fails with insufficient funds at the moment: Waiting for #252 to get resolved to fix that. The conditions in the test are:
|
* we expect 3 inputs in this case, which should give us the 264 fee
@vsubhuman I made the following changes:
|
rust/src/tx_builder.rs
Outdated
// Phase 3: add extra inputs needed for fees | ||
// We do this at the end because this new inputs won't be associated with | ||
// a specific output, so the improvement algorithm we do above does not apply here. | ||
if input_total.partial_cmp(&output_total).unwrap().eq(&Ordering::Less) { |
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.
- Why using
partial_cmp
here? - Unchecked unwrap doesn't look good.
If these two types are both Value
I think you can even just use <
, e.g. see how while added < needed
is used above
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.
Ah, that was a bad copy paste from my end 😅
Just pushed a version with a regular <
comparison
@rooooooooob , check the solution plz if you have a chance |
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 guess this is a good enough fix to do it at the end. CIP 2 actually leaves out the fees entirely and says it's out of scope of the CIP so this detail is not covered which is why I tried to do it during the adding phase.
We're also trying to figure out what we want to do for multiassets since those also weren't covered but we can cover that at a later point.
/check |
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.
/check
Thank you, @pedromtcosta ! Looks good! |
Added test that consistently fails on random improve not adding enough funds to cover the fees