fix: itest change ordering

This commit is contained in:
thesimplekid
2024-09-30 17:17:32 +02:00
parent 8fa770ca0d
commit 610571d05b
4 changed files with 25 additions and 4 deletions

View File

@@ -355,6 +355,15 @@ async fn test_fake_melt_change_in_quote() -> Result<()> {
let check = wallet.melt_quote_status(&melt_quote.id).await?;
assert_eq!(melt_response.change, check.change);
assert_eq!(
melt_response
.change
.unwrap()
.sort_by(|a, b| a.amount.cmp(&b.amount)),
check
.change
.unwrap()
.sort_by(|a, b| a.amount.cmp(&b.amount))
);
Ok(())
}

View File

@@ -146,6 +146,18 @@ pub struct BlindSignature {
pub dleq: Option<BlindSignatureDleq>,
}
impl Ord for BlindSignature {
fn cmp(&self, other: &Self) -> Ordering {
self.amount.cmp(&other.amount)
}
}
impl PartialOrd for BlindSignature {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
/// Witness
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(untagged)]

View File

@@ -48,7 +48,7 @@ pub enum Error {
}
/// Keyset version
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum KeySetVersion {
/// Current Version 00
Version00,
@@ -83,7 +83,7 @@ impl fmt::Display for KeySetVersion {
/// anyone who knows the set of public keys of a mint. The keyset ID **CAN**
/// be stored in a Cashu token such that the token can be used to identify
/// which mint or keyset it was generated from.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Id {
version: KeySetVersion,
id: [u8; Self::BYTELEN],

View File

@@ -76,7 +76,7 @@ done
# Run cargo test
cargo test -p cdk-integration-tests --test fake_wallet "test_fake_melt_change_in_quote"
cargo test -p cdk-integration-tests --test fake_wallet
# cargo test -p cdk-integration-tests --test mint
# Capture the exit status of cargo test