Skip to content

Commit

Permalink
Get rid of ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
someone235 committed Dec 26, 2023
1 parent be870cc commit 8479322
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion testing/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ smallvec.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tokio.workspace = true
ctor = "0.2.6"

[dev-dependencies]
criterion.workspace = true
Expand Down
23 changes: 23 additions & 0 deletions testing/integration/src/consensus_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//!
use async_channel::unbounded;
use kaspa_alloc::init_allocator_with_default_settings;
use kaspa_consensus::config::genesis::GENESIS;
use kaspa_consensus::config::{Config, ConfigBuilder};
use kaspa_consensus::consensus::factory::Factory as ConsensusFactory;
Expand Down Expand Up @@ -173,16 +174,19 @@ fn reachability_stretch_test(use_attack_json: bool) {

#[test]
fn test_attack_json() {
init_allocator_with_default_settings();
reachability_stretch_test(true);
}

#[test]
fn test_noattack_json() {
init_allocator_with_default_settings();
reachability_stretch_test(false);
}

#[tokio::test]
async fn consensus_sanity_test() {
init_allocator_with_default_settings();
let genesis_child: Hash = 2.into();
let config = ConfigBuilder::new(MAINNET_PARAMS).skip_proof_of_work().build();
let consensus = TestConsensus::new(&config);
Expand Down Expand Up @@ -232,6 +236,7 @@ struct GhostdagTestBlock {

#[tokio::test]
async fn ghostdag_test() {
init_allocator_with_default_settings();
let mut path_strings: Vec<String> =
common::read_dir("testdata/dags").map(|f| f.unwrap().path().to_str().unwrap().to_owned()).collect();
path_strings.sort();
Expand Down Expand Up @@ -316,6 +321,7 @@ fn strings_to_hashes(strings: &Vec<String>) -> Vec<Hash> {

#[tokio::test]
async fn block_window_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS)
.skip_proof_of_work()
.edit_consensus_params(|p| {
Expand Down Expand Up @@ -385,6 +391,7 @@ async fn block_window_test() {

#[tokio::test]
async fn header_in_isolation_validation_test() {
init_allocator_with_default_settings();
let config = Config::new(MAINNET_PARAMS);
let consensus = TestConsensus::new(&config);
let wait_handles = consensus.init();
Expand Down Expand Up @@ -453,6 +460,7 @@ async fn header_in_isolation_validation_test() {

#[tokio::test]
async fn incest_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS).skip_proof_of_work().build();
let consensus = TestConsensus::new(&config);
let wait_handles = consensus.init();
Expand Down Expand Up @@ -481,6 +489,7 @@ async fn incest_test() {

#[tokio::test]
async fn missing_parents_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS).skip_proof_of_work().build();
let consensus = TestConsensus::new(&config);
let wait_handles = consensus.init();
Expand All @@ -505,6 +514,7 @@ async fn missing_parents_test() {
// as a known invalid.
#[tokio::test]
async fn known_invalid_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS).skip_proof_of_work().build();
let consensus = TestConsensus::new(&config);
let wait_handles = consensus.init();
Expand All @@ -530,6 +540,7 @@ async fn known_invalid_test() {

#[tokio::test]
async fn median_time_test() {
init_allocator_with_default_settings();
struct Test {
name: &'static str,
config: Config,
Expand Down Expand Up @@ -603,6 +614,7 @@ async fn median_time_test() {

#[tokio::test]
async fn mergeset_size_limit_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS).skip_proof_of_work().build();
let consensus = TestConsensus::new(&config);
let wait_handles = consensus.init();
Expand Down Expand Up @@ -828,39 +840,46 @@ impl KaspadGoParams {

#[tokio::test]
async fn goref_custom_pruning_depth_test() {
init_allocator_with_default_settings();
json_test("testdata/dags_for_json_tests/goref_custom_pruning_depth", false).await
}

#[tokio::test]
async fn goref_notx_test() {
init_allocator_with_default_settings();
json_test("testdata/dags_for_json_tests/goref-notx-5000-blocks", false).await
}

#[tokio::test]
async fn goref_notx_concurrent_test() {
init_allocator_with_default_settings();
json_test("testdata/dags_for_json_tests/goref-notx-5000-blocks", true).await
}

#[tokio::test]
async fn goref_tx_small_test() {
init_allocator_with_default_settings();
json_test("testdata/dags_for_json_tests/goref-905-tx-265-blocks", false).await
}

#[tokio::test]
async fn goref_tx_small_concurrent_test() {
init_allocator_with_default_settings();
json_test("testdata/dags_for_json_tests/goref-905-tx-265-blocks", true).await
}

#[ignore]
#[tokio::test]
async fn goref_tx_big_test() {
init_allocator_with_default_settings();
// TODO: add this directory to a data repo and fetch dynamically
json_test("testdata/dags_for_json_tests/goref-1.6M-tx-10K-blocks", false).await
}

#[ignore]
#[tokio::test]
async fn goref_tx_big_concurrent_test() {
init_allocator_with_default_settings();
// TODO: add this file to a data repo and fetch dynamically
json_test("testdata/dags_for_json_tests/goref-1.6M-tx-10K-blocks", true).await
}
Expand Down Expand Up @@ -1223,6 +1242,7 @@ fn hex_decode(src: &str) -> Vec<u8> {

#[tokio::test]
async fn bounded_merge_depth_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(DEVNET_PARAMS)
.skip_proof_of_work()
.edit_consensus_params(|p| {
Expand Down Expand Up @@ -1302,6 +1322,7 @@ async fn bounded_merge_depth_test() {

#[tokio::test]
async fn difficulty_test() {
init_allocator_with_default_settings();
async fn add_block(consensus: &TestConsensus, block_time: Option<u64>, parents: Vec<Hash>) -> Header {
let selected_parent = consensus.ghostdag_manager().find_selected_parent(parents.iter().copied());
let block_time = block_time.unwrap_or_else(|| {
Expand Down Expand Up @@ -1620,6 +1641,7 @@ async fn difficulty_test() {

#[tokio::test]
async fn selected_chain_test() {
init_allocator_with_default_settings();
kaspa_core::log::try_init_logger("info");

let config = ConfigBuilder::new(MAINNET_PARAMS)
Expand Down Expand Up @@ -1688,6 +1710,7 @@ fn selected_chain_store_iterator(consensus: &TestConsensus, pruning_point: Hash)

#[tokio::test]
async fn staging_consensus_test() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS).build();

let db_tempdir = get_kaspa_tempdir();
Expand Down
5 changes: 4 additions & 1 deletion testing/integration/src/consensus_pipeline_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use futures_util::future::try_join_all;
use kaspa_alloc::init_allocator_with_default_settings;
use kaspa_consensus::{
config::ConfigBuilder, consensus::test_consensus::TestConsensus, params::MAINNET_PARAMS,
processes::reachability::tests::StoreValidationExtensions,
Expand All @@ -11,6 +12,7 @@ use tokio::join;

#[tokio::test]
async fn test_concurrent_pipeline() {
init_allocator_with_default_settings();
let config = ConfigBuilder::new(MAINNET_PARAMS).skip_proof_of_work().edit_consensus_params(|p| p.genesis.hash = 1.into()).build();
let consensus = TestConsensus::new(&config);
let wait_handles = consensus.init();
Expand All @@ -31,7 +33,7 @@ async fn test_concurrent_pipeline() {

for (hash, parents) in blocks {
// Submit to consensus twice to make sure duplicates are handled
let b = consensus.build_block_with_parents(hash, parents).to_immutable();
let b: kaspa_consensus_core::block::Block = consensus.build_block_with_parents(hash, parents).to_immutable();
let results = join!(
consensus.validate_and_insert_block(b.clone()).virtual_state_task,
consensus.validate_and_insert_block(b).virtual_state_task
Expand Down Expand Up @@ -76,6 +78,7 @@ async fn test_concurrent_pipeline() {

#[tokio::test]
async fn test_concurrent_pipeline_random() {
init_allocator_with_default_settings();
let genesis: Hash = blockhash::new_unique();
let bps = 8;
let delay = 2;
Expand Down
4 changes: 4 additions & 0 deletions testing/integration/src/daemon_integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use kaspa_addresses::Address;
use kaspa_alloc::init_allocator_with_default_settings;
use kaspa_consensusmanager::ConsensusManager;
use kaspa_core::task::runtime::AsyncRuntime;
use kaspa_notify::scope::{Scope, VirtualDaaScoreChangedScope};
Expand All @@ -10,6 +11,7 @@ use std::{sync::Arc, time::Duration};

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn daemon_sanity_test() {
init_allocator_with_default_settings();
kaspa_core::log::try_init_logger("INFO");

// let total_fd_limit = kaspa_utils::fd_budget::get_limit() / 2 - 128;
Expand All @@ -32,6 +34,7 @@ async fn daemon_sanity_test() {

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn daemon_mining_test() {
init_allocator_with_default_settings();
kaspa_core::log::try_init_logger("INFO");

let args = Args {
Expand Down Expand Up @@ -103,6 +106,7 @@ async fn daemon_mining_test() {
// The following test runtime parameters are required for a graceful shutdown of the gRPC server
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn daemon_cleaning_test() {
init_allocator_with_default_settings();
kaspa_core::log::try_init_logger("info,kaspa_grpc_core=trace,kaspa_grpc_server=trace,kaspa_grpc_client=trace,kaspa_core=trace");
let args = Args { devnet: true, ..Default::default() };
let consensus_manager;
Expand Down
5 changes: 0 additions & 5 deletions testing/integration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#[ctor::ctor]
fn init_allocator() {
kaspa_alloc::init_allocator_with_default_settings();
}

pub mod common;

#[cfg(test)]
Expand Down

0 comments on commit 8479322

Please sign in to comment.