Skip to content

Commit ff75d8f

Browse files
committed
f - use hashset, merge functions
1 parent 22bec08 commit ff75d8f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,12 @@ impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
532532
}
533533
});
534534
}
535-
}
536535

537-
#[cfg(test)]
538-
pub fn disable_unborn_channel_signer_op(&self, signer_op: SignerOp) {
539-
self.keys_manager.disable_next_signer_ops.lock().unwrap().push(signer_op);
536+
if available {
537+
self.keys_manager.disable_next_signer_ops.lock().unwrap().remove(&signer_op);
538+
} else {
539+
self.keys_manager.disable_next_signer_ops.lock().unwrap().insert(signer_op);
540+
}
540541
}
541542
}
542543

lightning/src/util/test_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ pub struct TestKeysInterface {
12171217
enforcement_states: Mutex<HashMap<[u8;32], Arc<Mutex<EnforcementState>>>>,
12181218
expectations: Mutex<Option<VecDeque<OnGetShutdownScriptpubkey>>>,
12191219
/// Holds a list of signer ops to disable for the next signer created by this interface.
1220-
pub disable_next_signer_ops: Mutex<Vec<SignerOp>>,
1220+
pub disable_next_signer_ops: Mutex<HashSet<SignerOp>>,
12211221
}
12221222

12231223
impl EntropySource for TestKeysInterface {
@@ -1278,8 +1278,8 @@ impl SignerProvider for TestKeysInterface {
12781278
let state = self.make_enforcement_state_cell(keys.commitment_seed);
12791279
let mut signer = TestChannelSigner::new_with_revoked(keys, state, self.disable_revocation_policy_check);
12801280
#[cfg(test)]
1281-
for op in self.disable_next_signer_ops.lock().unwrap().drain(..) {
1282-
signer.disable_op(op)
1281+
for op in self.disable_next_signer_ops.lock().unwrap().iter() {
1282+
signer.disable_op(*op)
12831283
}
12841284
signer
12851285
}
@@ -1319,7 +1319,7 @@ impl TestKeysInterface {
13191319
disable_revocation_policy_check: false,
13201320
enforcement_states: Mutex::new(new_hash_map()),
13211321
expectations: Mutex::new(None),
1322-
disable_next_signer_ops: Mutex::new(vec![]),
1322+
disable_next_signer_ops: Mutex::new(HashSet::new()),
13231323
}
13241324
}
13251325

0 commit comments

Comments
 (0)