From ea877a9013ade11190deb1b38fa3822fd1da9df8 Mon Sep 17 00:00:00 2001 From: pifragile Date: Sun, 25 Feb 2024 11:48:45 +0800 Subject: [PATCH 1/5] meetup size target 15 --- ceremonies/src/mock.rs | 4 ++-- ceremonies/src/tests.rs | 35 +++++++++++++++++++++++------------ communities/src/mock.rs | 2 +- test-utils/src/lib.rs | 6 +++--- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ceremonies/src/mock.rs b/ceremonies/src/mock.rs index ce3e365f..f7753bd0 100644 --- a/ceremonies/src/mock.rs +++ b/ceremonies/src/mock.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( parameter_types! { pub const DefaultDemurrage: Demurrage = Demurrage::from_bits(0x0000000000000000000001E3F0A8A973_i128); - pub const MeetupSizeTarget: u64 = 10; + pub const MeetupSizeTarget: u64 = 15; pub const MeetupMinSize: u64 = 3; pub const MeetupNewbieLimitDivider: u64 = 3; } @@ -64,7 +64,7 @@ impl dut::Config for TestRuntime { type MeetupMinSize = MeetupMinSize; type MeetupNewbieLimitDivider = MeetupNewbieLimitDivider; type WeightInfo = (); - type MaxAttestations = ConstU32<10>; + type MaxAttestations = ConstU32<15>; } // boilerplate diff --git a/ceremonies/src/tests.rs b/ceremonies/src/tests.rs index cd158ea5..7e14575d 100644 --- a/ceremonies/src/tests.rs +++ b/ceremonies/src/tests.rs @@ -1743,8 +1743,12 @@ fn after_inactive_cycle_forbid_non_bootstrapper_registration() { #[test] fn grow_population_and_removing_community_works() { new_test_ext().execute_with(|| { - let cid = perform_bootstrapping_ceremony(None, 3); let mut participants = bootstrappers(); + participants.extend(add_population(5, participants.len())); + let cid = perform_bootstrapping_ceremony( + Some(participants.clone().into_iter().map(|b| account_id(&b)).collect()), + 3, + ); // generate many keys and register all of them // they will use the same keys per participant throughout to following ceremonies @@ -1762,7 +1766,7 @@ fn grow_population_and_removing_community_works() { let cindex = EncointerScheduler::current_ceremony_index(); run_to_next_phase(); // Assigning - assert_eq!(EncointerCeremonies::bootstrapper_count((cid, cindex)), 6); + assert_eq!(EncointerCeremonies::bootstrapper_count((cid, cindex)), 11); assert_eq!(EncointerCeremonies::reputable_count((cid, cindex)), 0); assert_eq!(EncointerCeremonies::newbie_count((cid, cindex)), 14); assert_eq!(EncointerCeremonies::meetup_count((cid, cindex)), 1); @@ -1788,14 +1792,15 @@ fn grow_population_and_removing_community_works() { run_to_next_phase(); // Assigning - assert_eq!(EncointerCeremonies::bootstrapper_count((cid, cindex)), 6); - assert_eq!(EncointerCeremonies::reputable_count((cid, cindex)), 2); - assert_eq!(EncointerCeremonies::newbie_count((cid, cindex)), 12); - assert_eq!(EncointerCeremonies::meetup_count((cid, cindex)), 1); + assert_eq!(EncointerCeremonies::bootstrapper_count((cid, cindex)), 11); + assert_eq!(EncointerCeremonies::reputable_count((cid, cindex)), 3); + assert_eq!(EncointerCeremonies::newbie_count((cid, cindex)), 11); + assert_eq!(EncointerCeremonies::meetup_count((cid, cindex)), 2); run_to_next_phase(); fully_attest_meetup(cid, 1); + fully_attest_meetup(cid, 2); run_to_next_phase(); // Registering @@ -1813,9 +1818,9 @@ fn grow_population_and_removing_community_works() { run_to_next_phase(); // Assigning - assert_eq!(EncointerCeremonies::bootstrapper_count((cid, cindex)), 6); - assert_eq!(EncointerCeremonies::reputable_count((cid, cindex)), 4); - assert_eq!(EncointerCeremonies::newbie_count((cid, cindex)), 10); + assert_eq!(EncointerCeremonies::bootstrapper_count((cid, cindex)), 11); + assert_eq!(EncointerCeremonies::reputable_count((cid, cindex)), 7); + assert_eq!(EncointerCeremonies::newbie_count((cid, cindex)), 7); assert_eq!(EncointerCeremonies::meetup_count((cid, cindex)), 2); run_to_next_phase(); @@ -1841,7 +1846,11 @@ fn grow_population_and_removing_community_works() { } run_to_next_phase(); // Assigning - assert_eq!(proof_count, 13); + // 11 bootstrappers + 3 + 4 + 6 + // ceremony 1 : add 3 reputables floor(11 / 3) + // ceremony 2 : add 4 reputables floor(14 / 3) + // ceremony 3 : add 6 reputables floor(18 / 3) + assert_eq!(proof_count, 24); assert_eq!(EncointerCeremonies::meetup_count((cid, cindex)), 2); // now we remove the community @@ -2282,8 +2291,8 @@ fn get_meetup_participants_works() { exp_n_assigned_reputables, exp_n_assigned_endorsees, exp_n_assigned_newbies, - case(3, 7, 12, 6, 13, 19, 5, 5, 7, 12, 6, 5), - case(10, 1, 1, 20, 13, 2, 17, 2, 1, 1, 18, 0) + case(3, 11, 18, 6, 13, 29, 5, 7, 11, 18, 6, 10), + case(10, 1, 1, 30, 13, 2, 23, 2, 1, 1, 28, 0) )] fn generate_meetup_assignment_params_works( n_locations: u64, @@ -2315,7 +2324,9 @@ fn generate_meetup_assignment_params_works( assert_eq!(assigned_counts.bootstrappers, exp_n_assigned_bootstrappers); assert_eq!(assigned_counts.reputables, exp_n_assigned_reputables); + // case 2: we have 2 meetups, so 1 + 1 + 28 + 0 participants assert_eq!(assigned_counts.endorsees, exp_n_assigned_endorsees); + // case 1: 11 + 18 + 6 = 35, and we have 3 meetups, so 45 spots, so 10 newbie spots assert_eq!(assigned_counts.newbies, exp_n_assigned_newbies); let assignment = EncointerCeremonies::assignments((cid, cindex)); diff --git a/communities/src/mock.rs b/communities/src/mock.rs index ea308971..60c1564b 100644 --- a/communities/src/mock.rs +++ b/communities/src/mock.rs @@ -45,7 +45,7 @@ impl dut::Config for TestRuntime { type TrustableForNonDestructiveAction = EnsureAlice; type WeightInfo = (); type MaxCommunityIdentifiers = ConstU32<10>; - type MaxBootstrappers = ConstU32<10>; + type MaxBootstrappers = ConstU32<15>; type MaxLocationsPerGeohash = ConstU32<200>; type MaxCommunityIdentifiersPerGeohash = ConstU32<10>; } diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs index 7d09287e..cc91fc85 100644 --- a/test-utils/src/lib.rs +++ b/test-utils/src/lib.rs @@ -185,7 +185,7 @@ macro_rules! impl_encointer_communities { type TrustableForNonDestructiveAction = EnsureAlice; type WeightInfo = (); type MaxCommunityIdentifiers = ConstU32<10>; - type MaxBootstrappers = ConstU32<10>; + type MaxBootstrappers = ConstU32<15>; type MaxLocationsPerGeohash = ConstU32<10>; type MaxCommunityIdentifiersPerGeohash = ConstU32<10>; } @@ -213,7 +213,7 @@ macro_rules! test_runtime { } parameter_types! { - pub const MeetupSizeTarget: u64 = 10; + pub const MeetupSizeTarget: u64 = 15; pub const MeetupMinSize: u64 = 3; pub const MeetupNewbieLimitDivider: u64 = 3; } @@ -231,7 +231,7 @@ macro_rules! impl_encointer_ceremonies { type MeetupMinSize = MeetupMinSize; type MeetupNewbieLimitDivider = MeetupNewbieLimitDivider; type WeightInfo = (); - type MaxAttestations = ConstU32<10>; + type MaxAttestations = ConstU32<15>; } }; } From 64a0ac75d20d8bb50ae6b45fae060d4aabc5381f Mon Sep 17 00:00:00 2001 From: pifragile Date: Sun, 25 Feb 2024 12:01:27 +0800 Subject: [PATCH 2/5] fix migration test --- ceremonies/src/migrations.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ceremonies/src/migrations.rs b/ceremonies/src/migrations.rs index 1f9e38d2..5ab72edc 100644 --- a/ceremonies/src/migrations.rs +++ b/ceremonies/src/migrations.rs @@ -193,6 +193,11 @@ mod test { AccountId::from(AccountKeyring::Alice), AccountId::from(AccountKeyring::Alice), AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), ]; v0::AttestationRegistry::::insert( From 89d7d4ecc3ec5e2f9b81fcf59f0b008707fec599 Mon Sep 17 00:00:00 2001 From: pifragile Date: Sun, 25 Feb 2024 12:17:23 +0800 Subject: [PATCH 3/5] fix second test --- communities/src/migrations.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/communities/src/migrations.rs b/communities/src/migrations.rs index 4d3b01b7..aefa1632 100644 --- a/communities/src/migrations.rs +++ b/communities/src/migrations.rs @@ -684,6 +684,11 @@ mod test { AccountId::from(AccountKeyring::Dave), AccountId::from(AccountKeyring::Dave), AccountId::from(AccountKeyring::Dave), + AccountId::from(AccountKeyring::Dave), + AccountId::from(AccountKeyring::Dave), + AccountId::from(AccountKeyring::Dave), + AccountId::from(AccountKeyring::Dave), + AccountId::from(AccountKeyring::Dave), ]; v0::Bootstrappers::::insert( CommunityIdentifier::from_str("111112Fvv9d").unwrap(), From 77f2ce8855df10ece7ae1cfa6c9bd79c17ab1015 Mon Sep 17 00:00:00 2001 From: pifragile Date: Mon, 26 Feb 2024 16:53:12 +0800 Subject: [PATCH 4/5] set maxattestations to safe number --- ceremonies/src/mock.rs | 2 +- test-utils/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ceremonies/src/mock.rs b/ceremonies/src/mock.rs index f7753bd0..108a4916 100644 --- a/ceremonies/src/mock.rs +++ b/ceremonies/src/mock.rs @@ -64,7 +64,7 @@ impl dut::Config for TestRuntime { type MeetupMinSize = MeetupMinSize; type MeetupNewbieLimitDivider = MeetupNewbieLimitDivider; type WeightInfo = (); - type MaxAttestations = ConstU32<15>; + type MaxAttestations = ConstU32<25>; } // boilerplate diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs index cc91fc85..18e4f5fe 100644 --- a/test-utils/src/lib.rs +++ b/test-utils/src/lib.rs @@ -231,7 +231,7 @@ macro_rules! impl_encointer_ceremonies { type MeetupMinSize = MeetupMinSize; type MeetupNewbieLimitDivider = MeetupNewbieLimitDivider; type WeightInfo = (); - type MaxAttestations = ConstU32<15>; + type MaxAttestations = ConstU32<25>; } }; } From e048b05096c29cc80148eaa9ab966ceabf23eb7c Mon Sep 17 00:00:00 2001 From: pifragile Date: Mon, 26 Feb 2024 16:57:51 +0800 Subject: [PATCH 5/5] fix attestation test --- ceremonies/src/migrations.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ceremonies/src/migrations.rs b/ceremonies/src/migrations.rs index 5ab72edc..dbd3bfac 100644 --- a/ceremonies/src/migrations.rs +++ b/ceremonies/src/migrations.rs @@ -198,6 +198,16 @@ mod test { AccountId::from(AccountKeyring::Alice), AccountId::from(AccountKeyring::Alice), AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), + AccountId::from(AccountKeyring::Alice), ]; v0::AttestationRegistry::::insert(