Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into tomasz-test-keepdb
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Oct 27, 2023
2 parents 503aa2c + 686ae7c commit e3fb672
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
6 changes: 1 addition & 5 deletions pallets/configuration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub struct HostConfiguration {
pub min_orchestrator_collators: u32,
pub max_orchestrator_collators: u32,
pub collators_per_container: u32,
// If this value is 0 means that there is no rotation
pub full_rotation_period: u32,
}

Expand All @@ -94,8 +95,6 @@ pub enum InconsistentError {
MinOrchestratorCollatorsTooLow,
/// `max_collators` must be at least 1
MaxCollatorsTooLow,
/// `full_rotation_period` must be at least 1
FullRotationPeriodTooLow,
}

impl HostConfiguration {
Expand All @@ -114,9 +113,6 @@ impl HostConfiguration {
if self.max_orchestrator_collators < self.min_orchestrator_collators {
return Err(InconsistentError::MaxCollatorsLowerThanMinCollators);
}
if self.full_rotation_period < 1 {
return Err(InconsistentError::FullRotationPeriodTooLow);
}
Ok(())
}

Expand Down
47 changes: 47 additions & 0 deletions pallets/configuration/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,53 @@ fn config_set_value() {
});
}

#[test]
fn config_set_full_rotation_period_to_zero_works() {
new_test_ext_with_genesis(HostConfiguration {
max_collators: 100,
min_orchestrator_collators: 2,
max_orchestrator_collators: 5,
collators_per_container: 2,
full_rotation_period: 24,
})
.execute_with(|| {
run_to_block(1);
assert_eq!(Configuration::config().full_rotation_period, 24);
assert_ok!(
Configuration::set_full_rotation_period(RuntimeOrigin::root(), 0),
()
);

assert_eq!(
PendingConfigs::<Test>::get(),
vec![(
2,
HostConfiguration {
max_collators: 100,
min_orchestrator_collators: 2,
max_orchestrator_collators: 5,
collators_per_container: 2,
full_rotation_period: 0,
}
)]
);

// The session delay is set to 2, and one session is 5 blocks,
// so the change should not happen until block 11
assert_eq!(Configuration::config().full_rotation_period, 24);
run_to_block(2);
assert_eq!(Configuration::config().full_rotation_period, 24);
// First block of session 1
run_to_block(6);
assert_eq!(Configuration::config().full_rotation_period, 24);
run_to_block(10);
assert_eq!(Configuration::config().full_rotation_period, 24);
// First block of session 2
run_to_block(11);
assert_eq!(Configuration::config().full_rotation_period, 0);
});
}

#[test]
fn config_set_many_values_same_block() {
new_test_ext_with_genesis(HostConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion test/suites/para/test_tanssi_containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describeSuite({
it({
id: "T13",
title: "Blocks are being produced on container 2002",
timeout: 60000,
timeout: 90000,
test: async function () {
let blockNum = (await container2002Api.rpc.chain.getBlock()).block.header.number.toNumber();

Expand Down

0 comments on commit e3fb672

Please sign in to comment.