Skip to content

feat: add api to decode a swapstring#128

Open
moakilodash wants to merge 1 commit into
RGB-Tools:masterfrom
moakilodash:decode_swapstring_endpoint
Open

feat: add api to decode a swapstring#128
moakilodash wants to merge 1 commit into
RGB-Tools:masterfrom
moakilodash:decode_swapstring_endpoint

Conversation

@moakilodash
Copy link
Copy Markdown

resolving #61
let me know if i have to change anything

Copy link
Copy Markdown
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

Thanks! Requested just a couple of small changes

Comment thread src/routes.rs
}))
}

pub(crate) async fn decode_swap_string(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
pub(crate) async fn decode_swap_string(
pub(crate) async fn decode_swapstring(

Comment thread src/test/issue.rs
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the issue test doesn't seem the right place for these checks, please move them to the swap_roundtrip_assets test

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.

2 participants