From 8242c0afea368a3b2c00c93bc86525dfce1cecae Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Tue, 23 Jan 2024 23:20:54 +0100
Subject: [PATCH] test(#176): show that ExpiresOn is not correctly updated for
 Pending smiths

---
 pallets/smith-members/src/tests.rs | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pallets/smith-members/src/tests.rs b/pallets/smith-members/src/tests.rs
index a1ba5942a..60a8786a1 100644
--- a/pallets/smith-members/src/tests.rs
+++ b/pallets/smith-members/src/tests.rs
@@ -575,6 +575,7 @@ fn certifying_an_online_smith() {
         assert_ok!(Pallet::<Runtime>::accept_invitation(RuntimeOrigin::signed(
             5
         )));
+        Pallet::<Runtime>::on_new_session(2);
         assert_ok!(Pallet::<Runtime>::certify_smith(
             RuntimeOrigin::signed(1),
             5
@@ -588,11 +589,14 @@ fn certifying_an_online_smith() {
             Smiths::<Runtime>::get(5),
             Some(SmithMeta {
                 status: Smith,
-                expires_on: Some(5),
+                expires_on: Some(7),
                 issued_certs: vec![],
                 received_certs: vec![1, 2]
             })
         );
+        // TODO: test is failing here because ExpiresOn is not correctly updated
+        assert_eq!(ExpiresOn::<Runtime>::get(7), Some(vec![5]));
+
         Pallet::<Runtime>::on_smith_goes_online(5);
         // After going online, the expiration disappears
         assert_eq!(
@@ -604,6 +608,8 @@ fn certifying_an_online_smith() {
                 received_certs: vec![1, 2]
             })
         );
+        // ExpiresOn is not unscheduled, but as expires_on has switched to None it's not a problem
+        assert_eq!(ExpiresOn::<Runtime>::get(7), Some(vec![5]));
 
         // We can receive certification without postponing the expiration (because we are online)
         assert_ok!(Pallet::<Runtime>::certify_smith(
-- 
GitLab