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