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
This commit is contained in:
Michael Sproul 2024-01-31 16:25:55 +11:00 committed by GitHub
parent b035638f9b
commit d2aef1b35c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 1 deletions

View File

@ -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()

View File

@ -572,7 +572,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
return Some(u64::MAX);
}
self.builder_boost_factor.or({
if self.builder_proposals {
if !self.builder_proposals {
Some(0)
} else {
None