Skip to content

Commit 0735691

Browse files
authored
Merge pull request #6218 from csgui/wasm-issue-664/large-contracts-tests-issue
[clarity-wasm-tests] fix large contracts test failure
2 parents de6e82e + 9214518 commit 0735691

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

stackslib/src/clarity_vm/tests/large_contract.rs

Lines changed: 21 additions & 7 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
@@ -537,16 +537,30 @@ fn inner_test_simple_naming_system(owned_env: &mut OwnedEnvironment, version: Cl
537537
ClarityVersion::Clarity1,
538538
);
539539

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

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

547556
let contract_identifier = QualifiedContractIdentifier::local("names").unwrap();
548-
env.initialize_contract(contract_identifier, names_contract, ASTRules::PrecheckSize)
549-
.unwrap();
557+
env.initialize_contract_with_db(
558+
contract_identifier,
559+
names_contract,
560+
ASTRules::PrecheckSize,
561+
&mut analysis_db,
562+
)
563+
.unwrap();
550564
}
551565

552566
{

0 commit comments

Comments
 (0)