You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optionally disable all state-based policy checks in test signer
The signer we use in tests tracks the state of the channel and
refuses to sign when the channel attempts an invalid state
transition. In the next commit, however, we'll add an upgrade test
which will fail these checks as the the state won't get copied from
previous versions of LDK to this version.
Thus, here, we add the ability to disable all state-based checks
in the signer.
@@ -174,12 +180,12 @@ impl ChannelSigner for TestChannelSigner {
174
180
if !self.is_signer_available(SignerOp::ReleaseCommitmentSecret){
175
181
returnErr(());
176
182
}
177
-
{
178
-
letmut state = self.state.lock().unwrap();
183
+
letmut state = self.state.lock().unwrap();
184
+
if !self.disable_all_state_policy_checks{
179
185
assert!(idx == state.last_holder_revoked_commitment || idx == state.last_holder_revoked_commitment - 1,"can only revoke the current or next unrevoked commitment - trying {}, last revoked {}", idx, state.last_holder_revoked_commitment);
180
186
assert!(idx > state.last_holder_commitment,"cannot revoke the last holder commitment - attempted to revoke {} last commitment {}", idx, state.last_holder_commitment);
181
-
state.last_holder_revoked_commitment = idx;
182
187
}
188
+
state.last_holder_revoked_commitment = idx;
183
189
self.inner.release_commitment_secret(idx)
184
190
}
185
191
@@ -189,12 +195,14 @@ impl ChannelSigner for TestChannelSigner {
"expecting to validate the current or next holder commitment - trying {}, current {}",
202
+
idx,
203
+
state.last_holder_commitment
204
+
);
205
+
}
198
206
state.last_holder_commitment = idx;
199
207
Ok(())
200
208
}
@@ -205,7 +213,9 @@ impl ChannelSigner for TestChannelSigner {
205
213
returnErr(());
206
214
}
207
215
letmut state = self.state.lock().unwrap();
208
-
assert!(idx == state.last_counterparty_revoked_commitment || idx == state.last_counterparty_revoked_commitment - 1,"expecting to validate the current or next counterparty revocation - trying {}, current {}", idx, state.last_counterparty_revoked_commitment);
216
+
if !self.disable_all_state_policy_checks{
217
+
assert!(idx == state.last_counterparty_revoked_commitment || idx == state.last_counterparty_revoked_commitment - 1,"expecting to validate the current or next counterparty revocation - trying {}, current {}", idx, state.last_counterparty_revoked_commitment);
218
+
}
209
219
state.last_counterparty_revoked_commitment = idx;
210
220
Ok(())
211
221
}
@@ -227,14 +237,14 @@ impl EcdsaChannelSigner for TestChannelSigner {
0 commit comments