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.
@@ -180,12 +186,12 @@ impl ChannelSigner for TestChannelSigner {
180
186
if !self.is_signer_available(SignerOp::ReleaseCommitmentSecret){
181
187
returnErr(());
182
188
}
183
-
{
184
-
letmut state = self.state.lock().unwrap();
189
+
letmut state = self.state.lock().unwrap();
190
+
if !self.disable_all_state_policy_checks{
185
191
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);
186
192
assert!(idx > state.last_holder_commitment,"cannot revoke the last holder commitment - attempted to revoke {} last commitment {}", idx, state.last_holder_commitment);
187
-
state.last_holder_revoked_commitment = idx;
188
193
}
194
+
state.last_holder_revoked_commitment = idx;
189
195
self.inner.release_commitment_secret(idx)
190
196
}
191
197
@@ -195,12 +201,14 @@ impl ChannelSigner for TestChannelSigner {
"expecting to validate the current or next holder commitment - trying {}, current {}",
208
+
idx,
209
+
state.last_holder_commitment
210
+
);
211
+
}
204
212
state.last_holder_commitment = idx;
205
213
Ok(())
206
214
}
@@ -211,7 +219,9 @@ impl ChannelSigner for TestChannelSigner {
211
219
returnErr(());
212
220
}
213
221
letmut state = self.state.lock().unwrap();
214
-
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);
222
+
if !self.disable_all_state_policy_checks{
223
+
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);
224
+
}
215
225
state.last_counterparty_revoked_commitment = idx;
216
226
Ok(())
217
227
}
@@ -236,14 +246,14 @@ impl EcdsaChannelSigner for TestChannelSigner {
0 commit comments