From 7759e67081db57ba5eace510b497f073dae9b189 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Fri, 28 Apr 2023 20:23:58 +0200 Subject: [PATCH] test(#108): reveal certification expiry issue --- pallets/certification/src/tests.rs | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pallets/certification/src/tests.rs b/pallets/certification/src/tests.rs index 9b685c6f6..c22880e8f 100644 --- a/pallets/certification/src/tests.rs +++ b/pallets/certification/src/tests.rs @@ -175,3 +175,43 @@ fn test_cert_period() { )); }); } + +#[test] +fn test_cert_expiry() { + new_test_ext(DefaultCertificationConfig { + apply_cert_period_at_genesis: true, + certs_by_receiver: btreemap![ + 0 => btreemap![ + 1 => Some(5), + 2 => Some(5), + ], + 1 => btreemap![ + 0 => Some(6), + 2 => Some(6), + ], + 2 => btreemap![ + 0 => Some(7), + 1 => Some(7), + ], + ], + }) + .execute_with(|| { + run_to_block(5); + // Expiry of cert by issuer 1 + System::assert_has_event(RuntimeEvent::DefaultCertification(Event::RemovedCert { + issuer: 1, + issuer_issued_count: 1, + receiver: 0, + receiver_received_count: 1, + expiration: true, + })); + // Expiry of cert by issuer 2 + System::assert_has_event(RuntimeEvent::DefaultCertification(Event::RemovedCert { + receiver: 0, + issuer: 2, + issuer_issued_count: 1, + receiver_received_count: 0, // <-- No more cert received + expiration: true, + })); + }); +} -- GitLab