From b1b61a74b135084d70a30d1227add6983064b2cd Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Sat, 5 Aug 2023 09:46:50 +0200
Subject: [PATCH] test: OK for double maps

---
 .../tests/common/golden_testing/iterative.rs  |  8 ++++++-
 .../gdev/tests/common/golden_testing/key.rs   | 24 ++++++++++++-------
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/runtime/gdev/tests/common/golden_testing/iterative.rs b/runtime/gdev/tests/common/golden_testing/iterative.rs
index f01c31d7a..6d88b883c 100644
--- a/runtime/gdev/tests/common/golden_testing/iterative.rs
+++ b/runtime/gdev/tests/common/golden_testing/iterative.rs
@@ -314,7 +314,13 @@ impl StorageIterativeChecker {
                     Key::_ManualKey("Proxy".to_string(), "Announcements".to_string(), "[
 ]".to_string()),
                     Key::_ManualKey("Treasury".to_string(), "Proposals".to_string(), "[
-]".to_string())
+]".to_string()),
+                    Key::_ManualKey("Offences".to_string(), "ConcurrentReportsIndex".to_string(), "[
+]".to_string()),
+                    Key::_ManualKey("Multisig".to_string(), "Multisigs".to_string(), "[
+]".to_string()),
+                    Key::_ManualKey("AtomicSwap".to_string(), "PendingSwaps".to_string(), "[
+]".to_string()),
                 ]
             },
             overriden: HashMap::new(),
diff --git a/runtime/gdev/tests/common/golden_testing/key.rs b/runtime/gdev/tests/common/golden_testing/key.rs
index 63121ce9f..94606ed94 100644
--- a/runtime/gdev/tests/common/golden_testing/key.rs
+++ b/runtime/gdev/tests/common/golden_testing/key.rs
@@ -688,9 +688,9 @@ impl Key {
             Key::OffencesReports => {
                 Some(|| to_kv(pallet_offences::Reports::<Runtime>::iter().collect()))
             }
-            // TODO: double map
-            // Key::OffencesConcurrentReportsIndex => Some(|| to_kv(pallet_offences::ConcurrentReportsIndex::<Runtime>::iter().collect())),
-            Key::OffencesConcurrentReportsIndex => None,
+            Key::OffencesConcurrentReportsIndex => Some(|| to_kv(pallet_offences::ConcurrentReportsIndex::<Runtime>::iter()
+                .map(to_simple_map)
+                .collect())),
             Key::SessionNextKeys => {
                 Some(|| to_kv(pallet_session::NextKeys::<Runtime>::iter().collect()))
             }
@@ -778,11 +778,10 @@ impl Key {
                         .collect(),
                 )
             }),
-            // TODO: double map
-            // Key::AtomicSwapPendingSwaps => Some(|| to_kv(pallet_atomic_swap::PendingSwaps::<Runtime>::iter().collect())),
-            Key::AtomicSwapPendingSwaps => None,
-            // TODO: double map
-            // Key::MultisigMultisigs => Some(|| to_kv(pallet_multisig::Multisigs::<Runtime>::iter().collect())),
+            Key::AtomicSwapPendingSwaps => Some(|| to_kv(pallet_atomic_swap::PendingSwaps::<Runtime>::iter()
+                .map(to_simple_map).collect())),
+            Key::MultisigMultisigs => Some(|| to_kv(pallet_multisig::Multisigs::<Runtime>::iter()
+                .map(to_simple_map).collect())),
             Key::MultisigMultisigs => None,
             Key::ProvideRandomnessRequestsReadyAtEpoch => Some(|| {
                 to_kv(pallet_provide_randomness::RequestsReadyAtEpoch::<Runtime>::iter().collect())
@@ -964,6 +963,15 @@ impl Key {
 //     Some(Box::new(move || t))
 // }
 
+fn to_simple_map<K1, K2, V>((k1, k2, v): (K1, K2, V)) -> (String, V)
+where
+    K1: Debug + 'static,
+    K2: Debug + 'static,
+    V: Debug + 'static,
+{
+    (format!("{:?} => {:?}", k1, k2), v)
+}
+
 fn to_kv<K: Debug + 'static, V: Debug + 'static>(
     hm: HashMap<K, V>,
 ) -> BTreeMap<Box<String>, Box<dyn Debug>> {
-- 
GitLab