From bdbd481009272bf880213119676c263810bc8c36 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 2 May 2022 12:32:17 +0200 Subject: [PATCH] commands: remove the unit test of listpresigned txs It's not that useful as listpresignedtxs is already exercised under all conditions by the functional tests. And it would be a MAJOR pain to move it to the multi-cancel logic. As the usefulness / time spent ratio is very low, just drop it. I'd still like to add it back if possible, but definitely not with hardcoded PSBTs. --- src/commands/utils.rs | 211 ------------------------------------------ 1 file changed, 211 deletions(-) diff --git a/src/commands/utils.rs b/src/commands/utils.rs index 242a2f2a..4e4ea387 100644 --- a/src/commands/utils.rs +++ b/src/commands/utils.rs @@ -946,217 +946,6 @@ mod tests { fs::remove_dir_all(&datadir).unwrap_or_else(|_| ()); } - #[test] - fn test_presigned_txs() { - let datadir_stk = test_datadir(); - let datadir_man = test_datadir(); - let mut stake_revaultd = dummy_revaultd(datadir_stk.clone(), UserRole::Stakeholder); - let mut man_revaultd = dummy_revaultd(datadir_man.clone(), UserRole::Manager); - setup_db(&mut stake_revaultd).unwrap(); - let vaults = create_vaults(&stake_revaultd); - setup_db(&mut man_revaultd).unwrap(); - let _ = create_vaults(&man_revaultd); - - // vault[0] is not confirmed, no presigned txs here! - assert!(presigned_txs(&stake_revaultd, vec![vaults[0].db_vault.clone()]).is_none()); - - // vault[1] is funded, no txs is final - // The stakeholder has all the txs - let stake_txs = presigned_txs(&stake_revaultd, vec![vaults[1].db_vault.clone()]).unwrap(); - assert_eq!(stake_txs.len(), 1); - assert_eq!( - stake_txs[0].vault_outpoint, - vaults[1].db_vault.deposit_outpoint - ); - assert_eq!( - stake_txs[0].cancel, - vaults[1].transactions.as_ref().unwrap().initial_cancel - ); - assert_eq!( - stake_txs[0].unvault, - vaults[1].transactions.as_ref().unwrap().initial_unvault - ); - assert_eq!( - stake_txs[0].emergency.as_ref().unwrap(), - &vaults[1].transactions.as_ref().unwrap().initial_emer - ); - assert_eq!( - stake_txs[0].unvault_emergency.as_ref().unwrap(), - &vaults[1] - .transactions - .as_ref() - .unwrap() - .initial_unvault_emer - ); - - // The manager has the same txs, but no emergency - let man_txs = presigned_txs(&man_revaultd, vec![vaults[1].db_vault.clone()]).unwrap(); - assert_eq!(man_txs.len(), 1); - assert_eq!( - man_txs[0].vault_outpoint, - vaults[1].db_vault.deposit_outpoint - ); - assert_eq!( - man_txs[0].cancel, - vaults[1].transactions.as_ref().unwrap().initial_cancel - ); - assert_eq!( - man_txs[0].unvault, - vaults[1].transactions.as_ref().unwrap().initial_unvault - ); - assert!(man_txs[0].emergency.is_none()); - assert!(man_txs[0].unvault_emergency.is_none()); - - // vault[2] is secured, the unvault tx is not final - // The stakeholder has all the txs - let stake_txs = presigned_txs(&stake_revaultd, vec![vaults[2].db_vault.clone()]).unwrap(); - assert_eq!(stake_txs.len(), 1); - assert_eq!( - stake_txs[0].vault_outpoint, - vaults[2].db_vault.deposit_outpoint - ); - assert_eq!( - &stake_txs[0].cancel, - vaults[2] - .transactions - .as_ref() - .unwrap() - .final_cancel - .as_ref() - .unwrap() - ); - assert_eq!( - stake_txs[0].unvault, - vaults[2].transactions.as_ref().unwrap().initial_unvault - ); - assert_eq!( - stake_txs[0].emergency.as_ref().unwrap(), - vaults[2] - .transactions - .as_ref() - .unwrap() - .final_emer - .as_ref() - .unwrap() - ); - assert_eq!( - stake_txs[0].unvault_emergency.as_ref().unwrap(), - vaults[2] - .transactions - .as_ref() - .unwrap() - .final_unvault_emer - .as_ref() - .unwrap() - ); - - // The manager has the same txs, but no emergency - let man_txs = presigned_txs(&man_revaultd, vec![vaults[2].db_vault.clone()]).unwrap(); - assert_eq!(man_txs.len(), 1); - assert_eq!( - man_txs[0].vault_outpoint, - vaults[2].db_vault.deposit_outpoint - ); - assert_eq!( - &man_txs[0].cancel, - vaults[2] - .transactions - .as_ref() - .unwrap() - .final_cancel - .as_ref() - .unwrap() - ); - assert_eq!( - man_txs[0].unvault, - vaults[2].transactions.as_ref().unwrap().initial_unvault - ); - assert!(man_txs[0].emergency.is_none()); - assert!(man_txs[0].unvault_emergency.is_none()); - - // vault[3] is active, every tx is final - // The stakeholder has all the txs - let stake_txs = presigned_txs(&stake_revaultd, vec![vaults[3].db_vault.clone()]).unwrap(); - assert_eq!(stake_txs.len(), 1); - assert_eq!( - stake_txs[0].vault_outpoint, - vaults[3].db_vault.deposit_outpoint - ); - assert_eq!( - &stake_txs[0].cancel, - vaults[3] - .transactions - .as_ref() - .unwrap() - .final_cancel - .as_ref() - .unwrap() - ); - assert_eq!( - &stake_txs[0].unvault, - vaults[3] - .transactions - .as_ref() - .unwrap() - .final_unvault - .as_ref() - .unwrap() - ); - assert_eq!( - stake_txs[0].emergency.as_ref().unwrap(), - vaults[3] - .transactions - .as_ref() - .unwrap() - .final_emer - .as_ref() - .unwrap() - ); - assert_eq!( - stake_txs[0].unvault_emergency.as_ref().unwrap(), - vaults[3] - .transactions - .as_ref() - .unwrap() - .final_unvault_emer - .as_ref() - .unwrap() - ); - - // The manager has the same txs, but no emergency - let man_txs = presigned_txs(&man_revaultd, vec![vaults[3].db_vault.clone()]).unwrap(); - assert_eq!(man_txs.len(), 1); - assert_eq!( - man_txs[0].vault_outpoint, - vaults[3].db_vault.deposit_outpoint - ); - assert_eq!( - &man_txs[0].cancel, - vaults[3] - .transactions - .as_ref() - .unwrap() - .final_cancel - .as_ref() - .unwrap() - ); - assert_eq!( - &man_txs[0].unvault, - vaults[3] - .transactions - .as_ref() - .unwrap() - .final_unvault - .as_ref() - .unwrap() - ); - assert!(man_txs[0].emergency.is_none()); - assert!(man_txs[0].unvault_emergency.is_none()); - - fs::remove_dir_all(&datadir_stk).unwrap_or_else(|_| ()); - fs::remove_dir_all(&datadir_man).unwrap_or_else(|_| ()); - } - #[test] fn test_finalized_emer_txs() { let datadir = test_datadir();