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.
@@ -177,19 +178,26 @@ impl ChannelSigner for TestChannelSigner {
177
178
if !self.is_signer_available(SignerOp::ReleaseCommitmentSecret){
178
179
returnErr(());
179
180
}
180
-
{
181
-
letmut state = self.state.lock().unwrap();
181
+
letmut state = self.state.lock().unwrap();
182
+
if !self.disable_all_state_policy_checks{
182
183
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);
183
184
assert!(idx > state.last_holder_commitment,"cannot revoke the last holder commitment - attempted to revoke {} last commitment {}", idx, state.last_holder_commitment);
assert!(idx == state.last_holder_commitment || idx == state.last_holder_commitment - 1,"expecting to validate the current or next holder commitment - trying {}, current {}", idx, state.last_holder_commitment);
"expecting to validate the current or next holder commitment - trying {}, current {}",
197
+
idx,
198
+
state.last_holder_commitment
199
+
);
200
+
}
193
201
state.last_holder_commitment = idx;
194
202
Ok(())
195
203
}
@@ -200,7 +208,9 @@ impl ChannelSigner for TestChannelSigner {
200
208
returnErr(());
201
209
}
202
210
letmut state = self.state.lock().unwrap();
203
-
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);
211
+
if !self.disable_all_state_policy_checks{
212
+
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);
213
+
}
204
214
state.last_counterparty_revoked_commitment = idx;
205
215
Ok(())
206
216
}
@@ -218,22 +228,28 @@ impl EcdsaChannelSigner for TestChannelSigner {
// These commitment numbers are backwards counting. We expect either the same as the previously encountered,
230
240
// or the next one.
231
241
assert!(last_commitment_number == actual_commitment_number || last_commitment_number - 1 == actual_commitment_number,"{} doesn't come after {}", actual_commitment_number, last_commitment_number);
232
242
// Ensure that the counterparty doesn't get more than two broadcastable commitments -
233
243
// the last and the one we are trying to sign
234
-
assert!(actual_commitment_number >= state.last_counterparty_revoked_commitment - 2,"cannot sign a commitment if second to last wasn't revoked - signing {} revoked {}", actual_commitment_number, state.last_counterparty_revoked_commitment);
0 commit comments