Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: tests: decrease the bitcoind poll interval #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/daemon/bitcoind/poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,22 @@ fn update_tip(

if tip.height > current_tip.height {
// May just be a new (set of) block(s), make sure we are on the same chain
let bit_curr_hash = bitcoind.getblockhash(current_tip.height)?;
if bit_curr_hash == current_tip.hash || current_tip.height == 0 {
// We moved forward, everything is fine.
new_tip_event(&revaultd, bitcoind, &tip, unvaults_cache)?;
return Ok(current_tip);
match bitcoind.getblockhash(current_tip.height) {
Ok(bit_curr_hash) => {
if bit_curr_hash == current_tip.hash || current_tip.height == 0 {
// We moved forward, everything is fine.
new_tip_event(&revaultd, bitcoind, &tip, unvaults_cache)?;
return Ok(current_tip);
}
}
Err(e) => {
// Edge case: the last block *might* (very unlikely but our functional
// tests are exercing this) have been reorged out and the call to `getblockhash`
// would fail telling the height is out of range.
log::error!("Error while fetching block hash in update tip: '{}'", e);
thread::sleep(Duration::from_secs(5));
return update_tip(revaultd, bitcoind, deposits_cache, unvaults_cache);
}
}
}

Expand Down Expand Up @@ -1240,8 +1251,8 @@ fn handle_confirmed_deposit(
Ok(())
}

// Called when a deposit UTXO disappears from the listunspent result, ie it was spent. This tries
// to figure out where it went.
// Called when a deposit UTXO disappears from the listunspent result, ie it was spent (or reorg'ed
// out). This tries to figure out where it went.
fn handle_spent_deposit(
revaultd: &mut Arc<RwLock<RevaultD>>,
db_path: &Path,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_framework/revaultd.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(
f.write('network = "regtest"\n')
f.write(f"cookie_path = '{bitcoind_cookie}'\n")
f.write(f"addr = '127.0.0.1:{bitcoind.rpcport}'\n")
f.write("poll_interval_secs = 10\n")
f.write("poll_interval_secs = 2\n")

if stk_config is not None:
f.write("[stakeholder_config]\n")
Expand Down