From d2aef1b35c5057780fa04607d43671ad8518609d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 31 Jan 2024 16:25:55 +1100 Subject: [PATCH] Fix bug in `--builder-proposals` (#5151) * Fix bug in `--builder-proposals` * Add tests * More sensible test order * Fix duplicate builder-boost test case * Cargo fmt and rename --- validator_client/src/http_api/tests.rs | 52 +++++++++++++++++++++++++ validator_client/src/validator_store.rs | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/validator_client/src/http_api/tests.rs b/validator_client/src/http_api/tests.rs index f7db76e4a..9dc4e1a89 100644 --- a/validator_client/src/http_api/tests.rs +++ b/validator_client/src/http_api/tests.rs @@ -1177,6 +1177,58 @@ async fn validator_derived_builder_boost_factor_with_process_defaults() { .await; } +#[tokio::test] +async fn validator_builder_boost_factor_global_builder_proposals_true() { + let config = Config { + builder_proposals: true, + prefer_builder_proposals: false, + builder_boost_factor: None, + ..Config::default() + }; + ApiTester::new_with_config(config) + .await + .assert_default_builder_boost_factor(None); +} + +#[tokio::test] +async fn validator_builder_boost_factor_global_builder_proposals_false() { + let config = Config { + builder_proposals: false, + prefer_builder_proposals: false, + builder_boost_factor: None, + ..Config::default() + }; + ApiTester::new_with_config(config) + .await + .assert_default_builder_boost_factor(Some(0)); +} + +#[tokio::test] +async fn validator_builder_boost_factor_global_prefer_builder_proposals_true() { + let config = Config { + builder_proposals: true, + prefer_builder_proposals: true, + builder_boost_factor: None, + ..Config::default() + }; + ApiTester::new_with_config(config) + .await + .assert_default_builder_boost_factor(Some(u64::MAX)); +} + +#[tokio::test] +async fn validator_builder_boost_factor_global_prefer_builder_proposals_true_override() { + let config = Config { + builder_proposals: false, + prefer_builder_proposals: true, + builder_boost_factor: None, + ..Config::default() + }; + ApiTester::new_with_config(config) + .await + .assert_default_builder_boost_factor(Some(u64::MAX)); +} + #[tokio::test] async fn prefer_builder_proposals_validator() { ApiTester::new() diff --git a/validator_client/src/validator_store.rs b/validator_client/src/validator_store.rs index c913b9906..a2298d303 100644 --- a/validator_client/src/validator_store.rs +++ b/validator_client/src/validator_store.rs @@ -572,7 +572,7 @@ impl ValidatorStore { return Some(u64::MAX); } self.builder_boost_factor.or({ - if self.builder_proposals { + if !self.builder_proposals { Some(0) } else { None