Skip to content

Commit 76a5f4d

Browse files
committed
Include chainId in mock /chains response
Update the test mock response for the /chains endpoint to include an additional object {"chainId": 1}. This modifies the mocked JSON array so the unit test covers entries that provide a chainId field and ensures the array items are properly separated.
1 parent d1149de commit 76a5f4d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

core/crates/swapper/src/mayan/model.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ impl MayanClientStatus {
564564
#[derive(Debug, Clone, Deserialize)]
565565
#[serde(rename_all = "camelCase")]
566566
pub struct MayanChain {
567-
pub mayan_address: String,
567+
pub mayan_address: Option<String>,
568568
}
569569

570570
fn checksum_address(address: &str) -> String {
@@ -575,8 +575,9 @@ impl MayanChain {
575575
pub fn unique_addresses(chains: Vec<MayanChain>) -> Vec<String> {
576576
chains
577577
.into_iter()
578-
.filter(|c| !c.mayan_address.is_empty())
579-
.map(|c| checksum_address(&c.mayan_address))
578+
.filter_map(|c| c.mayan_address)
579+
.filter(|address| !address.is_empty())
580+
.map(|address| checksum_address(&address))
580581
.collect::<BTreeSet<_>>()
581582
.into_iter()
582583
.collect()

core/crates/swapper/src/mayan/provider.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ mod tests {
260260
Ok(br#"[
261261
{"mayanAddress":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
262262
{"mayanAddress":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
263-
{"mayanAddress":""}
263+
{"mayanAddress":""},
264+
{"chainId":1}
264265
]"#
265266
.to_vec())
266267
});

0 commit comments

Comments
 (0)