zebra-state tests run but fail with overflow error

This commit is contained in:
idky137 2024-03-18 13:45:09 +00:00
parent 7c1ab87fd4
commit a24612e78e
No known key found for this signature in database
23 changed files with 83 additions and 79 deletions

View File

@ -56,7 +56,7 @@ async fn test_rpc_response_data_for_network(network: Network) {
// Create a populated state service
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
let (state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), network).await;
zebra_state::populated_state(blocks.clone(), &network).await;
// Start snapshots of RPC responses.
let mut settings = insta::Settings::clone_current();

View File

@ -70,7 +70,7 @@ async fn rpc_getblock() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
// Init RPC
let (rpc, rpc_tx_queue_task_handle) = RpcImpl::new(
@ -343,7 +343,7 @@ async fn rpc_getbestblockhash() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service, the tip will be in `NUMBER_OF_BLOCKS`.
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
// Init RPC
let (rpc, rpc_tx_queue_task_handle) = RpcImpl::new(
@ -386,7 +386,7 @@ async fn rpc_getrawtransaction() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service
let (_state, read_state, _latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
let (latest_chain_tip, latest_chain_tip_sender) = MockChainTip::new();
latest_chain_tip_sender.send_best_tip_height(Height(10));
@ -557,7 +557,7 @@ async fn rpc_getaddresstxids_invalid_arguments() {
// Create a populated state service
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
let (rpc, rpc_tx_queue_task_handle) = RpcImpl::new(
"RPC test",
@ -674,7 +674,7 @@ async fn rpc_getaddresstxids_response() {
// Create a populated state service
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.to_owned(), network).await;
zebra_state::populated_state(blocks.to_owned(), &network).await;
if network == Mainnet {
// Exhaustively test possible block ranges for mainnet.
@ -814,7 +814,7 @@ async fn rpc_getaddressutxos_response() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
let rpc = RpcImpl::new(
"RPC test",
@ -864,7 +864,7 @@ async fn rpc_getblockcount() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service, the tip will be in `NUMBER_OF_BLOCKS`.
let (state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
let (
block_verifier_router,
@ -1026,7 +1026,7 @@ async fn rpc_getblockhash() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service
let (state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
let (
block_verifier_router,
@ -1090,7 +1090,7 @@ async fn rpc_getmininginfo() {
// Create a populated state service
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
// Init RPC
let get_block_template_rpc = get_block_template_rpcs::GetBlockTemplateRpcImpl::new(
@ -1126,7 +1126,7 @@ async fn rpc_getnetworksolps() {
// Create a populated state service
let (_state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), Mainnet).await;
zebra_state::populated_state(blocks.clone(), &Mainnet).await;
// Init RPC
let get_block_template_rpc = get_block_template_rpcs::GetBlockTemplateRpcImpl::new(
@ -1510,7 +1510,7 @@ async fn rpc_submitblock_errors() {
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
// Create a populated state service
let (state, read_state, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks, Mainnet).await;
zebra_state::populated_state(blocks, &Mainnet).await;
// Init RPCs
let (

View File

@ -93,7 +93,7 @@ async fn scanning_zecpages_from_populated_zebra_state() -> Result<()> {
// Create a populated state service.
let (_state_service, read_only_state_service, latest_chain_tip, _chain_tip_change) =
zebra_state::populated_state(blocks.clone(), network).await;
zebra_state::populated_state(blocks.clone(), &network).await;
let db = read_only_state_service.db();

View File

@ -234,10 +234,11 @@ pub fn check_and_delete_old_databases(
let current_span = Span::current();
let config = config.clone();
let db_kind = db_kind.as_ref().to_string();
let network = network.clone();
spawn_blocking(move || {
current_span.in_scope(|| {
delete_old_databases(config, db_kind, major_version, network);
delete_old_databases(config, db_kind, major_version, &network);
info!("finished old database version cleanup task");
})
})

View File

@ -430,7 +430,7 @@ impl StateService {
&state.read_service.db,
tip.1,
),
state.network,
&state.network,
MAX_LEGACY_CHAIN_BLOCKS,
) {
let legacy_db_path = state.read_service.db.path().to_path_buf();
@ -1643,7 +1643,7 @@ impl Service<ReadRequest> for ReadStateService {
let utxos = state.non_finalized_state_receiver.with_watch_data(
|non_finalized_state| {
read::address_utxos(
state.network,
&state.network,
non_finalized_state.best_chain(),
&state.db,
addresses,
@ -1749,7 +1749,7 @@ impl Service<ReadRequest> for ReadStateService {
read::difficulty::get_block_template_chain_info(
&latest_non_finalized_state,
&state.db,
state.network,
&state.network,
);
// The work is done in the future.
@ -1921,10 +1921,11 @@ pub fn spawn_init(
LatestChainTip,
ChainTipChange,
)> {
let network = network.clone();
tokio::task::spawn_blocking(move || {
init(
config,
network,
&network,
max_checkpoint_height,
checkpoint_verify_concurrency_limit,
)

View File

@ -51,7 +51,7 @@ impl ValueTree for PreparedChainTree {
(
self.chain.clone(),
self.count.current(),
self.network,
self.network.clone(),
self.history_tree.clone(),
)
}
@ -137,7 +137,7 @@ impl Strategy for PreparedChain {
let (network, blocks) = ledger_strategy
.prop_flat_map(|ledger| {
(
Just(ledger.network),
Just(ledger.network.clone()),
Block::partial_chain_strategy(
ledger,
MAX_PARTIAL_CHAIN_BLOCKS,
@ -193,7 +193,7 @@ impl Strategy for PreparedChain {
/// - a [`ChainTipChange`] tracker
pub async fn populated_state(
blocks: impl IntoIterator<Item = Arc<Block>>,
network: Network,
network: &Network,
) -> (
Buffer<BoxService<Request, Response, BoxError>, Request>,
ReadStateService,

View File

@ -643,7 +643,7 @@ impl Clone for ChainTipChange {
// clear the previous change hash, so the first action is a reset
last_change_hash: None,
network: self.network,
network: self.network.clone(),
}
}
}

View File

@ -53,7 +53,7 @@ pub(crate) use difficulty::AdjustedDifficulty;
#[tracing::instrument(skip(semantically_verified, finalized_tip_height, relevant_chain))]
pub(crate) fn block_is_valid_for_recent_chain<C>(
semantically_verified: &SemanticallyVerifiedBlock,
network: Network,
network: &Network,
finalized_tip_height: Option<block::Height>,
relevant_chain: C,
) -> Result<(), ValidateContextError>
@ -121,7 +121,7 @@ where
#[tracing::instrument(skip(block, history_tree))]
pub(crate) fn block_commitment_is_valid_for_chain_history(
block: Arc<Block>,
network: Network,
network: &Network,
history_tree: &HistoryTree,
) -> Result<(), ValidateContextError> {
match block.commitment(&network)? {
@ -308,7 +308,7 @@ fn difficulty_threshold_and_time_are_valid(
pub(crate) fn legacy_chain<I>(
nu5_activation_height: block::Height,
ancestors: I,
network: Network,
network: &Network,
max_legacy_chain_blocks: usize,
) -> Result<(), BoxError>
where
@ -384,7 +384,7 @@ pub(crate) fn initial_contextual_validity(
// Security: check proof of work before any other checks
check::block_is_valid_for_recent_chain(
semantically_verified,
non_finalized_state.network,
&non_finalized_state.network,
finalized_state.finalized_tip_height(),
relevant_chain,
)?;

View File

@ -91,7 +91,7 @@ impl AdjustedDifficulty {
/// If the `context` contains fewer than 28 items.
pub fn new_from_block<C>(
candidate_block: &Block,
network: Network,
network: &Network,
context: C,
) -> AdjustedDifficulty
where
@ -125,7 +125,7 @@ impl AdjustedDifficulty {
pub fn new_from_header_time<C>(
candidate_header_time: DateTime<Utc>,
previous_block_height: block::Height,
network: Network,
network: &Network,
context: C,
) -> AdjustedDifficulty
where
@ -148,7 +148,7 @@ impl AdjustedDifficulty {
AdjustedDifficulty {
candidate_time: candidate_header_time,
candidate_height,
network,
network: network.clone(),
relevant_difficulty_thresholds,
relevant_times,
}
@ -166,7 +166,7 @@ impl AdjustedDifficulty {
/// Returns the configured network.
pub fn network(&self) -> Network {
self.network
self.network.clone()
}
/// Calculate the expected `difficulty_threshold` for a candidate block, based

View File

@ -340,7 +340,7 @@ impl FinalizedState {
// thread, if it shows up in profiles
check::block_commitment_is_valid_for_chain_history(
block.clone(),
self.network(),
&self.network(),
&history_tree,
)?;
@ -414,7 +414,7 @@ impl FinalizedState {
let result = self.db.write_block(
finalized,
prev_note_commitment_trees,
self.network(),
&self.network(),
source,
);

View File

@ -803,7 +803,7 @@ impl DiskDb {
/// Returns the configured network for this database.
pub fn network(&self) -> Network {
self.network
self.network.clone()
}
/// Returns the `Path` where the files used by this database are located.

View File

@ -294,7 +294,7 @@ impl ZebraDb {
&mut self,
finalized: FinalizedBlock,
prev_note_commitment_trees: Option<NoteCommitmentTrees>,
network: Network,
network: &Network,
source: &str,
) -> Result<block::Hash, BoxError> {
let tx_hash_indexes: HashMap<transaction::Hash, usize> = finalized
@ -376,7 +376,9 @@ impl ZebraDb {
let address_balances: HashMap<transparent::Address, AddressBalanceLocation> =
changed_addresses
.into_iter()
.filter_map(|address| Some((address, self.address_balance_location(&address)?)))
.filter_map(|address| {
Some((address.clone(), self.address_balance_location(&address)?))
})
.collect();
let mut batch = DiskWriteBatch::new();
@ -440,7 +442,7 @@ impl DiskWriteBatch {
pub fn prepare_block_batch(
&mut self,
zebra_db: &ZebraDb,
network: Network,
network: &Network,
finalized: &FinalizedBlock,
new_outputs_by_out_loc: BTreeMap<OutputLocation, transparent::Utxo>,
spent_utxos_by_outpoint: HashMap<transparent::OutPoint, transparent::Utxo>,

View File

@ -550,7 +550,7 @@ fn snapshot_transparent_address_data(state: &FinalizedState, height: u32) {
// The default raw data serialization is very verbose, so we hex-encode the bytes.
stored_address_balances.push((address.to_string(), stored_address_balance_location));
stored_address_utxo_locations.push((stored_address_location, stored_utxo_locations));
stored_address_utxos.push((address, stored_utxos));
stored_address_utxos.push((address.clone(), stored_utxos));
stored_address_transaction_locations.push((address, stored_transaction_locations));
}

View File

@ -343,7 +343,7 @@ impl DiskWriteBatch {
pub fn prepare_transparent_transaction_batch(
&mut self,
db: &DiskDb,
network: Network,
network: &Network,
finalized: &FinalizedBlock,
new_outputs_by_out_loc: &BTreeMap<OutputLocation, transparent::Utxo>,
spent_utxos_by_outpoint: &HashMap<transparent::OutPoint, transparent::Utxo>,
@ -400,7 +400,7 @@ impl DiskWriteBatch {
pub fn prepare_new_transparent_outputs_batch(
&mut self,
db: &DiskDb,
network: Network,
network: &Network,
new_outputs_by_out_loc: &BTreeMap<OutputLocation, transparent::Utxo>,
address_balances: &mut HashMap<transparent::Address, AddressBalanceLocation>,
) -> Result<(), BoxError> {
@ -477,7 +477,7 @@ impl DiskWriteBatch {
pub fn prepare_spent_transparent_outputs_batch(
&mut self,
db: &DiskDb,
network: Network,
network: &Network,
spent_utxos_by_out_loc: &BTreeMap<OutputLocation, transparent::Utxo>,
address_balances: &mut HashMap<transparent::Address, AddressBalanceLocation>,
) -> Result<(), BoxError> {
@ -532,7 +532,7 @@ impl DiskWriteBatch {
pub fn prepare_spending_transparent_tx_ids_batch(
&mut self,
db: &DiskDb,
network: Network,
network: &Network,
spending_tx_location: TransactionLocation,
transaction: &Transaction,
spent_utxos_by_outpoint: &HashMap<transparent::OutPoint, transparent::Utxo>,

View File

@ -281,7 +281,7 @@ impl NonFinalizedState {
let finalized_tip_height = finalized_tip_height.unwrap_or(zebra_chain::block::Height(0));
let chain = Chain::new(
self.network,
&self.network,
finalized_tip_height,
finalized_state.sprout_tree_for_tip(),
finalized_state.sapling_tree_for_tip(),
@ -381,7 +381,7 @@ impl NonFinalizedState {
scope.spawn_fifo(|_scope| {
block_commitment_result = Some(check::block_commitment_is_valid_for_chain_history(
block,
network,
&network,
&history_tree,
));
});

View File

@ -211,7 +211,7 @@ pub struct ChainInner {
impl Chain {
/// Create a new Chain with the given finalized tip trees and network.
pub(crate) fn new(
network: Network,
network: &Network,
finalized_tip_height: Height,
sprout_note_commitment_tree: Arc<sprout::tree::NoteCommitmentTree>,
sapling_note_commitment_tree: Arc<sapling::tree::NoteCommitmentTree>,
@ -247,7 +247,7 @@ impl Chain {
};
let mut chain = Self {
network,
network: network.clone(),
inner,
last_fork_height: None,
};

View File

@ -47,7 +47,7 @@ fn push_genesis_chain() -> Result<()> {
|((chain, count, network, empty_tree) in PreparedChain::default())| {
prop_assert!(empty_tree.is_none());
let mut only_chain = Chain::new(network, Height(0), Default::default(), Default::default(), Default::default(), empty_tree, ValueBalance::zero());
let mut only_chain = Chain::new(&network, Height(0), Default::default(), Default::default(), Default::default(), empty_tree, ValueBalance::zero());
// contains the block value pool changes and chain value pool balances for each height
let mut chain_values = BTreeMap::new();
@ -99,7 +99,7 @@ fn push_history_tree_chain() -> Result<()> {
let count = std::cmp::min(count, chain.len() - 1);
let chain = &chain[1..];
let mut only_chain = Chain::new(network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree, ValueBalance::zero());
let mut only_chain = Chain::new(&network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree, ValueBalance::zero());
for block in chain
.iter()
@ -142,7 +142,7 @@ fn forked_equals_pushed_genesis() -> Result<()> {
// This chain will be used to check if the blocks in the forked chain
// correspond to the blocks in the original chain before the fork.
let mut partial_chain = Chain::new(
network,
&network,
Height(0),
Default::default(),
Default::default(),
@ -162,7 +162,7 @@ fn forked_equals_pushed_genesis() -> Result<()> {
// This chain will be forked.
let mut full_chain = Chain::new(
network,
&network,
Height(0),
Default::default(),
Default::default(),
@ -250,8 +250,8 @@ fn forked_equals_pushed_history_tree() -> Result<()> {
// use `fork_at_count` as the fork tip
let fork_tip_hash = chain[fork_at_count - 1].hash;
let mut full_chain = Chain::new(network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree.clone(), ValueBalance::zero());
let mut partial_chain = Chain::new(network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree, ValueBalance::zero());
let mut full_chain = Chain::new(&network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree.clone(), ValueBalance::zero());
let mut partial_chain = Chain::new(&network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree, ValueBalance::zero());
for block in chain
.iter()
@ -318,7 +318,7 @@ fn finalized_equals_pushed_genesis() -> Result<()> {
let fake_value_pool = ValueBalance::<NonNegative>::fake_populated_pool();
let mut full_chain = Chain::new(network, Height(0), Default::default(), Default::default(), Default::default(), empty_tree, fake_value_pool);
let mut full_chain = Chain::new(&network, Height(0), Default::default(), Default::default(), Default::default(), empty_tree, fake_value_pool);
for block in chain
.clone()
.take(finalized_count) {
@ -326,7 +326,7 @@ fn finalized_equals_pushed_genesis() -> Result<()> {
}
let mut partial_chain = Chain::new(
network,
&network,
full_chain.non_finalized_tip_height(),
full_chain.sprout_note_commitment_tree_for_tip(),
full_chain.sapling_note_commitment_tree_for_tip(),
@ -395,7 +395,7 @@ fn finalized_equals_pushed_history_tree() -> Result<()> {
let fake_value_pool = ValueBalance::<NonNegative>::fake_populated_pool();
let mut full_chain = Chain::new(network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree, fake_value_pool);
let mut full_chain = Chain::new(&network, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree, fake_value_pool);
for block in chain
.iter()
.take(finalized_count)
@ -404,7 +404,7 @@ fn finalized_equals_pushed_history_tree() -> Result<()> {
}
let mut partial_chain = Chain::new(
network,
&network,
Height(finalized_count.try_into().unwrap()),
full_chain.sprout_note_commitment_tree_for_tip(),
full_chain.sapling_note_commitment_tree_for_tip(),
@ -583,8 +583,8 @@ fn different_blocks_different_chains() -> Result<()> {
Default::default()
};
let chain1 = Chain::new(Network::Mainnet, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree1, ValueBalance::fake_populated_pool());
let chain2 = Chain::new(Network::Mainnet, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree2, ValueBalance::fake_populated_pool());
let chain1 = Chain::new(&Network::Mainnet, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree1, ValueBalance::fake_populated_pool());
let chain2 = Chain::new(&Network::Mainnet, Height(0), Default::default(), Default::default(), Default::default(), finalized_tree2, ValueBalance::fake_populated_pool());
let block1 = vec1[1].clone().prepare().test_with_zero_spent_utxos();
let block2 = vec2[1].clone().prepare().test_with_zero_spent_utxos();

View File

@ -26,7 +26,7 @@ use crate::{
fn construct_empty() {
let _init_guard = zebra_test::init();
let _chain = Chain::new(
Network::Mainnet,
&Network::Mainnet,
Height(0),
Default::default(),
Default::default(),
@ -43,7 +43,7 @@ fn construct_single() -> Result<()> {
zebra_test::vectors::BLOCK_MAINNET_434873_BYTES.zcash_deserialize_into()?;
let mut chain = Chain::new(
Network::Mainnet,
&Network::Mainnet,
Height(0),
Default::default(),
Default::default(),
@ -77,7 +77,7 @@ fn construct_many() -> Result<()> {
}
let mut chain = Chain::new(
Network::Mainnet,
&Network::Mainnet,
(initial_height - 1).expect("Initial height should be at least 1."),
Default::default(),
Default::default(),
@ -104,7 +104,7 @@ fn ord_matches_work() -> Result<()> {
let more_block = less_block.clone().set_work(10);
let mut lesser_chain = Chain::new(
Network::Mainnet,
&Network::Mainnet,
Height(0),
Default::default(),
Default::default(),
@ -115,7 +115,7 @@ fn ord_matches_work() -> Result<()> {
lesser_chain = lesser_chain.push(less_block.prepare().test_with_zero_spent_utxos())?;
let mut bigger_chain = Chain::new(
Network::Mainnet,
&Network::Mainnet,
Height(0),
Default::default(),
Default::default(),

View File

@ -48,14 +48,14 @@ pub struct AddressUtxos {
impl AddressUtxos {
/// Creates a new set of address UTXOs.
pub fn new(
network: Network,
network: &Network,
utxos: BTreeMap<OutputLocation, transparent::Output>,
tx_ids: BTreeMap<TransactionLocation, transaction::Hash>,
) -> Self {
Self {
utxos,
tx_ids,
network,
network: network.clone(),
}
}
@ -95,7 +95,7 @@ impl AddressUtxos {
/// If the addresses do not exist in the non-finalized `chain` or finalized `db`,
/// returns an empty list.
pub fn address_utxos<C>(
network: Network,
network: &Network,
chain: Option<C>,
db: &ZebraDb,
addresses: HashSet<transparent::Address>,
@ -150,7 +150,7 @@ where
"full address UTXO response",
);
return Ok(AddressUtxos::new(network, utxos, tx_ids));
return Ok(AddressUtxos::new(&network, utxos, tx_ids));
}
Err(chain_utxo_error) => {

View File

@ -45,7 +45,7 @@ pub const EXTRA_TIME_TO_MINE_A_BLOCK: u32 = POST_BLOSSOM_POW_TARGET_SPACING * 2;
pub fn get_block_template_chain_info(
non_finalized_state: &NonFinalizedState,
db: &ZebraDb,
network: Network,
network: &Network,
) -> Result<GetBlockTemplateChainInfo, BoxError> {
let mut best_relevant_chain_and_history_tree_result =
best_relevant_chain_and_history_tree(non_finalized_state, db);
@ -209,7 +209,7 @@ fn difficulty_time_and_history_tree(
relevant_chain: [Arc<Block>; POW_ADJUSTMENT_BLOCK_SPAN],
tip_height: Height,
tip_hash: block::Hash,
network: Network,
network: &Network,
history_tree: Arc<HistoryTree>,
) -> GetBlockTemplateChainInfo {
let relevant_data: Vec<(CompactDifficulty, DateTime<Utc>)> = relevant_chain
@ -247,7 +247,7 @@ fn difficulty_time_and_history_tree(
let difficulty_adjustment = AdjustedDifficulty::new_from_header_time(
cur_time.into(),
tip_height,
network,
&network,
relevant_data.iter().cloned(),
);
let expected_difficulty = difficulty_adjustment.expected_difficulty_threshold();
@ -272,11 +272,11 @@ fn difficulty_time_and_history_tree(
/// The `relevant_data` has recent block difficulties and times in reverse order from the tip.
fn adjust_difficulty_and_time_for_testnet(
result: &mut GetBlockTemplateChainInfo,
network: Network,
network: &Network,
previous_block_height: Height,
relevant_data: Vec<(CompactDifficulty, DateTime<Utc>)>,
) {
if network == Network::Mainnet {
if network == &Network::Mainnet {
return;
}
@ -360,7 +360,7 @@ fn adjust_difficulty_and_time_for_testnet(
result.expected_difficulty = AdjustedDifficulty::new_from_header_time(
result.cur_time.into(),
previous_block_height,
network,
&network,
relevant_data.iter().cloned(),
)
.expected_difficulty_threshold();

View File

@ -56,7 +56,7 @@ async fn populated_read_state_responds_correctly() -> Result<()> {
.collect();
let (_state, read_state, _latest_chain_tip, _chain_tip_change) =
populated_state(blocks.clone(), Mainnet).await;
populated_state(blocks.clone(), &Mainnet).await;
let tip_height = Height(blocks.len() as u32 - 1);

View File

@ -194,7 +194,7 @@ async fn test_populated_state_responds_correctly(
#[tokio::main]
async fn populate_and_check(blocks: Vec<Arc<Block>>) -> Result<()> {
let (state, _, _, _) = populated_state(blocks, Network::Mainnet).await;
let (state, _, _, _) = populated_state(blocks, &Network::Mainnet).await;
test_populated_state_responds_correctly(state).await?;
Ok(())
}
@ -306,7 +306,7 @@ proptest! {
fn some_block_less_than_network_upgrade(
(network, nu_activation_height, chain) in partial_nu5_chain_strategy(4, true, UNDER_LEGACY_CHAIN_LIMIT, NetworkUpgrade::Canopy)
) {
let response = crate::service::check::legacy_chain(nu_activation_height, chain.into_iter().rev(), network, TEST_LEGACY_CHAIN_LIMIT)
let response = crate::service::check::legacy_chain(nu_activation_height, chain.into_iter().rev(), &network, TEST_LEGACY_CHAIN_LIMIT)
.map_err(|error| error.to_string());
prop_assert_eq!(response, Ok(()));
@ -323,7 +323,7 @@ proptest! {
.coinbase_height()
.expect("chain contains valid blocks");
let response = crate::service::check::legacy_chain(nu_activation_height, chain.into_iter().rev(), network, TEST_LEGACY_CHAIN_LIMIT)
let response = crate::service::check::legacy_chain(nu_activation_height, chain.into_iter().rev(), &network, TEST_LEGACY_CHAIN_LIMIT)
.map_err(|error| error.to_string());
prop_assert_eq!(
@ -362,7 +362,7 @@ proptest! {
let response = crate::service::check::legacy_chain(
nu_activation_height,
chain.clone().into_iter().rev(),
network,
&network,
TEST_LEGACY_CHAIN_LIMIT,
).map_err(|error| error.to_string());
@ -380,7 +380,7 @@ proptest! {
fn at_least_one_transaction_with_valid_network_upgrade(
(network, nu_activation_height, chain) in partial_nu5_chain_strategy(5, true, UNDER_LEGACY_CHAIN_LIMIT, NetworkUpgrade::Canopy)
) {
let response = crate::service::check::legacy_chain(nu_activation_height, chain.into_iter().rev(), network, TEST_LEGACY_CHAIN_LIMIT)
let response = crate::service::check::legacy_chain(nu_activation_height, chain.into_iter().rev(), &network, TEST_LEGACY_CHAIN_LIMIT)
.map_err(|error| error.to_string());
prop_assert_eq!(response, Ok(()));

View File

@ -81,7 +81,7 @@ async fn check_transcripts(network: Network) -> Result<(), Report> {
for transcript_data in net_data {
// We're not verifying UTXOs here.
let (service, _, _, _) = zebra_state::init(Config::ephemeral(), network, Height::MAX, 0);
let (service, _, _, _) = zebra_state::init(Config::ephemeral(), &network, Height::MAX, 0);
let transcript = Transcript::from(transcript_data.iter().cloned());
/// SPANDOC: check the on disk service against the transcript
transcript.check(service).await?;