fix: setup tenure height in test environments

This commit is contained in:
Brice Dobry
2024-05-07 01:02:07 -04:00
parent d8ee58efef
commit 741726e676
3 changed files with 10 additions and 1 deletions

View File

@@ -160,7 +160,10 @@ impl MemoryEnvironmentGenerator {
pub struct TopLevelMemoryEnvironmentGenerator(MemoryBackingStore);
impl TopLevelMemoryEnvironmentGenerator {
pub fn get_env(&mut self, epoch: StacksEpochId) -> OwnedEnvironment {
let owned_env = OwnedEnvironment::new(self.0.as_clarity_db(), epoch);
let mut owned_env = OwnedEnvironment::new(self.0.as_clarity_db(), epoch);
if epoch >= StacksEpochId::Epoch30 {
owned_env.set_tenure_height(0);
}
owned_env
}
}

View File

@@ -299,6 +299,7 @@ impl ClarityInstance {
// need to increment the tenure height in the Clarity DB.
if new_tenure && epoch.epoch_id >= StacksEpochId::Epoch30 {
let mut clarity_db = datastore.as_clarity_db(header_db, burn_state_db);
clarity_db.begin();
let tenure_height = clarity_db
.get_tenure_height()
.expect("FAIL: unable to get tenure height from Clarity database");
@@ -309,6 +310,9 @@ impl ClarityInstance {
.expect("FAIL: tenure height overflow"),
)
.expect("FAIL: unable to set tenure height in Clarity database");
clarity_db
.commit()
.expect("FAIL: unable to commit tenure height");
}
ClarityBlockConnection {

View File

@@ -114,6 +114,8 @@ fn test_simple_token_system(#[case] version: ClarityVersion, #[case] epoch: Stac
gb.as_transaction(|tx| {
tx.with_clarity_db(|db| {
db.begin();
db.set_tenure_height(1).unwrap();
db.set_clarity_epoch_version(epoch).unwrap();
Ok(())
})