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

test(#176): reveal bug

parent 55d51237
No related branches found
No related tags found
No related merge requests found
...@@ -187,6 +187,52 @@ fn process_to_become_a_smith_and_lose_it() { ...@@ -187,6 +187,52 @@ fn process_to_become_a_smith_and_lose_it() {
}); });
} }
#[test]
fn avoid_multiple_events_for_becoming_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);
// Events cannot be recorded on genesis
run_to_block(1);
// State before
assert_eq!(Smiths::<Runtime>::get(5), None);
// Try to invite
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
));
System::assert_has_event(RuntimeEvent::Smith(
Event::<Runtime>::SmithMembershipAdded { idty_index: 5 },
));
run_to_block(2);
assert_ok!(Pallet::<Runtime>::certify_smith(
RuntimeOrigin::signed(3),
5
));
// Should not be promoted again
assert!(!System::events().iter().any(|record| record.event
== RuntimeEvent::Smith(Event::<Runtime>::SmithMembershipAdded { idty_index: 5 },)));
});
}
#[test] #[test]
fn should_have_checks_on_certify() { fn should_have_checks_on_certify() {
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