Skip to content

Commit

Permalink
Adjust MeetupSizeTarget to 15 (#372)
Browse files Browse the repository at this point in the history
* meetup size target 15

* fix migration test

* fix second test

* set maxattestations to safe number

* fix attestation test

---------

Co-authored-by: brenzi <brenzi@users.noreply.github.com>
  • Loading branch information
pifragile and brenzi authored Feb 26, 2024
1 parent 66805f4 commit 14e5d74
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
15 changes: 15 additions & 0 deletions ceremonies/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ 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),
AccountId::from(AccountKeyring::Alice),
AccountId::from(AccountKeyring::Alice),
AccountId::from(AccountKeyring::Alice),
AccountId::from(AccountKeyring::Alice),
AccountId::from(AccountKeyring::Alice),
];

v0::AttestationRegistry::<TestRuntime>::insert(
Expand Down
4 changes: 2 additions & 2 deletions ceremonies/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -64,7 +64,7 @@ impl dut::Config for TestRuntime {
type MeetupMinSize = MeetupMinSize;
type MeetupNewbieLimitDivider = MeetupNewbieLimitDivider;
type WeightInfo = ();
type MaxAttestations = ConstU32<10>;
type MaxAttestations = ConstU32<25>;
}

// boilerplate
Expand Down
35 changes: 23 additions & 12 deletions ceremonies/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions communities/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<TestRuntime>::insert(
CommunityIdentifier::from_str("111112Fvv9d").unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion communities/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
Expand Down
6 changes: 3 additions & 3 deletions test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -231,7 +231,7 @@ macro_rules! impl_encointer_ceremonies {
type MeetupMinSize = MeetupMinSize;
type MeetupNewbieLimitDivider = MeetupNewbieLimitDivider;
type WeightInfo = ();
type MaxAttestations = ConstU32<10>;
type MaxAttestations = ConstU32<25>;
}
};
}
Expand Down

0 comments on commit 14e5d74

Please sign in to comment.