Skip to content

Commit 1ab6d20

Browse files
committed
fix(drive): restore Ok(None) retry and strengthen test assertions
The previous commit incorrectly restricted retry to Err(_) only, but Ok(None) from the non-historical path is a legitimate trigger for historical retry — it means the contract exists in the historical path, not that it's absent. Restoring the _ catch-all preserves the original fix from a7fec8b. Test assertions now require contracts to be returned (not accept None) for cases where the contract definitely exists, eliminating tautological acceptance paths.
1 parent 73c264e commit 1ab6d20

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

packages/rs-drive/src/verify/contract/verify_contract/v0/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ impl Drive {
5656
if contract_known_keeps_history.is_none() {
5757
match &result {
5858
Ok((_, Some(_))) => result,
59-
// Ok(None) is a valid absence proof — contract genuinely doesn't exist.
60-
// Don't retry; the server builds a non-historical query for missing contracts.
61-
Ok((_, None)) => result,
62-
Err(_) => {
59+
_ => {
6360
tracing::debug!(
6461
?contract_id,
6562
"retrying contract verification with history enabled"

packages/rs-drive/src/verify/contract/verify_contract_return_serialization/v0/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ impl Drive {
5858
if contract_known_keeps_history.is_none() {
5959
match &result {
6060
Ok((_, Some(_))) => result,
61-
// Ok(None) is a valid absence proof — contract genuinely doesn't exist.
62-
// Don't retry; the server builds a non-historical query for missing contracts.
63-
Ok((_, None)) => result,
64-
Err(_) => {
61+
_ => {
6562
tracing::debug!(
6663
?contract_id,
6764
"retrying contract verification with history enabled"

packages/rs-drive/tests/query_tests.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4744,9 +4744,10 @@ mod tests {
47444744
)
47454745
.expect("verification with None should succeed");
47464746
assert_eq!(root_hash, proof_root_hash);
4747-
if let Some(contract) = proof_contract {
4748-
assert_eq!(latest_contract, contract);
4749-
}
4747+
assert_eq!(
4748+
latest_contract,
4749+
proof_contract.expect("contract exists and was updated — None retry must return it")
4750+
);
47504751

47514752
// Test 2: Some(true) - direct historical, must succeed since proof was generated
47524753
// for a historical contract
@@ -4806,9 +4807,9 @@ mod tests {
48064807
)
48074808
.expect("return_serialization with None should succeed for historical contract");
48084809
assert_eq!(root_hash, proof_root_hash_4);
4809-
if let Some((deserialized, _bytes)) = proof_contract_4 {
4810-
assert_eq!(latest_contract, deserialized);
4811-
}
4810+
let (deserialized, _bytes) =
4811+
proof_contract_4.expect("contract exists — return_serialization must return it");
4812+
assert_eq!(latest_contract, deserialized);
48124813
}
48134814

48144815
#[cfg(feature = "server")]

0 commit comments

Comments
 (0)