Skip to content

Commit 6adc670

Browse files
authored
Merge pull request #6169 from BowTiedWoo/feat/clarity-wasm-undefined-variable-fix
Skip Version-Incompatible Clarity Tests to Prevent UndefinedVariable Errors
2 parents 7fa5b6d + 4d867d5 commit 6adc670

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

clarity/src/vm/tests/contracts.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ fn tx_sponsor_contract_asserts(env: &mut Environment, sponsor: Option<PrincipalD
294294

295295
#[apply(test_epochs)]
296296
fn test_tx_sponsor(epoch: StacksEpochId, mut env_factory: MemoryEnvironmentGenerator) {
297+
// Skip this test for Epoch20 and Epoch2_05, Clarity2 is not available.
298+
// `tx-sponsor?` is not available in Clarity1.
299+
if epoch < StacksEpochId::Epoch21 {
300+
return;
301+
}
302+
297303
let mut owned_env = env_factory.get_env(epoch);
298304

299305
let contract_a = "(define-read-only (get-sponsor)

clarity/src/vm/tests/variables.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ fn test_block_height(
5454
CheckErrors::UndefinedVariable("block-height".to_string()),
5555
err.err
5656
);
57+
// Return early if the ClarityVersion is Clarity3, as `block-height`
58+
// is not available in Clarity3. Initializing the contract will throw
59+
// UndefinedVariable error and fail the test for expected behaviour.
60+
return;
5761
} else {
5862
assert!(analysis.is_ok());
5963
}
@@ -112,6 +116,11 @@ fn test_stacks_block_height(
112116
CheckErrors::UndefinedVariable("stacks-block-height".to_string()),
113117
err.err
114118
);
119+
// Return early if the ClarityVersion is not Clarity3, as
120+
// `stacks-block-height` is available only in Clarity3. Initializing
121+
// the contract will throw UndefinedVariable error and fail the test
122+
// for expected behaviour.
123+
return;
115124
} else {
116125
assert!(analysis.is_ok());
117126
}
@@ -172,6 +181,11 @@ fn test_tenure_height(
172181
CheckErrors::UndefinedVariable("tenure-height".to_string()),
173182
err.err
174183
);
184+
// Return early if the ClarityVersion is not Clarity3, as
185+
// `tenure-height` is available only in Clarity3. Initializing the
186+
// contract will throw UndefinedVariable error and fail the test for
187+
// expected behaviour.
188+
return;
175189
} else {
176190
assert!(analysis.is_ok());
177191
}

0 commit comments

Comments
 (0)