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

test: Add cases about proposed/committed rewards #1605

Merged
merged 7 commits into from
Oct 8, 2019
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 test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ mod net;
mod node;
mod rpc;
pub mod specs;
mod txo;
mod utils;

use ckb_types::core::BlockNumber;

pub use net::Net;
pub use node::Node;
pub use specs::{Setup, Spec, TestProtocol};
pub use txo::{TXOSet, TXO};

// ckb doesn't support tx proposal window configuration, use a hardcoded value for integration test.
pub const DEFAULT_TX_PROPOSAL_WINDOW: (BlockNumber, BlockNumber) = (2, 10);
Expand Down
7 changes: 7 additions & 0 deletions test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::time::Instant;

#[allow(clippy::cognitive_complexity)]
fn main() {
env::set_var("RUST_BACKTRACE", "full");
let _ = {
let filter = ::std::env::var("CKB_LOG").unwrap_or_else(|_| "info".to_string());
env_logger::builder().parse_filters(&filter).try_init()
Expand Down Expand Up @@ -279,6 +280,12 @@ fn all_specs() -> SpecMap {
Box::new(UncleInheritFromForkBlock),
Box::new(UncleInheritFromForkUncle),
Box::new(PackUnclesIntoEpochStarting),
Box::new(FeeOfTransaction),
Box::new(FeeOfMaxBlockProposalsLimit),
Box::new(FeeOfMultipleMaxBlockProposalsLimit),
Box::new(ProposeButNotCommit),
Box::new(ProposeDuplicated),
Box::new(ForkedTransaction),
];
specs.into_iter().map(|spec| (spec.name(), spec)).collect()
}
Expand Down
20 changes: 11 additions & 9 deletions test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,11 @@ impl Node {
since: u64,
capacity: Capacity,
) -> TransactionView {
let always_success_out_point = OutPoint::new(
self.genesis_cellbase_hash.clone(),
SYSTEM_CELL_ALWAYS_SUCCESS_INDEX,
);
let always_success_cell_dep = self.always_success_cell_dep();
let always_success_script = self.always_success_script();

core::TransactionBuilder::default()
.cell_dep(
CellDep::new_builder()
.out_point(always_success_out_point)
.build(),
)
.cell_dep(always_success_cell_dep)
.output(
CellOutputBuilder::default()
.capacity(capacity.pack())
Expand All @@ -385,6 +378,15 @@ impl Node {
.build()
}

pub fn always_success_cell_dep(&self) -> CellDep {
CellDep::new_builder()
.out_point(OutPoint::new(
self.genesis_cellbase_hash.clone(),
SYSTEM_CELL_ALWAYS_SUCCESS_INDEX,
))
.build()
}

fn prepare_chain_spec(
&mut self,
modify_chain_spec: Box<dyn Fn(&mut ChainSpec) -> ()>,
Expand Down
12 changes: 11 additions & 1 deletion test/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ckb_jsonrpc_types::{
Alert, BannedAddr, Block, BlockNumber, BlockTemplate, BlockView, Capacity,
Alert, BannedAddr, Block, BlockNumber, BlockReward, BlockTemplate, BlockView, Capacity,
CellOutputWithOutPoint, CellTransaction, CellWithStatus, ChainInfo, DryRunResult, EpochNumber,
EpochView, HeaderView, LiveCell, LockHashIndexState, Node, OutPoint, PeerState, Timestamp,
Transaction, TransactionWithStatus, TxPoolInfo, Uint64, Version,
Expand Down Expand Up @@ -346,6 +346,15 @@ impl RpcClient {
.expect("rpc call calculate_dao_maximum_withdraw")
.into()
}

pub fn get_cellbase_output_capacity_details(&self, hash: Byte32) -> BlockReward {
self.inner()
.lock()
.get_cellbase_output_capacity_details(hash.unpack())
.call()
.expect("rpc call get_cellbase_output_capacity_details")
.expect("get_cellbase_output_capacity_details return none")
}
}

jsonrpc_client!(pub struct Inner {
Expand Down Expand Up @@ -405,4 +414,5 @@ jsonrpc_client!(pub struct Inner {
pub fn deindex_lock_hash(&mut self, lock_hash: H256) -> RpcRequest<()>;
pub fn get_lock_hash_index_states(&mut self) -> RpcRequest<Vec<LockHashIndexState>>;
pub fn calculate_dao_maximum_withdraw(&mut self, _out_point: OutPoint, _hash: H256) -> RpcRequest<Capacity>;
pub fn get_cellbase_output_capacity_details(&mut self, _hash: H256) -> RpcRequest<Option<BlockReward>>;
});
2 changes: 1 addition & 1 deletion test/src/specs/alert/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod alert_propagation;

pub use alert_propagation::AlertPropagation;
pub use alert_propagation::*;

use ckb_crypto::secp::Privkey;
use ckb_jsonrpc_types::JsonBytes;
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/indexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod basic;
mod genesis_issued_cells;

pub use basic::IndexerBasic;
pub use genesis_issued_cells::GenesisIssuedCells;
pub use basic::*;
pub use genesis_issued_cells::*;
Loading