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

Fix dao related CI #585

Merged
merged 1 commit into from
Mar 4, 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
12 changes: 11 additions & 1 deletion test/src/miner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::util::temp_dir;
use ckb_app_config::BlockAssemblerConfig;
use ckb_jsonrpc_types::{BlockTemplate, ProposalShortId};
use ckb_jsonrpc_types::{BlockTemplate, EpochNumberWithFraction, ProposalShortId};
use ckb_sdk::{Address, AddressPayload, CkbRpcClient, NetworkType};
use ckb_types::{
core::BlockNumber,
Expand Down Expand Up @@ -48,6 +48,16 @@ impl Miner {
.expect("RPC generate_block")
}

pub fn generate_epochs(&self, num_epochs: u64, epoch_length: u64) -> EpochNumberWithFraction {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If our dao tests are all integer multiples of epochs, for simplicity, it is suggested to remove the epoch_length parameter.

ckb_types::core::EpochNumberWithFraction::new(num_epochs, 0, 1)

Can generate_blocks be removed?

Copy link
Collaborator Author

@eval-exec eval-exec Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is suggested to remove the epoch_length parameter

Ok, we can improve this later.

Can generate_blocks be removed?

generate_blocks can not be removed, many specs are using it.

let epoch_number_with_fraction =
ckb_types::core::EpochNumberWithFraction::new(num_epochs, 0, epoch_length);
self.rpc
.lock()
.unwrap()
.generate_epochs(epoch_number_with_fraction.into())
.expect("RPC generate_epoch")
}

pub fn generate_blocks(&self, count: u64) {
log::info!("generating {} blocks...", count);
(0..count).for_each(|_| {
Expand Down
6 changes: 3 additions & 3 deletions test/src/spec/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl Spec for DaoPrepareOne {
// Drive the chain until since mature and then withdraw
setup
.miner()
.generate_blocks(LOCK_PERIOD_EPOCHES * EPOCH_LENGTH);
.generate_epochs(LOCK_PERIOD_EPOCHES, EPOCH_LENGTH);
let out_points = vec![new_out_point(prepare_tx_hash, 0)];
let _withdraw_tx_hash = withdraw(setup, &out_points);
assert_eq!(deposited_capacity(setup), 0);
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Spec for DaoPrepareMultiple {
// Drive the chain until since mature and then withdraw
setup
.miner()
.generate_blocks(LOCK_PERIOD_EPOCHES * EPOCH_LENGTH);
.generate_epochs(LOCK_PERIOD_EPOCHES, EPOCH_LENGTH);
let out_points = (0..shannons.len())
.map(|i| new_out_point(&prepare_tx_hash, i))
.collect::<Vec<_>>();
Expand Down Expand Up @@ -135,7 +135,7 @@ impl Spec for DaoWithdrawMultiple {
// Drive the chain until since mature and then withdraw
setup
.miner()
.generate_blocks(LOCK_PERIOD_EPOCHES * EPOCH_LENGTH);
.generate_epochs(LOCK_PERIOD_EPOCHES, EPOCH_LENGTH);
let out_points = prepare_tx_hashes
.into_iter()
.map(|hash| new_out_point(hash, 0))
Expand Down
Loading