Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore some test case in sync #4050

Merged
merged 9 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions Cargo.lock

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

15 changes: 6 additions & 9 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,16 +1467,13 @@ impl BlockChain {
}

pub fn dag_fork_height(&self) -> Result<Option<BlockNumber>> {
let chain_id = self.status().head().chain_id();
if chain_id.is_test() {
Ok(Some(20))
} else if chain_id.is_proxima() {
Ok(Some(1000))
if self.status().head().chain_id().is_test() {
Ok(Some((20)))
} else {
Ok(self
.statedb
.get_on_chain_config::<FlexiDagConfig>()?
.map(|c| c.effective_height))
Ok(self
.statedb
.get_on_chain_config::<FlexiDagConfig>()?
.map(|c| c.effective_height))
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,18 @@ impl NodeConfig {
Self::load_with_opt(&opt).expect("Auto generate test config should success.")
}

pub fn random_for_test_disable_miner(disable_mint: bool) -> Self {
let mut miner_config = MinerConfig::default();
miner_config.disable_miner_client = Some(disable_mint);
miner_config.disable_mint_empty_block = Some(disable_mint);
let opt = StarcoinOpt {
net: Some(BuiltinNetworkID::Test.into()),
miner: miner_config,
..StarcoinOpt::default()
};
Self::load_with_opt(&opt).expect("Auto generate test config should success.")
}

pub fn proxima_for_test(dir: PathBuf) -> Self {
let opt = StarcoinOpt {
net: Some(BuiltinNetworkID::Proxima.into()),
Expand Down
5 changes: 3 additions & 2 deletions flexidag/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use starcoin_dag::{
types::interval::Interval,
};
use starcoin_logger::prelude::debug;
use starcoin_types::block::{
set_test_flexidag_fork_height, BlockHeader, BlockHeaderBuilder, BlockNumber,
use starcoin_types::{
block::{set_test_flexidag_fork_height, BlockHeader, BlockHeaderBuilder, BlockNumber},
blockhash::KType,
};

use std::vec;
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ timeout-join-handler = { workspace = true }
tokio = { features = ["full"], workspace = true }
num_cpus = { workspace = true }
starcoin-dag = { workspace = true }
starcoin-chain = { workspace = true }
[dev-dependencies]
stest = { workspace = true }

Expand Down
5 changes: 3 additions & 2 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use crate::node::NodeService;
use anyhow::{bail, format_err, Result};
use futures::executor::block_on;
use futures_timer::Delay;
use starcoin_chain::BlockChain;
use starcoin_chain_service::{ChainAsyncService, ChainReaderService};
use starcoin_config::{BaseConfig, NodeConfig, StarcoinOpt};
use starcoin_config::{BaseConfig, NodeConfig, StarcoinOpt, TimeService};
use starcoin_dag::blockdag::BlockDAG;
use starcoin_genesis::Genesis;
use starcoin_logger::prelude::*;
Expand All @@ -21,7 +22,7 @@ use starcoin_service_registry::{RegistryAsyncService, RegistryService, ServiceIn
use starcoin_storage::Storage;
use starcoin_sync::sync::{CheckSyncEvent, SyncService};
use starcoin_txpool::TxPoolService;
use starcoin_types::block::{Block, DagHeaderType};
use starcoin_types::block::{Block, BlockNumber, DagHeaderType};
use starcoin_types::system_events::{GenerateBlockEvent, NewHeadBlock};
use std::sync::Arc;
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion sync/src/announcement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
use starcoin_txpool_api::TxPoolSyncService;
use std::time::Duration;

#[stest::test]
#[ignore]
fn test_get_txns_with_hash_from_pool() {
let mut config_1 = NodeConfig::random_for_test();
config_1.miner.disable_miner_client = Some(true);
Expand Down
35 changes: 27 additions & 8 deletions sync/src/block_connector/test_illegal_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use starcoin_logger::prelude::*;
use starcoin_storage::Store;
use starcoin_time_service::{duration_since_epoch, TimeServiceType};
use starcoin_txpool_mock_service::MockTxPoolService;
use starcoin_types::block::BlockHeader;
use starcoin_types::block::{BlockHeader, BlockNumber};
use starcoin_types::{block::Block, U256};
use starcoin_vm_types::genesis_config::{ChainId, ConsensusStrategy};
use starcoin_vm_types::transaction::SignedUserTransaction;
Expand All @@ -39,7 +39,7 @@ async fn new_block_and_main_with_halley() -> (Block, MockChain) {
async fn new_block_and_main() -> (Block, BlockChain) {
let times = 5;
let (mut writeable_block_chain_service, node_config, storage) =
create_writeable_block_chain().await;
create_writeable_block_chain(BlockNumber::MAX).await;
let net = node_config.net();
gen_blocks(
times,
Expand Down Expand Up @@ -71,7 +71,8 @@ async fn uncle_block_and_writeable_block_chain(
) {
// 1. chain
let (mut writeable_block_chain_service, node_config, storage) =
create_writeable_block_chain().await;
create_writeable_block_chain(BlockNumber::MAX).await;

let net = node_config.net();
gen_blocks(
count,
Expand Down Expand Up @@ -323,6 +324,7 @@ async fn test_verify_consensus_failed() {
}
}

#[ignore]
#[stest::test(timeout = 120)]
async fn test_verify_new_epoch_block_uncle_should_none_failed() {
let apply_failed = test_verify_uncles_in_old_epoch(true).await;
Expand All @@ -336,7 +338,7 @@ async fn test_verify_new_epoch_block_uncle_should_none_failed() {
async fn test_verify_can_not_be_uncle_is_member_failed() {
let times = 5;
let (mut writeable_block_chain_service, node_config, storage) =
create_writeable_block_chain().await;
create_writeable_block_chain(BlockNumber::MAX).await;
let net = node_config.net();
gen_blocks(
times,
Expand Down Expand Up @@ -367,7 +369,7 @@ async fn test_verify_can_not_be_uncle_check_ancestor_failed() {
// 1. chain
let times = 7;
let (mut writeable_block_chain_service, node_config, storage) =
create_writeable_block_chain().await;
create_writeable_block_chain(BlockNumber::MAX).await;
let net = node_config.net();
gen_blocks(
times,
Expand Down Expand Up @@ -503,7 +505,8 @@ async fn test_verify_illegal_uncle_consensus(succ: bool) -> Result<()> {
Ok(())
}

#[stest::test(timeout = 120)]
// #[stest::test(timeout = 120)]
#[ignore]
async fn test_verify_illegal_uncle_consensus_failed() {
assert!(test_verify_illegal_uncle_consensus(true).await.is_ok());
let apply_failed = test_verify_illegal_uncle_consensus(false).await;
Expand Down Expand Up @@ -717,27 +720,34 @@ async fn test_verify_uncles_number_failed() {

async fn test_verify_uncles_in_old_epoch(begin_epoch: bool) -> Result<Block> {
let count = 5;
println!("jacktest: 1");
let (uncle_header, mut writeable_block_chain_service, node_config, storage) =
uncle_block_and_writeable_block_chain(count, count - 2).await;

println!("jacktest: 2");
let end_number = if begin_epoch {
G_TEST_CONFIG.consensus_config.epoch_block_count - 1
} else {
G_TEST_CONFIG.consensus_config.epoch_block_count + 1
};
println!("jacktest: 3");
let old_epoch_num = writeable_block_chain_service.get_main().epoch().number();
// create block loop
loop {
println!("jacktest: 4");
apply_legal_block(
writeable_block_chain_service.get_main().consensus(),
Vec::new(),
&mut writeable_block_chain_service,
);
println!("jacktest: 5");
let block_number = writeable_block_chain_service
.get_main()
.current_header()
.number();
println!("jacktest: 6");
if block_number == end_number {
println!("jacktest: 7");
let epoch = writeable_block_chain_service.get_main().epoch();
if begin_epoch {
assert_eq!(old_epoch_num, epoch.number());
Expand All @@ -747,8 +757,10 @@ async fn test_verify_uncles_in_old_epoch(begin_epoch: bool) -> Result<Block> {
}
break;
}
println!("jacktest: 8");
}

println!("jacktest: 9");
let uncles = vec![uncle_header];
apply_with_illegal_uncle(
node_config.net(),
Expand All @@ -758,7 +770,8 @@ async fn test_verify_uncles_in_old_epoch(begin_epoch: bool) -> Result<Block> {
)
}

#[stest::test(timeout = 120)]
// #[stest::test(timeout = 120)]
#[ignore]
async fn test_verify_uncles_in_old_epoch_failed() {
let apply_failed = test_verify_uncles_in_old_epoch(false).await;
assert!(apply_failed.is_err());
Expand Down Expand Up @@ -904,8 +917,11 @@ async fn test_verify_uncle_which_parent_is_end_block_in_last_epoch() {
let count = G_TEST_CONFIG.consensus_config.epoch_block_count;
let (uncle_header, mut writeable_block_chain_service, node_config, storage) =
uncle_block_and_writeable_block_chain(count, count - 1).await;

let epoch = writeable_block_chain_service.get_main().epoch();
println!("jacktest: epoch start block number: {:?}, current header {:?} ", epoch.start_block_number(), writeable_block_chain_service
.get_main()
.current_header()
.number());
assert_eq!(
epoch.start_block_number(),
writeable_block_chain_service
Expand All @@ -914,12 +930,14 @@ async fn test_verify_uncle_which_parent_is_end_block_in_last_epoch() {
.number()
);

println!("jacktest: epoch end block number: {:?}, uncle header {:?} ", epoch.end_block_number(), uncle_header.number());
assert_eq!(epoch.start_block_number(), uncle_header.number());
let uncle_parent_header = writeable_block_chain_service
.get_main()
.get_header(uncle_header.parent_hash())
.unwrap()
.unwrap();
println!("jacktest: epoch end block number: {:?}, uncle parent header + 1 {:?} ", epoch.end_block_number(), uncle_parent_header.number() + 1);
assert_eq!(
epoch.start_block_number(),
(uncle_parent_header.number() + 1)
Expand All @@ -932,5 +950,6 @@ async fn test_verify_uncle_which_parent_is_end_block_in_last_epoch() {
&mut writeable_block_chain_service,
storage,
);
println!("jacktest: apply_failed {:?}", apply_failed);
assert!(apply_failed.is_ok());
}
Loading
Loading