Skip to content

Commit

Permalink
Adds stub for acceptance test(s) and removes outdated TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Jun 7, 2024
1 parent 5470979 commit 0d35fc3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion zebra-rpc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ impl SyncerRpcMethods for RpcRequestClient {
}
Err(err) => Err(err),
}
// TODO: Check for the MISSING_BLOCK_ERROR_CODE and return a `Result<Option<_>>`?
}
}

Expand Down
2 changes: 2 additions & 0 deletions zebrad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ progress-bar = [

prometheus = ["metrics-exporter-prometheus"]

rpc-syncer = ["zebra-rpc/syncer"]

# Production features that modify dependency behaviour

# Enable additional error debugging in release builds
Expand Down
40 changes: 40 additions & 0 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3170,3 +3170,43 @@ async fn regtest_submit_blocks() -> Result<()> {
common::regtest::submit_blocks_test().await?;
Ok(())
}

// TODO:
// - Test that chain forks are handled correctly and that `ChainTipChange` sees a `Reset`
// - Test that `ChainTipChange` is updated when the non-finalized best chain grows
// - Test that the `ChainTipChange` updated by the RPC syncer is updated when the finalized tip changes
#[cfg(feature = "rpc-syncer")]
#[tokio::test]
async fn trusted_chain_sync_handles_forks_correctly() -> Result<()> {
let _init_guard = zebra_test::init();
let mut config = random_known_rpc_port_config(false, &Mainnet)?;
config.state.ephemeral = false;
config.network.network = Network::new_regtest(None);

let testdir = testdir()?.with_config(&mut config)?;
let mut child = testdir.spawn_child(args!["start"])?;

std::thread::sleep(LAUNCH_DELAY);

// Spawn a read state with the RPC syncer to check that it has the same best chain as Zebra
let (_read_state, _latest_chain_tip, _chain_tip_change, _sync_task) =
zebra_rpc::sync::init_read_state_with_syncer(
config.state,
&config.network.network,
config.rpc.listen_addr.unwrap(),
)
.await?
.map_err(|err| eyre!(err))?;

// Submit some blocks on the best chain

child.kill(false)?;
let output = child.wait_with_output()?;

// Make sure the command was killed
output.assert_was_killed()?;

output.assert_failure()?;

Ok(())
}

0 comments on commit 0d35fc3

Please sign in to comment.