Skip to content
Snippets Groups Projects
Commit bdb31722 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

test(#109): reveal certification renewal issue

parent 3da34f02
No related branches found
No related tags found
No related merge requests found
......@@ -175,3 +175,72 @@ fn test_cert_period() {
));
});
}
// after given validity period, a certification should expire
#[test]
fn test_cert_expiration() {
new_test_ext(DefaultCertificationConfig {
apply_cert_period_at_genesis: false,
certs_by_receiver: btreemap![
0 => btreemap![
1 => Some(5),
],
],
})
.execute_with(|| {
run_to_block(5);
// Expiry of cert by issuer 1
System::assert_last_event(RuntimeEvent::DefaultCertification(Event::RemovedCert {
issuer: 1,
issuer_issued_count: 0,
receiver: 0,
receiver_received_count: 0,
expiration: true,
}));
});
}
// when renewing a certification, it should not expire now, but later
#[test]
fn test_cert_renewal() {
new_test_ext(DefaultCertificationConfig {
apply_cert_period_at_genesis: false,
certs_by_receiver: btreemap![
0 => btreemap![
1 => Some(5),
2 => Some(20),
],
1 => btreemap![
0 => Some(20),
2 => Some(20),
],
2 => btreemap![
0 => Some(20),
1 => Some(20),
],
],
})
.execute_with(|| {
run_to_block(2);
// renew certification from bob to alice
// this certification should expire 10 blocks later (at block 12)
assert_eq!(
DefaultCertification::add_cert(RuntimeOrigin::signed(1), 1, 0),
Ok(().into())
);
System::assert_last_event(RuntimeEvent::DefaultCertification(Event::RenewedCert {
issuer: 1,
receiver: 0,
}));
run_to_block(12);
// expiry of previously renewed cert
System::assert_last_event(RuntimeEvent::DefaultCertification(Event::RemovedCert {
issuer: 1,
issuer_issued_count: 1,
receiver: 0,
receiver_received_count: 1,
expiration: true,
}));
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment