mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Improve tests
This commit is contained in:
@@ -283,14 +283,7 @@ pub mod tests {
|
|||||||
.find(|validator| validator.validating_pubkey == local_pubkey)
|
.find(|validator| validator.validating_pubkey == local_pubkey)
|
||||||
.expect("validator must exist on VC");
|
.expect("validator must exist on VC");
|
||||||
assert_eq!(&remote_validator.derivation_path, &local_keystore.path());
|
assert_eq!(&remote_validator.derivation_path, &local_keystore.path());
|
||||||
// It's not immediately clear why Lighthouse returns `None` rather than
|
assert_eq!(remote_validator.readonly, Some(false));
|
||||||
// `Some(false)` here, I would expect the latter to be the most accurate.
|
|
||||||
// However, it doesn't seem like a big deal.
|
|
||||||
//
|
|
||||||
// See: https://github.com/sigp/lighthouse/pull/3490
|
|
||||||
//
|
|
||||||
// If that PR changes we'll need to change this line.
|
|
||||||
assert_eq!(remote_validator.readonly, None);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ pub const GAS_LIMIT_FLAG: &str = "gas-limit";
|
|||||||
pub const FEE_RECIPIENT_FLAG: &str = "suggested-fee-recipient";
|
pub const FEE_RECIPIENT_FLAG: &str = "suggested-fee-recipient";
|
||||||
pub const BUILDER_PROPOSALS_FLAG: &str = "builder-proposals";
|
pub const BUILDER_PROPOSALS_FLAG: &str = "builder-proposals";
|
||||||
|
|
||||||
|
const NO_VALIDATORS_MSG: &str = "No validators present on source validator client";
|
||||||
|
|
||||||
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||||
App::new(CMD)
|
App::new(CMD)
|
||||||
.about(
|
.about(
|
||||||
@@ -248,6 +250,10 @@ async fn run<'a>(config: MoveConfig) -> Result<(), String> {
|
|||||||
let (dest_http_client, _dest_keystores) =
|
let (dest_http_client, _dest_keystores) =
|
||||||
vc_http_client(dest_vc_url.clone(), &dest_vc_token_path).await?;
|
vc_http_client(dest_vc_url.clone(), &dest_vc_token_path).await?;
|
||||||
|
|
||||||
|
if src_keystores.is_empty() {
|
||||||
|
return Err(NO_VALIDATORS_MSG.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
let pubkeys_to_move = match validators {
|
let pubkeys_to_move = match validators {
|
||||||
Validators::All => src_keystores.iter().map(|v| v.validating_pubkey).collect(),
|
Validators::All => src_keystores.iter().map(|v| v.validating_pubkey).collect(),
|
||||||
Validators::Some(request_pubkeys) => {
|
Validators::Some(request_pubkeys) => {
|
||||||
@@ -561,13 +567,14 @@ mod test {
|
|||||||
where
|
where
|
||||||
F: Fn(&[PublicKeyBytes]) -> Validators,
|
F: Fn(&[PublicKeyBytes]) -> Validators,
|
||||||
{
|
{
|
||||||
let import_test_result = self
|
let src_vc = if let Some(import_builder) = self.import_builder {
|
||||||
.import_builder
|
let import_test_result = import_builder.run_test().await;
|
||||||
.expect("test requires an import builder")
|
assert!(import_test_result.result.is_ok());
|
||||||
.run_test()
|
import_test_result.vc
|
||||||
.await;
|
} else {
|
||||||
assert!(import_test_result.result.is_ok());
|
ApiTester::new().await
|
||||||
let src_vc = import_test_result.vc;
|
};
|
||||||
|
|
||||||
let src_vc_token_path = self.dir.path().join(SRC_VC_TOKEN_FILE_NAME);
|
let src_vc_token_path = self.dir.path().join(SRC_VC_TOKEN_FILE_NAME);
|
||||||
fs::write(&src_vc_token_path, &src_vc.api_token).unwrap();
|
fs::write(&src_vc_token_path, &src_vc.api_token).unwrap();
|
||||||
let (src_vc_client, src_vc_initial_keystores) =
|
let (src_vc_client, src_vc_initial_keystores) =
|
||||||
@@ -599,7 +606,7 @@ mod test {
|
|||||||
|
|
||||||
let result = run(move_config).await;
|
let result = run(move_config).await;
|
||||||
|
|
||||||
let (dest_vc_client, dest_vc_keystores) =
|
let (_dest_vc_client, dest_vc_keystores) =
|
||||||
vc_http_client(dest_vc.url.clone(), &dest_vc_token_path)
|
vc_http_client(dest_vc.url.clone(), &dest_vc_token_path)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -634,6 +641,15 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn no_validators() {
|
||||||
|
TestBuilder::new()
|
||||||
|
.await
|
||||||
|
.run_test(|_| Validators::All)
|
||||||
|
.await
|
||||||
|
.assert_err_is(NO_VALIDATORS_MSG.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn one_validator_move_all() {
|
async fn one_validator_move_all() {
|
||||||
TestBuilder::new()
|
TestBuilder::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user