Skip to content

Commit d35184e

Browse files
committed
remove setup contracts from snapshot
1 parent 883ad61 commit d35184e

File tree

2 files changed

+29
-47
lines changed

2 files changed

+29
-47
lines changed

stackslib/src/chainstate/tests/consensus.rs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,12 @@ impl ContractConsensusTest<'_> {
10481048
call_epochs.iter().all(|e| e >= min_deploy_epoch),
10491049
"All call epochs must be >= the minimum deploy epoch"
10501050
);
1051-
1051+
assert!(
1052+
setup_contracts
1053+
.iter()
1054+
.all(|c| c.deploy_epoch.is_none() || c.deploy_epoch.unwrap() >= *min_deploy_epoch),
1055+
"All setup contracts must have a deploy epoch >= the minimum deploy epoch"
1056+
);
10521057
// Build epoch_blocks map based on deploy and call epochs
10531058
let mut num_blocks_per_epoch: HashMap<StacksEpochId, u64> = HashMap::new();
10541059
let mut contract_deploys_per_epoch: HashMap<StacksEpochId, Vec<(String, ClarityVersion)>> =
@@ -1173,27 +1178,30 @@ impl ContractConsensusTest<'_> {
11731178
}
11741179

11751180
/// Deploys prerequisite contracts scheduled for the given epoch.
1176-
fn deploy_setup_contracts(&mut self, epoch: StacksEpochId) -> Vec<ExpectedResult> {
1181+
/// Panics if the deployment fails.
1182+
fn deploy_setup_contracts(&mut self, epoch: StacksEpochId) {
11771183
let Some(contracts) = self.setup_contracts_per_epoch.get(&epoch).cloned() else {
1178-
return vec![];
1184+
return;
11791185
};
11801186

11811187
let is_naka_block = epoch.uses_nakamoto_blocks();
1182-
contracts
1183-
.into_iter()
1184-
.map(|contract| {
1185-
self.chain.consume_pre_naka_prepare_phase();
1186-
self.append_tx_block(
1187-
&TestTxSpec::ContractDeploy {
1188-
sender: &FAUCET_PRIV_KEY,
1189-
name: &contract.name,
1190-
code: &contract.code,
1191-
clarity_version: contract.clarity_version,
1192-
},
1193-
is_naka_block,
1194-
)
1195-
})
1196-
.collect()
1188+
contracts.into_iter().for_each(|contract| {
1189+
self.chain.consume_pre_naka_prepare_phase();
1190+
let result = self.append_tx_block(
1191+
&TestTxSpec::ContractDeploy {
1192+
sender: &FAUCET_PRIV_KEY,
1193+
name: &contract.name,
1194+
code: &contract.code,
1195+
clarity_version: contract.clarity_version,
1196+
},
1197+
is_naka_block,
1198+
);
1199+
assert!(
1200+
matches!(result, ExpectedResult::Success(_)),
1201+
"Expected success for setup contract {}: {result:?}",
1202+
contract.name,
1203+
);
1204+
});
11971205
}
11981206

11991207
/// Deploys all contract versions scheduled for the given epoch.
@@ -1313,7 +1321,9 @@ impl ContractConsensusTest<'_> {
13131321
.test_chainstate
13141322
.advance_into_epoch(&private_key, epoch);
13151323

1316-
results.extend(self.deploy_setup_contracts(epoch));
1324+
// Differently from the deploy_contracts and call_contracts functions, setup contracts are expected to succeed.
1325+
// Their receipt is not relevant to the test.
1326+
self.deploy_setup_contracts(epoch);
13171327
results.extend(self.deploy_contracts(epoch));
13181328
results.extend(self.call_contracts(epoch));
13191329
}

stackslib/src/chainstate/tests/snapshots/blockstack_lib__chainstate__tests__static_analysis_tests__static_check_error_bad_trait_implementation.snap

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,6 @@ source: stackslib/src/chainstate/tests/static_analysis_tests.rs
33
expression: result
44
---
55
[
6-
Success(ExpectedBlockOutput(
7-
marf_hash: "ea4bd6655c60fab8f7361d5dadafe85828880fe8eedfcd1ee1009089d080c69a",
8-
evaluated_epoch: Epoch33,
9-
transactions: [
10-
ExpectedTransactionOutput(
11-
tx: "SmartContract(name: trait-contract, code_body: [..], clarity_version: Some(Clarity4))",
12-
vm_error: "None [NON-CONSENSUS BREAKING]",
13-
return_type: Response(ResponseData(
14-
committed: true,
15-
data: Bool(true),
16-
)),
17-
cost: ExecutionCost(
18-
write_length: 87,
19-
write_count: 2,
20-
read_length: 1,
21-
read_count: 1,
22-
runtime: 10190,
23-
),
24-
),
25-
],
26-
total_block_cost: ExecutionCost(
27-
write_length: 87,
28-
write_count: 2,
29-
read_length: 1,
30-
read_count: 1,
31-
runtime: 10190,
32-
),
33-
)),
346
Success(ExpectedBlockOutput(
357
marf_hash: "3e216b0c84ceed92b873d280c01a1541de4bc3fc8dea66968cd7af59387080e5",
368
evaluated_epoch: Epoch33,

0 commit comments

Comments
 (0)