Skip to content

Commit c05cd6d

Browse files
central_systest_blobs: support reverting invokes
1 parent a433940 commit c05cd6d

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

crates/central_systest_blobs/src/cende_blob_regression_test.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ static NON_TRIVIAL_RESOURCE_BOUNDS: LazyLock<AllResourceBounds> =
158158
},
159159
});
160160

161-
type TxPair = (ExecutableAccountTx, InternalConsensusTransaction);
161+
struct TxPair {
162+
executable: ExecutableAccountTx,
163+
internal: InternalConsensusTransaction,
164+
should_revert: bool,
165+
}
162166

163167
/// ID of the current blobs file.
164168
fn current_generation() -> usize {
@@ -302,13 +306,18 @@ impl BlobFactory {
302306
)
303307
.unwrap();
304308
let mut transactions_with_receipts = Vec::new();
305-
for (executable, internal) in self.next_txs.iter() {
309+
for TxPair { executable, internal, should_revert } in self.next_txs.iter() {
306310
let (execution_info, _state_changes) = executor
307311
.execute(&BlockifierTx::new_for_sequencing(ExecutableTx::Account(
308312
executable.clone(),
309313
)))
310314
.unwrap();
311-
assert!(!execution_info.is_reverted(), "Got a reverted tx: {execution_info:?}");
315+
assert_eq!(
316+
execution_info.is_reverted(),
317+
*should_revert,
318+
"Execution result does not match expected (should_revert={should_revert}): \
319+
{execution_info:?}"
320+
);
312321

313322
transactions_with_receipts.push(InternalTransactionWithReceipt {
314323
transaction: internal.clone(),
@@ -507,7 +516,11 @@ impl BlobFactory {
507516
.returning(move |_| Ok(Some(contract.get_class())));
508517

509518
// Return the transactions.
510-
self.next_txs.push((executable.into(), internal_tx));
519+
self.next_txs.push(TxPair {
520+
executable: executable.into(),
521+
internal: internal_tx,
522+
should_revert: false,
523+
});
511524
}
512525

513526
fn make_free_deploy_account_tx(&mut self, account: FeatureContract) -> ContractAddress {
@@ -559,7 +572,11 @@ impl BlobFactory {
559572
tx: without_hash,
560573
tx_hash,
561574
});
562-
self.next_txs.push((executable.into(), internal));
575+
self.next_txs.push(TxPair {
576+
executable: executable.into(),
577+
internal,
578+
should_revert: false,
579+
});
563580
contract_address
564581
}
565582

@@ -569,6 +586,7 @@ impl BlobFactory {
569586
function_name: &str,
570587
calldata: &[Felt],
571588
with_fee_charge: bool,
589+
should_revert: bool,
572590
) {
573591
let nonce = self.nonce_manager.next(*OPERATOR_ADDRESS);
574592
let resource_bounds = if with_fee_charge {
@@ -604,7 +622,7 @@ impl BlobFactory {
604622
tx: without_hash,
605623
tx_hash,
606624
});
607-
self.next_txs.push((executable.into(), internal));
625+
self.next_txs.push(TxPair { executable: executable.into(), internal, should_revert });
608626
}
609627

610628
fn make_operator_deploy_tx(
@@ -633,6 +651,7 @@ impl BlobFactory {
633651
"deploy_contract",
634652
&calldata,
635653
with_fee_charge,
654+
false, // should not revert
636655
);
637656
contract_address
638657
}
@@ -668,7 +687,7 @@ impl BlobFactory {
668687
let mut transaction_receipts = vec![];
669688
let mut transaction_state_diffs = vec![];
670689

671-
for (tx_index, (executable, internal)) in txs.into_iter().enumerate() {
690+
for (tx_index, TxPair { executable, internal, .. }) in txs.into_iter().enumerate() {
672691
let tx_hash = match &internal {
673692
InternalConsensusTransaction::RpcTransaction(tx) => tx.tx_hash,
674693
InternalConsensusTransaction::L1Handler(_) => {

0 commit comments

Comments
 (0)