Validate FFI primitive inputs + refresh bindings/tests#1263
Validate FFI primitive inputs + refresh bindings/tests#1263benalleng merged 4 commits intopayjoin:masterfrom
Conversation
Pull Request Test Coverage Report for Build 22112284749Details
💛 - Coveralls |
cd3391a to
a44a282
Compare
59affc6 to
93bc4e8
Compare
055a2bb to
53db1cb
Compare
Thanks... applying that now |
759be1b to
10ee724
Compare
732c40a to
f331ef3
Compare
8b3625e to
20d3670
Compare
benalleng
left a comment
There was a problem hiding this comment.
I think you may have misunderstood my comments on the review, the psbt consts can be simply imported and not set as strings in the tests. I appreciate seeing the test_utils.dart but it was not really my intention to need to add this.
There was a problem hiding this comment.
you've kind of reversed what you did here that you did in the dart file
There was a problem hiding this comment.
This fell back during the rebase; I had a backup branch, so I'll bring it back. Side note, I've noticed only the Python test fails if the poll approach isn't used... will try to find out why (not the top task)
There was a problem hiding this comment.
sidenote, should we consider asserting a failure when attempts exceed 3, unless the intent is explicitly “smoke test only”
There was a problem hiding this comment.
The can actually just be
final psbt = test_utils.originalPsbt();
you will need to add it to the test_utils.dart import though
There was a problem hiding this comment.
Related note (but not a blocker for this PR), we should really not expose test utils in the main payjoin namespace for language bindings. This test_utils approach is a nice helper but the test utils are still exposed in the main namespace. I tried my hand at this briefly and couldn't find a good approach #1199 (comment)
5771b7a to
c1c3600
Compare
51d9f8b to
3f78b70
Compare
Co-authored-by: Benalleng <benalleng@gmail.com>
777f16b to
2b8e63e
Compare
spacebear21
left a comment
There was a problem hiding this comment.
utACK. I rebased to squash Ben's commit into the relevant 2nd commit, and added an additional commit that renames PrimitiveError to the more descriptive FfiValidationError
payjoin-ffi/src/error.rs
Outdated
| pub struct SerdeJsonError(#[from] serde_json::Error); | ||
|
|
||
| #[derive(Debug, thiserror::Error, uniffi::Error)] | ||
| pub enum PrimitiveError { |
There was a problem hiding this comment.
I think this type (and the PrimitiveError variants on specific error types) could be more descriptive as e.g. ValidationError or TypeCastError.
2b8e63e to
edbe432
Compare
payjoin-ffi/src/receive/error.rs
Outdated
| /// Amount exceeds allowed maximum. | ||
| #[error("Amount out of range: {amount_sat} sats (max {max_sat})")] | ||
| AmountOutOfRange { amount_sat: u64, max_sat: u64 }, | ||
| /// Weight must be positive and no more than a block. | ||
| #[error("Weight out of range: {weight_units} wu (max {max_wu})")] | ||
| WeightOutOfRange { weight_units: u64, max_wu: u64 }, |
There was a problem hiding this comment.
Seems these should just be part of the FfiValidation variant?
edbe432 to
b4a64e4
Compare
Rename error type and variants for clarity
b4a64e4 to
0679a8c
Compare
There was a problem hiding this comment.
re-re-ACK 0679a8c
I cleaned up the python checks which were false negatives before
This PR addresses #1262 and hardens the FFI boundary by validating primitive inputs and surfacing explicit errors. Updates integration tests/bindings to match the new error shapes and removes silent acceptance of invalid fee rates/amounts.
Follow-ups
Decide final script/witness size caps and document rationale.
Add Dart integration fix for large fee rate parsing (separate PR).