mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 13:54:44 +00:00
Remove old debugging code, fix API fault
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::response_builder::ResponseBuilder;
|
||||
use crate::{ApiError, ApiResult};
|
||||
use crate::ApiResult;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use hyper::{Body, Request};
|
||||
use std::sync::Arc;
|
||||
@@ -11,8 +11,5 @@ pub fn get_fork_choice<T: BeaconChainTypes>(
|
||||
req: Request<Body>,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
) -> ApiResult {
|
||||
let json = beacon_chain.fork_choice.as_json().map_err(|e| {
|
||||
ApiError::ServerError(format!("Unable to encode fork choice as JSON: {:?}", e))
|
||||
})?;
|
||||
ResponseBuilder::new(&req)?.body_no_ssz(&json)
|
||||
ResponseBuilder::new(&req)?.body_no_ssz(&*beacon_chain.fork_choice.core_proto_array())
|
||||
}
|
||||
|
||||
@@ -799,15 +799,21 @@ fn get_fork_choice() {
|
||||
let node = build_node(&mut env, testing_client_config());
|
||||
let remote_node = node.remote_node().expect("should produce remote node");
|
||||
|
||||
// Ideally we would check that the returned fork choice is the same as the one in the
|
||||
// `beacon_chain`, however that would involve exposing (making public) the core fork choice
|
||||
// struct that is a bit messy.
|
||||
//
|
||||
// Given that serializing the fork choice is just vanilla serde, I think it's fair to assume it
|
||||
// works.
|
||||
env.runtime()
|
||||
let fork_choice = env
|
||||
.runtime()
|
||||
.block_on(remote_node.http.advanced().get_fork_choice())
|
||||
.expect("should not error when getting fork choice");
|
||||
|
||||
assert_eq!(
|
||||
fork_choice,
|
||||
*node
|
||||
.client
|
||||
.beacon_chain()
|
||||
.expect("node should have beacon chain")
|
||||
.fork_choice
|
||||
.core_proto_array(),
|
||||
"result should be as expected"
|
||||
);
|
||||
}
|
||||
|
||||
fn compare_validator_response<T: EthSpec>(
|
||||
|
||||
Reference in New Issue
Block a user