Skip to content

Commit

Permalink
Fix test relying on omitting block body when asked for one
Browse files Browse the repository at this point in the history
  • Loading branch information
hrxi authored and jsdanielh committed May 16, 2024
1 parent f8e14bf commit c3f939d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ nimiq-test-log = { workspace = true }
# This adds a circular dev-dependency which is fine but breaks VS code rust-analyzer.
# See https://github.com/rust-analyzer/rust-analyzer/issues/14167
nimiq-test-utils = { workspace = true }
nimiq-transaction-builder = { workspace = true }
nimiq-trie = { workspace = true }
nimiq-zkp-component = { workspace = true, features = ["zkp-prover", "parallel"] }

Expand Down
33 changes: 23 additions & 10 deletions consensus/tests/state_live_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ use nimiq_database::{
};
use nimiq_genesis::{NetworkId, NetworkInfo};
use nimiq_hash::{Blake2bHash, Blake2sHash};
use nimiq_keys::{Address, KeyPair};
use nimiq_network_interface::{
network::Network,
request::{Handle, RequestCommon},
};
use nimiq_network_mock::{MockHub, MockId, MockNetwork, MockPeerId};
use nimiq_primitives::{key_nibbles::KeyNibbles, policy::Policy, trie::trie_diff::TrieDiff};
use nimiq_primitives::{
coin::Coin, key_nibbles::KeyNibbles, policy::Policy, trie::trie_diff::TrieDiff,
};
use nimiq_test_log::test;
use nimiq_test_utils::{
block_production::TemporaryBlockProducer,
blockchain::{produce_macro_blocks, push_micro_block, signing_key, voting_key},
mock_node::MockNode,
node::TESTING_BLS_CACHE_MAX_CAPACITY,
};
use nimiq_transaction::ExecutedTransaction;
use nimiq_transaction_builder::TransactionBuilder;
use nimiq_utils::time::OffsetTime;
use parking_lot::{Mutex, RwLock};
use tokio::sync::mpsc::{self, Sender};
Expand Down Expand Up @@ -734,15 +739,23 @@ async fn can_remove_chunks_related_to_invalid_blocks() {
mock_id,
blockchain_proxy,
);
match &mut response {
Ok(blocks) => match &mut blocks.blocks[0] {
Block::Micro(micro_block) => {
micro_block.body = None;
}
_ => unreachable!(),
},
_ => unreachable!(),
}
response.as_mut().unwrap().blocks[0]
.unwrap_micro_ref_mut()
.body
.as_mut()
.unwrap()
.transactions
.push(ExecutedTransaction::Ok(
TransactionBuilder::new_basic(
&KeyPair::default(),
Address::burn_address(),
Coin::MAX,
Coin::ZERO,
Policy::genesis_block_number(),
NetworkId::UnitAlbatross,
)
.unwrap(),
));
response
});

Expand Down

0 comments on commit c3f939d

Please sign in to comment.