Skip to content

Commit

Permalink
Merge pull request #504 from chenyukang/yukang-fix-clippy
Browse files Browse the repository at this point in the history
chore: fix clippy and enable it in CI
  • Loading branch information
quake authored Jan 30, 2025
2 parents 58c0518 + 81fc710 commit 5154ff1
Show file tree
Hide file tree
Showing 33 changed files with 561 additions and 616 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test:

.PHONY: clippy
clippy:
cargo clippy --all --all-targets --all-features
cargo clippy --all --all-targets --all-features -- -D warnings -A clippy::module-inception

.PHONY: bless
bless:
Expand Down
2 changes: 1 addition & 1 deletion src/cch/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ impl CchActor {
+ self.config.ckb_final_tlc_expiry_delta,
hash_algorithm: HashAlgorithm::Sha256,
onion_packet: None,
shared_secret: NO_SHARED_SECRET.clone(),
shared_secret: NO_SHARED_SECRET,
previous_tlc: None,
},
rpc_reply,
Expand Down
4 changes: 2 additions & 2 deletions src/ckb/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl ContractsContext {

pub(crate) fn get_udt_info(&self, udt_script: &Script) -> Option<&UdtArgInfo> {
for udt in &self.get_udt_whitelist().0 {
if let Some(_type) = udt_script.hash_type().try_into().ok() {
if let Ok(_type) = udt_script.hash_type().try_into() {
if udt.script.code_hash.pack() == udt_script.code_hash()
&& udt.script.hash_type == _type
{
Expand Down Expand Up @@ -249,7 +249,7 @@ fn get_contracts_context() -> &'static ContractsContext {
}

#[cfg(test)]
fn get_contracts_context<'a>() -> ContractsContext {
fn get_contracts_context() -> ContractsContext {
super::tests::test_utils::MOCK_CONTEXT
.read()
.expect("read mock context")
Expand Down
10 changes: 5 additions & 5 deletions src/ckb/funding/funding_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ impl FundingTxBuilder {

match self.request.udt_type_script {
Some(ref udt_type_script) => {
let mut udt_amount = self.request.local_amount as u128;
let mut udt_amount = self.request.local_amount;
let mut ckb_amount = self.request.local_reserved_ckb_amount;

// To make tx building easier, do not include the amount not funded yet in the
// funding cell.
if remote_funded {
udt_amount += self.request.remote_amount as u128;
udt_amount += self.request.remote_amount;
ckb_amount = ckb_amount
.checked_add(self.request.remote_reserved_ckb_amount)
.ok_or(FundingError::InvalidChannel)?;
Expand Down Expand Up @@ -190,7 +190,7 @@ impl FundingTxBuilder {
.ok_or(FundingError::InvalidChannel)?;
}
let ckb_output = packed::CellOutput::new_builder()
.capacity(Capacity::shannons(ckb_amount as u64).pack())
.capacity(Capacity::shannons(ckb_amount).pack())
.lock(self.context.funding_cell_lock_script.clone())
.build();
Ok((ckb_output, packed::Bytes::default()))
Expand All @@ -206,7 +206,7 @@ impl FundingTxBuilder {
outputs_data: &mut Vec<packed::Bytes>,
cell_deps: &mut HashSet<packed::CellDep>,
) -> Result<(), TxBuilderError> {
let udt_amount = self.request.local_amount as u128;
let udt_amount = self.request.local_amount;
// return early if we don't need to build UDT cell
if self.request.udt_type_script.is_none() || udt_amount == 0 {
return Ok(());
Expand Down Expand Up @@ -306,7 +306,7 @@ impl FundingTxBuilder {
let ckb_client = CkbRpcClient::new(&self.context.rpc_url);
let cell_dep_resolver = ckb_client
.get_block_by_number(0.into())
.map_err(|err| FundingError::CkbRpcError(err))?
.map_err(FundingError::CkbRpcError)?
.and_then(|genesis_block| {
DefaultCellDepResolver::from_genesis(&BlockView::from(genesis_block)).ok()
})
Expand Down
10 changes: 8 additions & 2 deletions src/ckb/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ pub struct MockContext {
pub contracts_context: ContractsContext,
}

impl Default for MockContext {
fn default() -> Self {
Self::new()
}
}

impl MockContext {
pub fn new() -> Self {
let binaries = [
Expand Down Expand Up @@ -109,7 +115,7 @@ impl MockContext {
.get(&Contract::CkbAuth)
.unwrap()
.clone()
.get(0)
.first()
.unwrap()
.clone(),
]
Expand Down Expand Up @@ -167,7 +173,7 @@ impl Actor for TraceTxReplier {
myself: ActorRef<Self::Msg>,
(notifier, timeout, reply_port): Self::Arguments,
) -> Result<Self::State, ActorProcessingErr> {
let _ = myself.send_after(timeout, || TraceTxResult::Timeout());
myself.send_after(timeout, TraceTxResult::Timeout);
let hash = self.tx_hash.clone();
notifier.subscribe(myself, move |notification| {
if notification.0 == hash {
Expand Down
Loading

0 comments on commit 5154ff1

Please sign in to comment.