Skip to content

Commit 42ce4de

Browse files
committed
test: fix trait_stack_depth test
1 parent 5b8ed30 commit 42ce4de

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

clarity/src/vm/tests/contracts.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use stacks_common::types::StacksEpochId;
2222
use crate::vm::ast::errors::ParseErrors;
2323
use crate::vm::ast::ASTRules;
2424
use crate::vm::contexts::Environment;
25+
use crate::vm::database::MemoryBackingStore;
2526
use crate::vm::errors::{CheckErrors, Error, RuntimeErrorType};
2627
use crate::vm::tests::{
2728
env_factory, execute, is_committed, is_err_code_i128 as is_err_code, symbols_from_values,
@@ -1146,15 +1147,16 @@ fn test_cc_stack_depth(
11461147
);
11471148
}
11481149

1149-
// Test not valid for clarity-wasm runtime
1150-
// Contracts would error in the static analysis pass.
1151-
#[cfg(not(feature = "clarity-wasm"))]
11521150
#[apply(test_clarity_versions)]
11531151
fn test_cc_trait_stack_depth(
11541152
version: ClarityVersion,
11551153
epoch: StacksEpochId,
11561154
mut env_factory: MemoryEnvironmentGenerator,
11571155
) {
1156+
// Test is not valid for ClarityV1.
1157+
if cfg!(feature = "clarity-wasm") && version == ClarityVersion::Clarity1 {
1158+
return;
1159+
}
11581160
let mut owned_env = env_factory.get_env(epoch);
11591161

11601162
let contract_one = "(define-public (foo)
@@ -1176,16 +1178,31 @@ fn test_cc_trait_stack_depth(
11761178

11771179
let mut placeholder_context =
11781180
ContractContext::new(QualifiedContractIdentifier::transient(), version);
1181+
1182+
let mut store = MemoryBackingStore::new();
1183+
let mut analysis_db = store.as_analysis_db();
1184+
analysis_db.begin();
1185+
11791186
let mut env = owned_env.get_exec_environment(None, None, &mut placeholder_context);
11801187

11811188
let contract_identifier = QualifiedContractIdentifier::local("c-foo").unwrap();
1182-
env.initialize_contract(contract_identifier, contract_one, ASTRules::PrecheckSize)
1183-
.unwrap();
1189+
env.initialize_contract_with_db(
1190+
contract_identifier,
1191+
contract_one,
1192+
ASTRules::PrecheckSize,
1193+
&mut analysis_db,
1194+
)
1195+
.unwrap();
11841196

11851197
let contract_identifier = QualifiedContractIdentifier::local("c-bar").unwrap();
11861198
assert_eq!(
1187-
env.initialize_contract(contract_identifier, contract_two, ASTRules::PrecheckSize)
1188-
.unwrap_err(),
1199+
env.initialize_contract_with_db(
1200+
contract_identifier,
1201+
contract_two,
1202+
ASTRules::PrecheckSize,
1203+
&mut analysis_db
1204+
)
1205+
.unwrap_err(),
11891206
RuntimeErrorType::MaxStackDepthReached.into()
11901207
);
11911208
}

0 commit comments

Comments
 (0)