Skip to content

Commit

Permalink
fix: updates to daily recovery test (#3433)
Browse files Browse the repository at this point in the history
Description
---
This PR provides some fixes to debug and hopefully fix the daily recovery test
- Use the debug logging config to produce more verbose logs
- Stop the Utxo Scanner from overriding the seed peers when doing a recovery
- Remove a weird javascript regex panic statement and just reduce the number of retries in the config
- Only run a single daily test to make the logs more readable


How Has This Been Tested?
---
This is to fix some tests
  • Loading branch information
philipr-za authored Oct 8, 2021
1 parent ff6bc38 commit 8ac27be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
8 changes: 1 addition & 7 deletions applications/daily_tests/automatic_recovery_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function run(options = {}) {
grpc_console_wallet_address: "127.0.0.1:18111",
baseDir: options.baseDir || "./temp/base-nodes/",
},
false,
"../../integration_tests/log4rs/wallet.yml",
options.seedWords
);

Expand Down Expand Up @@ -95,12 +95,6 @@ async function run(options = {}) {
};
}

let errMatch = data.match(FAILURE_REGEXP);
// One extra attempt
if (errMatch && parseInt(errMatch[1]) > 1) {
throw new Error(data);
}

return null;
},
});
Expand Down
10 changes: 5 additions & 5 deletions applications/daily_tests/cron_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ async function runWalletRecoveryTest(instances) {
scannedRate,
recoveredAmount,
} = await walletRecoveryTest({
seedWords:
"spare man patrol essay divide hollow trip visual actress sadness country hungry toy blouse body club depend capital sleep aim high recycle crystal abandon",
log: LOG_FILE,
numWallets: instances,
seedWords:
"spare man patrol essay divide hollow trip visual actress sadness country hungry toy blouse body club depend capital sleep aim high recycle crystal abandon",
log: LOG_FILE,
numWallets: instances,
baseDir,
});

Expand Down Expand Up @@ -136,7 +136,7 @@ async function main() {

// ------------------------- CRON ------------------------- //
new CronJob("0 7 * * *", () => runWalletRecoveryTest(1)).start();
new CronJob("30 7 * * *", () => runWalletRecoveryTest(5)).start();
//new CronJob("30 7 * * *", () => runWalletRecoveryTest(5)).start();
new CronJob("0 6 * * *", () =>
runBaseNodeSyncTest(SyncType.Archival)
).start();
Expand Down
11 changes: 9 additions & 2 deletions applications/tari_console_wallet/src/recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use log::*;
use rustyline::Editor;
use tari_app_utilities::utilities::ExitCodes;
use tari_common_types::types::PrivateKey;
use tari_crypto::tari_utilities::hex::Hex;
use tari_key_manager::mnemonic::to_secretkey;
use tari_shutdown::Shutdown;
use tari_wallet::{
Expand Down Expand Up @@ -89,13 +90,19 @@ pub async fn wallet_recovery(wallet: &WalletSqlite, base_node_config: &PeerConfi
let peer_manager = wallet.comms.peer_manager();
let mut peer_public_keys = Vec::with_capacity(peers.len());
for peer in peers {
debug!(
target: LOG_TARGET,
"Peer added: {} (NodeId: {})",
peer.public_key.to_hex(),
peer.node_id.to_hex()
);
peer_public_keys.push(peer.public_key.clone());
peer_manager.add_peer(peer).await?;
}

let mut recovery_task = UtxoScannerService::<WalletSqliteDatabase>::builder()
.with_peers(peer_public_keys)
.with_retry_limit(10)
.with_retry_limit(3)
.build_with_wallet(wallet, shutdown_signal);

let mut event_stream = recovery_task.get_event_receiver();
Expand All @@ -106,7 +113,7 @@ pub async fn wallet_recovery(wallet: &WalletSqlite, base_node_config: &PeerConfi
loop {
match event_stream.recv().await {
Ok(UtxoScannerEvent::ConnectingToBaseNode(peer)) => {
print!("Connecting to base node {}... ", peer);
println!("Connecting to base node {}... ", peer);
},
Ok(UtxoScannerEvent::ConnectedToBaseNode(_, latency)) => {
println!("OK (latency = {:.2?})", latency);
Expand Down
8 changes: 6 additions & 2 deletions base_layer/wallet/src/utxo_scanner_service/utxo_scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,12 @@ where TBackend: WalletBackend + 'static
_ = self.resources.current_base_node_watcher.changed() => {
debug!(target: LOG_TARGET, "Base node change detected.");
let peer = self.resources.current_base_node_watcher.borrow().as_ref().cloned();
if let Some(peer) = peer {
self.peer_seeds = vec![peer.public_key];

// If we are recovering we will stick to the initially provided seeds
if self.mode != UtxoScannerMode::Recovery {
if let Some(peer) = peer {
self.peer_seeds = vec![peer.public_key];
}
}

self.is_running.store(false, Ordering::Relaxed);
Expand Down

0 comments on commit 8ac27be

Please sign in to comment.