mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 16:53:21 +08:00
fix: setup tenure height in test environments
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user