فهرست منبع

fix: itest change ordering

thesimplekid 6 ماه پیش
والد
کامیت
610571d05b
4فایلهای تغییر یافته به همراه25 افزوده شده و 4 حذف شده
  1. 10 1
      crates/cdk-integration-tests/tests/fake_wallet.rs
  2. 12 0
      crates/cdk/src/nuts/nut00/mod.rs
  3. 2 2
      crates/cdk/src/nuts/nut02.rs
  4. 1 1
      misc/fake_itests.sh

+ 10 - 1
crates/cdk-integration-tests/tests/fake_wallet.rs

@@ -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(())
 }

+ 12 - 0
crates/cdk/src/nuts/nut00/mod.rs

@@ -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)]

+ 2 - 2
crates/cdk/src/nuts/nut02.rs

@@ -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],

+ 1 - 1
misc/fake_itests.sh

@@ -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