Skip to content

Commit 574bd6e

Browse files
committed
Remove global availability logic for testing async signing
1 parent a922904 commit 574bd6e

File tree

5 files changed

+0
-70
lines changed

5 files changed

+0
-70
lines changed

lightning/src/chain/channelmonitor.rs

-6
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

-6
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

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

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

lightning/src/util/test_channel_signer.rs

-14
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

-3
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)