chore: add comments and clean up code

This commit is contained in:
Brice Dobry
2023-01-25 17:46:06 -05:00
parent 2d7c8a4355
commit be86fa7f86
4 changed files with 9 additions and 2 deletions

View File

@@ -212,7 +212,8 @@ impl DefinedFunction {
);
}
// Since this Clarity 1 contract may be called from a Clarity 2 contract,
// we need to handle Clarity 2 values as well.
// we need to handle Clarity 2 values as well. Clarity 2 contracts can only
// be executed in epoch 2.1, so we only need to handle `CallableType` here.
(
TypeSignature::CallableType(CallableSubtype::Trait(_)),
Value::CallableContract(CallableData {

View File

@@ -1838,6 +1838,9 @@ impl ContractContext {
&self.clarity_version
}
/// Canonicalize the types for the specified epoch. Only functions and
/// defined traits are exposed externally, so other types are not
/// canonicalized.
pub fn canonicalize_types(&mut self, epoch: &StacksEpochId) {
for (_, function) in self.functions.iter_mut() {
function.canonicalize_types(epoch);

View File

@@ -396,6 +396,7 @@ fn trait_invocation_205_with_stored_principal() {
});
}
/// Publish a trait in epoch 2.05 and then invoke it in epoch 2.1.
#[test]
fn trait_invocation_cross_epoch() {
let mut sim = ClarityTestSim::new();
@@ -475,6 +476,9 @@ fn trait_invocation_cross_epoch() {
});
}
/// Publish a trait that includes another trait in one of its functions in
/// epoch 2.05 and then invoke it in epoch 2.1. Test variations of epoch and
/// Clarity versions for the contract that uses the trait.
#[test]
fn trait_with_trait_invocation_cross_epoch() {
let mut sim = ClarityTestSim::new();

View File

@@ -4878,7 +4878,6 @@ fn trait_invocation_cross_epoch() {
parsed.txid(),
tx.get("raw_result").unwrap().as_str().unwrap()
);
// eprintln!("{}", tx);
}
}
}