Skip to content
Snippets Groups Projects
Commit 5879b057 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

test(#176): reveal that a ceritification on a online smith is bugged

parent 00972dea
No related branches found
No related tags found
1 merge request!232Resolve "PromotedToSmith is issued even for Smith"
...@@ -556,6 +556,73 @@ fn certifying_on_different_status() { ...@@ -556,6 +556,73 @@ fn certifying_on_different_status() {
}); });
} }
#[test]
fn certifying_an_online_smith() {
new_test_ext(GenesisConfig {
initial_smiths: btreemap![
1 => (false, vec![2, 3, 4]),
2 => (false, vec![3, 4]),
3 => (false, vec![1, 2]),
4 => (false, vec![]),
],
})
.execute_with(|| {
// Go online to be able to invite+certify
Pallet::<Runtime>::on_smith_goes_online(1);
Pallet::<Runtime>::on_smith_goes_online(2);
Pallet::<Runtime>::on_smith_goes_online(3);
assert_ok!(Pallet::<Runtime>::invite_smith(RuntimeOrigin::signed(1), 5));
assert_ok!(Pallet::<Runtime>::accept_invitation(RuntimeOrigin::signed(
5
)));
assert_ok!(Pallet::<Runtime>::certify_smith(
RuntimeOrigin::signed(1),
5
));
assert_ok!(Pallet::<Runtime>::certify_smith(
RuntimeOrigin::signed(2),
5
));
// Smith can expire
assert_eq!(
Smiths::<Runtime>::get(5),
Some(SmithMeta {
status: Smith,
expires_on: Some(5),
issued_certs: vec![],
received_certs: vec![1, 2]
})
);
Pallet::<Runtime>::on_smith_goes_online(5);
// After going online, the expiration disappears
assert_eq!(
Smiths::<Runtime>::get(5),
Some(SmithMeta {
status: Smith,
expires_on: None,
issued_certs: vec![],
received_certs: vec![1, 2]
})
);
// We can receive certification without postponing the expiration (because we are online)
assert_ok!(Pallet::<Runtime>::certify_smith(
RuntimeOrigin::signed(3),
5
));
// TODO: this test currently fails because expires_on is not None
assert_eq!(
Smiths::<Runtime>::get(5),
Some(SmithMeta {
status: Smith,
expires_on: None,
issued_certs: vec![],
received_certs: vec![1, 2, 3]
})
);
});
}
#[test] #[test]
fn invitation_on_non_wot_member() { fn invitation_on_non_wot_member() {
new_test_ext(GenesisConfig { new_test_ext(GenesisConfig {
......
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