Skip to content

Commit

Permalink
commands: remove the unit test of listpresigned txs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
darosior committed May 2, 2022
1 parent aaabf50 commit bdbd481
Showing 1 changed file with 0 additions and 211 deletions.
211 changes: 0 additions & 211 deletions src/commands/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit bdbd481

Please sign in to comment.