Skip to content

Commit 9214518

Browse files
committed
tests: fix large contracts errors
1 parent a5eae6a commit 9214518

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

stackslib/src/clarity_vm/tests/large_contract.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub const TEST_BURN_STATE_DB_AST_PRECHECK: UnitTestBurnStateDB = UnitTestBurnSta
5959
const SIMPLE_TOKENS: &str = "(define-map tokens { account: principal } { balance: uint })
6060
(define-read-only (my-get-token-balance (account principal))
6161
(default-to u0 (get balance (map-get? tokens (tuple (account account))))))
62-
(define-read-only (explode (account principal))
62+
(define-private (explode (account principal))
6363
(map-delete tokens (tuple (account account))))
6464
(define-private (token-credit! (account principal) (amount uint))
6565
(if (<= amount u0)
@@ -84,8 +84,8 @@ const SIMPLE_TOKENS: &str = "(define-map tokens { account: principal } { balance
8484
(if (>= block-height block-to-release)
8585
(faucet)
8686
(err \"must be in the future\")))
87-
(begin (token-credit! 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR u10000)
88-
(token-credit! 'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G u200)
87+
(begin (try! (token-credit! 'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR u10000))
88+
(try! (token-credit! 'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G u200))
8989
(token-credit! .tokens u4))";
9090

9191
/// Since setup_block is not called, we need to manually increment the tenure
@@ -112,9 +112,6 @@ fn new_block<'a, 'b>(
112112
block
113113
}
114114

115-
// Test not valid for clarity-wasm runtime
116-
// Contracts would error in the static analysis pass.
117-
#[cfg(not(feature = "clarity-wasm"))]
118115
#[apply(test_clarity_versions)]
119116
fn test_simple_token_system(#[case] version: ClarityVersion, #[case] epoch: StacksEpochId) {
120117
if epoch < StacksEpochId::Epoch2_05 || version > ClarityVersion::Clarity2 {
@@ -467,9 +464,6 @@ where
467464
f(&mut owned_env, version)
468465
}
469466

470-
// Test not valid for clarity-wasm runtime
471-
// Contracts would error in the static analysis pass.
472-
#[cfg(not(feature = "clarity-wasm"))]
473467
#[apply(test_clarity_versions)]
474468
fn test_simple_naming_system(#[case] version: ClarityVersion, #[case] epoch: StacksEpochId) {
475469
with_versioned_memory_environment(inner_test_simple_naming_system, version, false);
@@ -543,16 +537,30 @@ fn inner_test_simple_naming_system(owned_env: &mut OwnedEnvironment, version: Cl
543537
ClarityVersion::Clarity1,
544538
);
545539

540+
let mut store = MemoryBackingStore::new();
541+
let mut analysis_db = store.as_analysis_db();
542+
analysis_db.begin();
543+
546544
{
547545
let mut env = owned_env.get_exec_environment(None, None, &placeholder_context);
548546

549547
let contract_identifier = QualifiedContractIdentifier::local("tokens").unwrap();
550-
env.initialize_contract(contract_identifier, tokens_contract, ASTRules::PrecheckSize)
551-
.unwrap();
548+
env.initialize_contract_with_db(
549+
contract_identifier,
550+
tokens_contract,
551+
ASTRules::PrecheckSize,
552+
&mut analysis_db,
553+
)
554+
.unwrap();
552555

553556
let contract_identifier = QualifiedContractIdentifier::local("names").unwrap();
554-
env.initialize_contract(contract_identifier, names_contract, ASTRules::PrecheckSize)
555-
.unwrap();
557+
env.initialize_contract_with_db(
558+
contract_identifier,
559+
names_contract,
560+
ASTRules::PrecheckSize,
561+
&mut analysis_db,
562+
)
563+
.unwrap();
556564
}
557565

558566
{

0 commit comments

Comments
 (0)