Skip to content

Commit 4d96e0c

Browse files
committed
Remove global availability logic for testing async signing
1 parent ccd47fc commit 4d96e0c

File tree

5 files changed

+0
-70
lines changed

5 files changed

+0
-70
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,12 +1923,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
19231923
self.inner.lock().unwrap().counterparty_payment_script = script;
19241924
}
19251925

1926-
#[cfg(test)]
1927-
pub fn do_signer_call<F: FnMut(&Signer) -> ()>(&self, mut f: F) {
1928-
let inner = self.inner.lock().unwrap();
1929-
f(&inner.onchain_tx_handler.signer);
1930-
}
1931-
19321926
#[cfg(test)]
19331927
pub fn do_mut_signer_call<F: FnMut(&mut Signer) -> ()>(&self, mut f: F) {
19341928
let mut inner = self.inner.lock().unwrap();

lightning/src/ln/channel.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,12 +2116,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
21162116
self.outbound_scid_alias
21172117
}
21182118

2119-
/// Returns the holder signer for this channel.
2120-
#[cfg(test)]
2121-
pub fn get_signer(&self) -> &ChannelSignerType<SP> {
2122-
return &self.holder_signer
2123-
}
2124-
21252119
/// Returns the holder signer for this channel.
21262120
#[cfg(test)]
21272121
pub fn get_mut_signer(&mut self) -> &mut ChannelSignerType<SP> {

lightning/src/ln/functional_test_utils.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -482,47 +482,6 @@ impl<'a, 'b, 'c> Node<'a, 'b, 'c> {
482482
pub fn get_block_header(&self, height: u32) -> Header {
483483
self.blocks.lock().unwrap()[height as usize].0.header
484484
}
485-
/// Changes the channel signer's availability for the specified peer and channel.
486-
///
487-
/// When `available` is set to `true`, the channel signer will behave normally. When set to
488-
/// `false`, the channel signer will act like an off-line remote signer and will return `Err` for
489-
/// several of the signing methods. Currently, only `get_per_commitment_point` and
490-
/// `release_commitment_secret` are affected by this setting.
491-
#[cfg(test)]
492-
pub fn set_channel_signer_available(&self, peer_id: &PublicKey, chan_id: &ChannelId, available: bool) {
493-
use crate::sign::ChannelSigner;
494-
log_debug!(self.logger, "Setting channel signer for {} as available={}", chan_id, available);
495-
496-
let per_peer_state = self.node.per_peer_state.read().unwrap();
497-
let chan_lock = per_peer_state.get(peer_id).unwrap().lock().unwrap();
498-
499-
let mut channel_keys_id = None;
500-
if let Some(chan) = chan_lock.channel_by_id.get(chan_id).map(|phase| phase.context()) {
501-
chan.get_signer().as_ecdsa().unwrap().set_available(available);
502-
channel_keys_id = Some(chan.channel_keys_id);
503-
}
504-
505-
let mut monitor = None;
506-
for (funding_txo, channel_id) in self.chain_monitor.chain_monitor.list_monitors() {
507-
if *chan_id == channel_id {
508-
monitor = self.chain_monitor.chain_monitor.get_monitor(funding_txo).ok();
509-
}
510-
}
511-
if let Some(monitor) = monitor {
512-
monitor.do_signer_call(|signer| {
513-
channel_keys_id = channel_keys_id.or(Some(signer.inner.channel_keys_id()));
514-
signer.set_available(available)
515-
});
516-
}
517-
518-
if available {
519-
self.keys_manager.unavailable_signers.lock().unwrap()
520-
.remove(channel_keys_id.as_ref().unwrap());
521-
} else {
522-
self.keys_manager.unavailable_signers.lock().unwrap()
523-
.insert(channel_keys_id.unwrap());
524-
}
525-
}
526485

527486
/// Toggles this node's signer to be available for the given signer operation.
528487
/// This is useful for testing behavior for restoring an async signer that previously

lightning/src/util/test_channel_signer.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ pub struct TestChannelSigner {
7171
/// Channel state used for policy enforcement
7272
pub state: Arc<Mutex<EnforcementState>>,
7373
pub disable_revocation_policy_check: bool,
74-
/// When `true` (the default), the signer will respond immediately with signatures. When `false`,
75-
/// the signer will return an error indicating that it is unavailable.
76-
pub available: Arc<Mutex<bool>>,
7774
/// Set of signer operations that are disabled. If an operation is disabled,
7875
/// the signer will return `Err` when the corresponding method is called.
7976
pub disabled_signer_ops: HashSet<SignerOp>,
@@ -130,7 +127,6 @@ impl TestChannelSigner {
130127
inner,
131128
state,
132129
disable_revocation_policy_check: false,
133-
available: Arc::new(Mutex::new(true)),
134130
disabled_signer_ops: new_hash_set(),
135131
}
136132
}
@@ -145,7 +141,6 @@ impl TestChannelSigner {
145141
inner,
146142
state,
147143
disable_revocation_policy_check,
148-
available: Arc::new(Mutex::new(true)),
149144
disabled_signer_ops: new_hash_set(),
150145
}
151146
}
@@ -157,15 +152,6 @@ impl TestChannelSigner {
157152
self.state.lock().unwrap()
158153
}
159154

160-
/// Marks the signer's availability.
161-
///
162-
/// When `true`, methods are forwarded to the underlying signer as normal. When `false`, some
163-
/// methods will return `Err` indicating that the signer is unavailable. Intended to be used for
164-
/// testing asynchronous signing.
165-
pub fn set_available(&self, available: bool) {
166-
*self.available.lock().unwrap() = available;
167-
}
168-
169155
pub fn enable_op(&mut self, signer_op: SignerOp) {
170156
self.disabled_signer_ops.remove(&signer_op);
171157
}

lightning/src/util/test_utils.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,6 @@ impl SignerProvider for TestKeysInterface {
12771277
let keys = self.backing.derive_channel_signer(channel_value_satoshis, channel_keys_id);
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);
1280-
if self.unavailable_signers.lock().unwrap().contains(&channel_keys_id) {
1281-
signer.set_available(false);
1282-
}
12831280
if let Some(ops) = self.unavailable_signers_ops.lock().unwrap().get(&channel_keys_id) {
12841281
for &op in ops {
12851282
signer.disable_op(op);

0 commit comments

Comments
 (0)