Skip to content

Commit

Permalink
Merge pull request #3110 from stacks-network/fix/utxo-chaining
Browse files Browse the repository at this point in the history
Fix/utxo chaining
  • Loading branch information
jcnelson committed Apr 27, 2022
2 parents 0fe97f5 + e9f7949 commit c2af13c
Show file tree
Hide file tree
Showing 12 changed files with 1,103 additions and 107 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ default = ["developer-mode"]
developer-mode = []
monitoring_prom = ["prometheus"]
slog_json = ["slog-json", "stacks_common/slog_json", "clarity/slog_json"]

testing = []

[profile.dev.package.regex]
opt-level = 2
Expand Down
20 changes: 17 additions & 3 deletions src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,21 @@ impl SortitionDB {
first_burn_hash: &BurnchainHeaderHash,
) -> Result<SortitionDB, db_error> {
use crate::core::StacksEpochExtension;
SortitionDB::connect_test_with_epochs(
first_block_height,
first_burn_hash,
StacksEpoch::unit_test(StacksEpochId::Epoch20, first_block_height),
)
}

/// Open a burn database at random tmp dir (used for testing)
/// But, take a particular epoch configuration
#[cfg(test)]
pub fn connect_test_with_epochs(
first_block_height: u64,
first_burn_hash: &BurnchainHeaderHash,
epochs: Vec<StacksEpoch>,
) -> Result<SortitionDB, db_error> {
let mut rng = rand::thread_rng();
let mut buf = [0u8; 32];
rng.fill_bytes(&mut buf);
Expand All @@ -2165,7 +2179,7 @@ impl SortitionDB {
first_block_height,
first_burn_hash,
get_epoch_time_secs(),
&StacksEpoch::unit_test(StacksEpochId::Epoch20, first_block_height),
&epochs,
PoxConstants::test_default(),
true,
)
Expand Down Expand Up @@ -3726,7 +3740,7 @@ impl<'a> SortitionHandleTx<'a> {
.map(|s| s.parse().expect("BUG: bad mining bonus stored in DB")))
}

#[cfg(test)]
#[cfg(any(test, feature = "testing"))]
fn store_burn_distribution(
&mut self,
new_sortition: &SortitionId,
Expand All @@ -3742,7 +3756,7 @@ impl<'a> SortitionHandleTx<'a> {
self.execute(sql, args).unwrap();
}

#[cfg(not(test))]
#[cfg(not(any(test, feature = "testing")))]
fn store_burn_distribution(
&mut self,
_new_sortition: &SortitionId,
Expand Down
Loading

0 comments on commit c2af13c

Please sign in to comment.