Skip to content

Commit

Permalink
Applied CR suggestions pt.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Zajkowski committed May 13, 2024
1 parent 63507d5 commit ae79d19
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 451 deletions.
946 changes: 503 additions & 443 deletions LEGACY_SSE_EMULATION.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion event_sidecar/src/event_stream_server/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ async fn should_serve_events_with_no_query(path: &str, is_legacy_endpoint: bool)
);
}

/// In legacy endpoints not all input events will be re-emitted to output. If an input (2.x) event is not translatable.
/// In legacy endpoints not all input events will be re-emitted to output. If an input (2.x) event is not translatable
/// to 1.x it will be muffled. So we need to adjust the final id to the last event that was 1.x translatable.
fn adjust_final_id(
is_legacy_endpoint: bool,
Expand Down
2 changes: 0 additions & 2 deletions event_sidecar/src/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ async fn connecting_to_node_prior_to_2_0_0_should_fail() {
}

#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
#[ignore] //this test should be re-enabled soon, this is temporary as it was being flaky after the block restructure.
async fn shutdown_should_be_passed_through_when_versions_change() {
let (
testing_config,
Expand Down Expand Up @@ -568,7 +567,6 @@ async fn sidecar_should_use_start_from_if_database_is_not_empty() {
}

#[tokio::test(flavor = "multi_thread", worker_threads = 8)]
#[ignore] //this test should be re-enabled soon, this is temporary as it was being flaky after the block restructure.
async fn sidecar_should_connect_to_multiple_nodes() {
let (sse_port_1, rest_port_1, mut mock_node_1) =
build_2_0_0(sse_server_example_2_0_0_data()).await;
Expand Down
2 changes: 1 addition & 1 deletion types/src/legacy_sse_data/translate_block_added.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ mod tests {
let under_test = DefaultEraEndV2Translator;
let era_end_v2 = era_end_v2();
let maybe_translated = under_test.translate(&era_end_v2);
assert!(maybe_translated.is_some());
assert!(maybe_translated.is_some(), "{:?}", maybe_translated);
let translated = maybe_translated.unwrap();
let mut expected_validator_weights = BTreeMap::new();
expected_validator_weights.insert(
Expand Down
6 changes: 3 additions & 3 deletions types/src/legacy_sse_data/translate_execution_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mod tests {

let maybe_translated = under_test.translate(&effects);

assert!(maybe_translated.is_some());
assert!(maybe_translated.is_some(), "{:?}", maybe_translated);
let translated = maybe_translated.unwrap();
assert!(translated.operations.is_empty());
assert_eq!(
Expand All @@ -231,7 +231,7 @@ mod tests {
}

#[test]
fn default_execution_effects_translator_should_empty_trnsforms_if_something_was_not_translatable(
fn default_execution_effects_translator_should_empty_transforms_if_something_was_not_translatable(
) {
let mut rng = TestRng::new();
let under_test = DefaultExecutionEffectsTranslator {};
Expand All @@ -246,7 +246,7 @@ mod tests {

let maybe_translated = under_test.translate(&effects);

assert!(maybe_translated.is_some());
assert!(maybe_translated.is_some(), "{:?}", maybe_translated);
let translated = maybe_translated.unwrap();
assert!(translated.operations.is_empty());
assert!(translated.transforms.is_empty());
Expand Down
2 changes: 1 addition & 1 deletion types/src/sse_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pub mod test_support {
}

pub fn example_block_added_2_0_0(hash: &str, height: u64) -> String {
let raw_block_added = json!({"BlockAdded":{"block_hash":"0afaafa0983eeb216049d2be396d7689119bd2367087a94a30de53b1887ec592","block":{"Version2":{"hash":hash,"header":{"parent_hash":"327a6be4f8b23115e089875428ff03d9071a7020ce3e0f4734c43e4279ad77fc","state_root_hash":"4f1638725e8a92ad6432a76124ba4a6db365b00ff352beb58b8c48ed9ed4b68d","body_hash":"337a4c9e510e01e142a19e5d81203bdc43e59a4f9039288c01f7b89370e1d104","random_bit":true,"accumulated_seed":"7b7d7b18668dcc8ffecda5f5de1037f26cd61394f72357cdc9ba84f0f48e37c8","era_end":null,"timestamp":"2024-05-10T19:55:20.415Z","era_id":77,"height":height,"protocol_version":"2.0.0","proposer":"01cee2ff4318180282a73bfcd1446f8145e4d80508fecd76fc38dce13af491f0e5","current_gas_price":1,"last_switch_block_hash":"a3533c2625c6413be2287e581c5fca1a0165ebac02b051f9f07ccf1ad483cf2d"},"body":{"transactions":{"0":[],"1":[],"2":[],"3":[]},"rewarded_signatures":[[248],[0],[0]]}}}}}).to_string();
let raw_block_added = json!({"BlockAdded":{"block_hash":hash,"block":{"Version2":{"hash":hash,"header":{"parent_hash":"327a6be4f8b23115e089875428ff03d9071a7020ce3e0f4734c43e4279ad77fc","state_root_hash":"4f1638725e8a92ad6432a76124ba4a6db365b00ff352beb58b8c48ed9ed4b68d","body_hash":"337a4c9e510e01e142a19e5d81203bdc43e59a4f9039288c01f7b89370e1d104","random_bit":true,"accumulated_seed":"7b7d7b18668dcc8ffecda5f5de1037f26cd61394f72357cdc9ba84f0f48e37c8","era_end":null,"timestamp":"2024-05-10T19:55:20.415Z","era_id":77,"height":height,"protocol_version":"2.0.0","proposer":"01cee2ff4318180282a73bfcd1446f8145e4d80508fecd76fc38dce13af491f0e5","current_gas_price":1,"last_switch_block_hash":"a3533c2625c6413be2287e581c5fca1a0165ebac02b051f9f07ccf1ad483cf2d"},"body":{"transactions":{"0":[],"1":[],"2":[],"3":[]},"rewarded_signatures":[[248],[0],[0]]}}}}}).to_string();
super::deserialize(&raw_block_added).unwrap(); // deserializing to make sure that the raw json string is in correct form
raw_block_added
}
Expand Down

0 comments on commit ae79d19

Please sign in to comment.