Add tests for flags enable-enr-auto-update
and disable-packet-filter
(#2887)
Resolves https://github.com/sigp/lighthouse/issues/2602
## Issue Addressed
https://github.com/sigp/lighthouse/pull/2749#issue-1037552417
> ## Open TODO
> Add tests for boot_node flags `enable-enr-auto-update` and `disable-packet-filter`. They end up in [Discv5Config](9ed2cba6bc/boot_node/src/config.rs (L29)
), which doesn't support serde (de)serialization.
## Proposed Changes
- Added tests for flags `enable-enr-auto-update` and `disable-packet-filter`
- Instead of (de)serialize Discv5Config, added the two fields copied from Discv5Config to BootNodeConfigSerialization.
This commit is contained in:
parent
20941bc0f7
commit
daa3da3758
@ -132,13 +132,15 @@ impl<T: EthSpec> BootNodeConfig<T> {
|
|||||||
|
|
||||||
/// The set of configuration parameters that can safely be (de)serialized.
|
/// The set of configuration parameters that can safely be (de)serialized.
|
||||||
///
|
///
|
||||||
/// Its fields are a subset of the fields of `BootNodeConfig`.
|
/// Its fields are a subset of the fields of `BootNodeConfig`, some of them are copied from `Discv5Config`.
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct BootNodeConfigSerialization {
|
pub struct BootNodeConfigSerialization {
|
||||||
pub listen_socket: SocketAddr,
|
pub listen_socket: SocketAddr,
|
||||||
// TODO: Generalise to multiaddr
|
// TODO: Generalise to multiaddr
|
||||||
pub boot_nodes: Vec<Enr>,
|
pub boot_nodes: Vec<Enr>,
|
||||||
pub local_enr: Enr,
|
pub local_enr: Enr,
|
||||||
|
pub disable_packet_filter: bool,
|
||||||
|
pub enable_enr_auto_update: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BootNodeConfigSerialization {
|
impl BootNodeConfigSerialization {
|
||||||
@ -150,7 +152,7 @@ impl BootNodeConfigSerialization {
|
|||||||
boot_nodes,
|
boot_nodes,
|
||||||
local_enr,
|
local_enr,
|
||||||
local_key: _,
|
local_key: _,
|
||||||
discv5_config: _,
|
discv5_config,
|
||||||
phantom: _,
|
phantom: _,
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
@ -158,6 +160,8 @@ impl BootNodeConfigSerialization {
|
|||||||
listen_socket: *listen_socket,
|
listen_socket: *listen_socket,
|
||||||
boot_nodes: boot_nodes.clone(),
|
boot_nodes: boot_nodes.clone(),
|
||||||
local_enr: local_enr.clone(),
|
local_enr: local_enr.clone(),
|
||||||
|
disable_packet_filter: !discv5_config.enable_packet_filter,
|
||||||
|
enable_enr_auto_update: discv5_config.enr_update,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,9 +139,25 @@ fn enr_port_flag() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add tests for flags `enable-enr-auto-update` and `disable-packet-filter`.
|
#[test]
|
||||||
//
|
fn disable_packet_filter_flag() {
|
||||||
// These options end up in `Discv5Config`, which doesn't support serde (de)serialization.
|
CommandLineTest::new()
|
||||||
|
.flag("disable-packet-filter", None)
|
||||||
|
.run_with_ip()
|
||||||
|
.with_config(|config| {
|
||||||
|
assert_eq!(config.disable_packet_filter, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn enable_enr_auto_update_flag() {
|
||||||
|
CommandLineTest::new()
|
||||||
|
.flag("enable-enr-auto-update", None)
|
||||||
|
.run_with_ip()
|
||||||
|
.with_config(|config| {
|
||||||
|
assert_eq!(config.enable_enr_auto_update, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn network_dir_flag() {
|
fn network_dir_flag() {
|
||||||
|
Loading…
Reference in New Issue
Block a user