feat: add api to decode a swapstring#128
Open
moakilodash wants to merge 1 commit into
Open
Conversation
zoedberg
requested changes
May 18, 2026
Member
zoedberg
left a comment
There was a problem hiding this comment.
Thanks! Requested just a couple of small changes
| })) | ||
| } | ||
|
|
||
| pub(crate) async fn decode_swap_string( |
Member
There was a problem hiding this comment.
Suggested change
| pub(crate) async fn decode_swap_string( | |
| pub(crate) async fn decode_swapstring( |
Comment on lines
+52
to
+93
| // check /decodeswapstring | ||
| let maker_init_response = maker_init( | ||
| node1_addr, | ||
| 30, | ||
| Some(&asset_nia.asset_id), | ||
| 3_000_000, | ||
| None, | ||
| 100, | ||
| ) | ||
| .await; | ||
| let decoded_swapstring = decode_swapstring(node1_addr, &maker_init_response.swapstring).await; | ||
| assert_eq!(decoded_swapstring.qty_from, 30); | ||
| assert_eq!(decoded_swapstring.qty_to, 3_000_000); | ||
| assert_eq!( | ||
| decoded_swapstring.from_asset, | ||
| Some(asset_nia.asset_id.clone()) | ||
| ); | ||
| assert_eq!(decoded_swapstring.to_asset, None); | ||
| assert!(decoded_swapstring.expiry > 0); | ||
| assert_eq!( | ||
| decoded_swapstring.payment_hash, | ||
| maker_init_response.payment_hash | ||
| ); | ||
|
|
||
| // check /decodeswapstring invalid swapstring error | ||
| let payload = DecodeSwapstringRequest { | ||
| swapstring: s!("not_a_valid_swapstring"), | ||
| }; | ||
| let res = reqwest::Client::new() | ||
| .post(format!("http://{node1_addr}/decodeswapstring")) | ||
| .json(&payload) | ||
| .send() | ||
| .await | ||
| .unwrap(); | ||
| check_response_is_nok( | ||
| res, | ||
| reqwest::StatusCode::BAD_REQUEST, | ||
| "Invalid swap string 'not_a_valid_swapstring'", | ||
| "InvalidSwapString", | ||
| ) | ||
| .await; | ||
|
|
Member
There was a problem hiding this comment.
the issue test doesn't seem the right place for these checks, please move them to the swap_roundtrip_assets test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolving #61
let me know if i have to change anything