From 83542d27d33253b95e362154c416c71683da56ee Mon Sep 17 00:00:00 2001
From: Hugo Trentesaux <hugo@trentesaux.fr>
Date: Fri, 13 Oct 2023 16:30:11 +0200
Subject: [PATCH] test: refund queue

---
 pallets/duniter-account/src/lib.rs      |  2 +-
 runtime/gdev/tests/integration_tests.rs |  2 ++
 runtime/gdev/tests/xt_tests.rs          | 33 +++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs
index 2191bfac7..670da5802 100644
--- a/pallets/duniter-account/src/lib.rs
+++ b/pallets/duniter-account/src/lib.rs
@@ -96,7 +96,7 @@ pub mod pallet {
     pub type PendingNewAccounts<T: Config> =
         StorageMap<_, Blake2_128Concat, T::AccountId, (), OptionQuery>;
 
-    #[derive(Encode, Decode, Clone, TypeInfo)]
+    #[derive(Encode, Decode, Clone, TypeInfo, Debug, PartialEq)]
     pub struct QueuedRefund<AccountId, IdtyId, Balance> {
         /// account to refund
         pub account: AccountId,
diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs
index 87df60fa9..916cac4c7 100644
--- a/runtime/gdev/tests/integration_tests.rs
+++ b/runtime/gdev/tests/integration_tests.rs
@@ -954,6 +954,7 @@ fn test_validate_new_idty_after_few_uds() {
                 IdtyData {
                     // first eligible UD will be at block 30
                     first_eligible_ud: pallet_universal_dividend::FirstEligibleUd::from(3),
+                    quotas: (0, 0)
                 }
             );
         });
@@ -1014,6 +1015,7 @@ fn test_claim_memberhsip_after_few_uds() {
                 IdtyData {
                     // first eligible UD will be at block 30
                     first_eligible_ud: pallet_universal_dividend::FirstEligibleUd::from(3),
+                    quotas: (0, 0)
                 }
             );
         });
diff --git a/runtime/gdev/tests/xt_tests.rs b/runtime/gdev/tests/xt_tests.rs
index 1614e8622..8da6deb0a 100644
--- a/runtime/gdev/tests/xt_tests.rs
+++ b/runtime/gdev/tests/xt_tests.rs
@@ -100,3 +100,36 @@ fn test_transfer_xt() {
             assert_eq!(Balances::free_balance(Treasury::account_id()), 200 + 3);
         })
 }
+
+/// test that fees are added to the refund queue
+#[test]
+fn test_refund_queue() {
+    ExtBuilder::new(1, 3, 4)
+        .with_initial_balances(vec![
+            (AccountKeyring::Alice.to_account_id(), 10_000),
+            (AccountKeyring::Eve.to_account_id(), 10_000),
+        ])
+        .build()
+        .execute_with(|| {
+            let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death {
+                dest: AccountKeyring::Eve.to_account_id().into(),
+                value: 500,
+            });
+
+            // 1 cĞD of tip
+            let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 1u64);
+            assert_ok!(Executive::apply_extrinsic(xt));
+
+            // check treasury initial amount
+            assert_eq!(
+                pallet_duniter_account::RefundQueue::<Runtime>::get()
+                    .first()
+                    .expect("a refund should have been added to the queue"),
+                &pallet_duniter_account::pallet::QueuedRefund {
+                    account: AccountKeyring::Alice.to_account_id(),
+                    identity: 1u32,
+                    amount: 2u64
+                }
+            );
+        })
+}
-- 
GitLab