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

Remove nervosnetwork/faketime, replace cargo test by nextest-rs/nextest #3777

Merged
merged 3 commits into from
Jan 16, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/ci_unit_tests_macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
needs: prologue
runs-on: macos-11
steps:
- name: Install nextest
uses: taiki-e/install-action@nextest
- uses: actions/checkout@v3
- run: |
if [[ ${{ needs.prologue.outputs.os_skip }} == run ]] && [[ ${{ needs.prologue.outputs.job_skip }} == run ]];then
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci_unit_tests_ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
profile: minimal
toolchain: 1.61.0
- run: sudo apt-get update && sudo apt-get install -y libssl-dev pkg-config libclang-dev
- name: Install nextest
uses: taiki-e/install-action@nextest
- uses: actions/checkout@v3
- run: |
if [[ ${{ needs.prologue.outputs.os_skip }} == run ]] && [[ ${{ needs.prologue.outputs.job_skip }} == run ]];then
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci_unit_tests_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ jobs:
scoop install git
scoop bucket add extras
scoop install llvm yasm
- name: Install cargo-nextest
run: |
scoop install wget
wget https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-0.9.36/cargo-nextest-0.9.36-x86_64-pc-windows-msvc.zip
7z x cargo-nextest-0.9.36-x86_64-pc-windows-msvc.zip -oC:\Users\Administrator\.cargo\bin -y
- run: |
if [[ ${{ needs.prologue.outputs.os_skip }} == run ]] && [[ ${{ needs.prologue.outputs.job_skip }} == run ]];then
devtools/ci/ci_main.sh
Expand Down
40 changes: 17 additions & 23 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [
"util",
"util/occupied-capacity/core",
"util/channel",
"util/systemtime",
"util/fixed-hash/core",
"util/build-info",
"util/logger",
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ GRCOV_EXCL_STOP = ^\s*\)(;)?$$
GRCOV_EXCL_LINE = \s*(((log|ckg_logger)::)?(trace|debug|info|warn|error)|(debug_)?assert(_eq|_ne|_error_eq))!\(.*\)(;)?$$

##@ Testing
.PHONY: doc-test
doc-test: ## Run doc tests
cargo test --all --doc

.PHONY: test
test: quick-test ## Run all tests, including some tests can be time-consuming to execute (tagged with [ignore])
cargo test ${VERBOSE} --features ${CKB_FEATURES} --all -- --nocapture --ignored
test: ## Run all tests, including some tests can be time-consuming to execute (tagged with [ignore])
cargo nextest run ${VERBOSE} --features ${CKB_FEATURES} --workspace --hide-progress-bar --success-output immediate-final --failure-output immediate-final --run-ignored all
$(MAKE) doc-test

.PHONY: quick-test
quick-test: ## Run all tests, excluding some tests can be time-consuming to execute (tagged with [ignore])
cargo test ${VERBOSE} --features ${CKB_FEATURES} --all -- --nocapture
cargo nextest run ${VERBOSE} --features ${CKB_FEATURES} --workspace --hide-progress-bar --success-output immediate-final --failure-output immediate-final --run-ignored default
$(MAKE) doc-test

.PHONY: cov-install-tools
cov-install-tools:
Expand Down
3 changes: 2 additions & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ckb-store = { path = "../store", version = "= 0.107.0-pre" }
ckb-verification = { path = "../verification", version = "= 0.107.0-pre" }
ckb-verification-contextual = { path = "../verification/contextual", version = "= 0.107.0-pre" }
ckb-verification-traits = { path = "../verification/traits", version = "= 0.107.0-pre" }
faketime = "0.2.0"
ckb-systemtime = { path = "../util/systemtime", version = "= 0.107.0-pre" }
ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.107.0-pre" }
ckb-dao = { path = "../util/dao", version = "= 0.107.0-pre" }
ckb-proposal-table = { path = "../util/proposal-table", version = "= 0.107.0-pre" }
Expand All @@ -39,6 +39,7 @@ ckb-network = { path = "../network", version = "= 0.107.0-pre" }
ckb-launcher = { path = "../util/launcher", version = "= 0.107.0-pre" }
lazy_static = "1.4"
tempfile = "3.0"
ckb-systemtime = { path = "../util/systemtime", version = "= 0.107.0-pre" ,features = ["enable_faketime"]}

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ckb_rust_unstable_port::IsSorted;
use ckb_shared::shared::Shared;
use ckb_stop_handler::{SignalSender, StopHandler};
use ckb_store::{attach_block_cell, detach_block_cell, ChainStore, StoreTransaction};
use ckb_systemtime::unix_time_as_millis;
use ckb_types::{
core::{
cell::{
Expand All @@ -32,7 +33,6 @@ use ckb_verification::cache::Completed;
use ckb_verification::{BlockVerifier, InvalidParentError, NonContextualBlockTxsVerifier};
use ckb_verification_contextual::{ContextualBlockVerifier, VerifyContext};
use ckb_verification_traits::{Switch, Verifier};
use faketime::unix_time_as_millis;
use std::collections::{HashSet, VecDeque};
use std::sync::Arc;
use std::{cmp, thread};
Expand Down
4 changes: 2 additions & 2 deletions chain/src/tests/block_assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ fn create_cellbase(number: BlockNumber, epoch: &EpochExt) -> TransactionView {
#[cfg(not(disable_faketime))]
#[test]
fn test_block_template_timestamp() {
let faketime_file = faketime::millis_tempfile(0).expect("create faketime file");
::std::env::set_var("FAKETIME", faketime_file.as_os_str());
let mut _faketime_guard = ckb_systemtime::faketime();
_faketime_guard.set_faketime(0);

let consensus = Consensus::default();
let epoch = consensus.genesis_epoch_ext().clone();
Expand Down
2 changes: 1 addition & 1 deletion chain/src/tests/find_fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use crate::tests::util::{MockChain, MockStore};
use ckb_chain_spec::consensus::{Consensus, ProposalWindow};
use ckb_launcher::SharedBuilder;
use ckb_store::ChainStore;
use ckb_systemtime::unix_time_as_millis;
use ckb_types::{
core::{BlockBuilder, BlockExt, BlockView},
packed,
prelude::Pack,
U256,
};
use ckb_verification_traits::Switch;
use faketime::unix_time_as_millis;
use std::collections::HashSet;
use std::sync::Arc;

Expand Down
3 changes: 2 additions & 1 deletion network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ckb-metrics = {path = "../util/metrics", version = "= 0.107.0-pre"}
tokio = { version = "1", features = ["sync", "macros"] }
tokio-util = { version = "0.7", features = ["codec"] }
futures = "0.3"
faketime = "0.2.0"
ckb-systemtime = {path = "../util/systemtime", version = "= 0.107.0-pre"}
lazy_static = { version = "1.3.0", optional = true }
bs58 = { version = "0.4.0", optional = true }
sentry = { version = "0.26.0", optional = true }
Expand Down Expand Up @@ -48,6 +48,7 @@ criterion = "0.4"
proptest = "1.0"
num_cpus = "1.10"
once_cell = "1.8.0"
ckb-systemtime = {path = "../util/systemtime", version = "= 0.107.0-pre", features = ["enable_faketime"]}

[[bench]]
name = "peer_store"
Expand Down
2 changes: 1 addition & 1 deletion network/src/peer_store/addr_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl AddrManager {
let mut duplicate_ips = HashSet::new();
let mut addr_infos = Vec::with_capacity(count);
let mut rng = rand::thread_rng();
let now_ms = faketime::unix_time_as_millis();
let now_ms = ckb_systemtime::unix_time_as_millis();
for i in 0..self.random_ids.len() {
// reuse the for loop to shuffle random ids
// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
Expand Down
2 changes: 1 addition & 1 deletion network/src/peer_store/ban_list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Ban list
use crate::peer_store::types::{ip_to_network, BannedAddr};
use crate::peer_store::Multiaddr;
use faketime::unix_time_as_millis;
use ckb_systemtime::unix_time_as_millis;
use ipnetwork::IpNetwork;
use p2p::utils::multiaddr_to_socketaddr;
use std::collections::HashMap;
Expand Down
Loading