Skip to content

Commit 583bd6d

Browse files
committed
test(drive-abci): expect UnpaidConsensusError for single-tx purchase failures (issue #2867)
Two pre-existing NFT tests asserted PaidConsensusError + invalid_paid_count=1 for single-transition batches whose lone Purchase fails on DocumentNotForSaleError or DocumentIncorrectPurchasePriceError. With the v1 `flatten` / `merge_many` aggregators introduced in this PR (PROTOCOL_VERSION_12+), an all-failed single-transition batch now returns `data: None` instead of the legacy `Some(empty_vec)`. The result flows down the unpaid path: `UnpaidConsensusError` and the tx is removed from the block by prepare_proposal. Update the assertions to reflect that. Note that PR #3608 (separate, pending) restores Paid behavior for these specific paths by emitting a BumpIdentityDataContractNonce action so the user pays for the validation work — at which point these tests will need to flip back to PaidConsensusError. For now this PR alone produces UnpaidConsensus for these cases, which matches v3.1-dev's current state without #3608's bump emission.
1 parent c402712 commit 583bd6d

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/nft.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,16 +1847,19 @@ mod nft_tests {
18471847
.unwrap()
18481848
.expect("expected to commit transaction");
18491849

1850-
assert_eq!(processing_result.invalid_paid_count(), 1);
1850+
// PROTOCOL_VERSION_12+ (issue #2867): the v1 `flatten` / `merge_many`
1851+
// aggregators return `data: None` when no per-transition input
1852+
// contributed, so a single-transition batch where the lone Purchase
1853+
// fails its price check now flows as `UnpaidConsensusError` (tx
1854+
// removed from block by prepare_proposal) instead of being recorded
1855+
// as a paid empty `BatchTransitionAction`.
1856+
assert_eq!(processing_result.invalid_unpaid_count(), 1);
1857+
assert_eq!(processing_result.invalid_paid_count(), 0);
18511858

18521859
let result = processing_result.into_execution_results().remove(0);
18531860

1854-
let StateTransitionExecutionResult::PaidConsensusError {
1855-
error: consensus_error,
1856-
..
1857-
} = result
1858-
else {
1859-
panic!("expected a paid consensus error");
1861+
let StateTransitionExecutionResult::UnpaidConsensusError(consensus_error) = result else {
1862+
panic!("expected an unpaid consensus error");
18601863
};
18611864
assert_eq!(consensus_error.to_string(), "5rJccTdtJfg6AxSKyrptWUug3PWjveEitTTLqBn9wHdk document can not be purchased for 35000000000, it's sale price is 50000000000 (in credits)");
18621865
}
@@ -2355,16 +2358,19 @@ mod nft_tests {
23552358
.unwrap()
23562359
.expect("expected to commit transaction");
23572360

2358-
assert_eq!(processing_result.invalid_paid_count(), 1);
2361+
// PROTOCOL_VERSION_12+ (issue #2867): the v1 `flatten` / `merge_many`
2362+
// aggregators return `data: None` when no per-transition input
2363+
// contributed, so a single-transition batch where the lone Purchase
2364+
// hits `DocumentNotForSaleError` now flows as `UnpaidConsensusError`
2365+
// (tx removed from block by prepare_proposal) instead of being
2366+
// recorded as a paid empty `BatchTransitionAction`.
2367+
assert_eq!(processing_result.invalid_unpaid_count(), 1);
2368+
assert_eq!(processing_result.invalid_paid_count(), 0);
23592369

23602370
let result = processing_result.into_execution_results().remove(0);
23612371

2362-
let StateTransitionExecutionResult::PaidConsensusError {
2363-
error: consensus_error,
2364-
..
2365-
} = result
2366-
else {
2367-
panic!("expected a paid consensus error");
2372+
let StateTransitionExecutionResult::UnpaidConsensusError(consensus_error) = result else {
2373+
panic!("expected an unpaid consensus error");
23682374
};
23692375
assert_eq!(
23702376
consensus_error.to_string(),

0 commit comments

Comments
 (0)