Skip to content

Commit

Permalink
Wait for a successful block ingestion in lightwalletd integration
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Mar 10, 2022
1 parent 25c3e27 commit c364034
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,29 +1680,42 @@ fn lightwalletd_integration() -> Result<()> {
let (_, zebrad) = zebrad.kill_on_error(result)?;

// Check that `lightwalletd` is calling the expected Zebra RPCs
//
// TODO: add extra checks when we add new Zebra RPCs

// get_blockchain_info
// getblockchaininfo
let result = lightwalletd.expect_stdout_line_matches("Got sapling height");
let (_, zebrad) = zebrad.kill_on_error(result)?;

let result = lightwalletd.expect_stdout_line_matches("Found 0 blocks in cache");
let (_, zebrad) = zebrad.kill_on_error(result)?;

// Check that `lightwalletd` got to the first unimplemented Zebra RPC
// getblock with block 1 in Zebra's state
//
// TODO: update the missing method name when we add a new Zebra RPC

// zcash/lightwalletd calls getbestblockhash here, but
// adityapk00/lightwalletd calls getblock
let result =
lightwalletd.expect_stdout_line_matches("Block hash changed, clearing mempool clients");
//
// Until block 1 has been downloaded, lightwalletd will log Zebra's RPC error:
// "error requesting block: 0: Block not found"
// But we can't check for that, because Zebra might download genesis before lightwalletd asks.
// We also get a similar log when lightwalletd reaches the end of Zebra's cache.
//
// After the first getblock call, lightwalletd will log:
// "Block hash changed, clearing mempool clients"
// But we can't check for that, because it can come before or after the Ingestor log.
let result = lightwalletd.expect_stdout_line_matches("Ingestor adding block to cache: 1");
let (_, zebrad) = zebrad.kill_on_error(result)?;

// (next RPC)
//
// TODO: add extra checks when we add new Zebra RPCs

// Unimplemented getrawmempool (repeated, in a separate lightwalletd thread)
//
// zcash/lightwalletd exits with a fatal error here.
// adityapk00/lightwalletd keeps trying the mempool,
// but it sometimes skips the "Method not found" log line.
//
// If a refresh is pending, we can get "Mempool refresh error" before the Ingestor log,
// and "Another refresh is in progress" after it.
let result =
lightwalletd.expect_stdout_line_matches("(Mempool refresh error: -32601: Method not found)|(Another refresh in progress, returning)");
let (_, zebrad) = zebrad.kill_on_error(result)?;
Expand Down

0 comments on commit c364034

Please sign in to comment.