Skip to content

Commit c55aeef

Browse files
committed
all: Run 'cargo clippy --fix --all-targets'
1 parent 862abdb commit c55aeef

45 files changed

Lines changed: 321 additions & 387 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chain/ethereum/src/adapter.rs

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ mod tests {
14101410
filter.event_signatures.sort();
14111411
}
14121412
assert_eq!(expected_log_filters, actual_log_filters);
1413-
assert_eq!(true, actual_send_all_block_headers);
1413+
assert!(actual_send_all_block_headers);
14141414
}
14151415

14161416
#[test]
@@ -1477,7 +1477,7 @@ mod tests {
14771477
}
14781478
assert_eq!(expected_log_filters, actual_log_filters);
14791479

1480-
assert_eq!(true, actual_send_all_block_headers);
1480+
assert!(actual_send_all_block_headers);
14811481
}
14821482

14831483
#[test]
@@ -1504,76 +1504,63 @@ mod tests {
15041504
wildcard_signatures: HashSet::from_iter(vec![[11u8; 4]]),
15051505
};
15061506

1507-
assert_eq!(
1508-
false,
1509-
filter.matches(&call(address(2), vec![])),
1507+
assert!(
1508+
!filter.matches(&call(address(2), vec![])),
15101509
"call with empty bytes are always ignore, whatever the condition"
15111510
);
15121511

1513-
assert_eq!(
1514-
false,
1515-
filter.matches(&call(address(4), vec![1; 36])),
1512+
assert!(
1513+
!filter.matches(&call(address(4), vec![1; 36])),
15161514
"call with incorrect address should be ignored"
15171515
);
15181516

1519-
assert_eq!(
1520-
true,
1517+
assert!(
15211518
filter.matches(&call(address(1), vec![1; 36])),
15221519
"call with correct address & signature should match"
15231520
);
15241521

1525-
assert_eq!(
1526-
true,
1522+
assert!(
15271523
filter.matches(&call(address(1), vec![1; 32])),
15281524
"call with correct address & signature, but with incorrect input size should match"
15291525
);
15301526

1531-
assert_eq!(
1532-
false,
1533-
filter.matches(&call(address(1), vec![4u8; 36])),
1527+
assert!(
1528+
!filter.matches(&call(address(1), vec![4u8; 36])),
15341529
"call with correct address but incorrect signature for a specific contract filter (i.e. matches some signatures) should be ignored"
15351530
);
15361531

1537-
assert_eq!(
1538-
false,
1539-
filter.matches(&call(address(0), vec![11u8; 36])),
1532+
assert!(
1533+
!filter.matches(&call(address(0), vec![11u8; 36])),
15401534
"this signature should not match filter1, this avoid false passes if someone changes the code"
15411535
);
1542-
assert_eq!(
1543-
false,
1544-
filter2.matches(&call(address(1), vec![10u8; 36])),
1536+
assert!(
1537+
!filter2.matches(&call(address(1), vec![10u8; 36])),
15451538
"this signature should not match filter2 because the address is not the expected one"
15461539
);
1547-
assert_eq!(
1548-
true,
1540+
assert!(
15491541
filter2.matches(&call(address(0), vec![10u8; 36])),
15501542
"this signature should match filter2 on the non wildcard clause"
15511543
);
1552-
assert_eq!(
1553-
true,
1544+
assert!(
15541545
filter2.matches(&call(address(0), vec![11u8; 36])),
15551546
"this signature should match filter2 on the wildcard clause"
15561547
);
15571548

15581549
// extend filter1 and test the filter 2 stuff again
15591550
filter.extend(filter2);
1560-
assert_eq!(
1561-
true,
1551+
assert!(
15621552
filter.matches(&call(address(0), vec![11u8; 36])),
15631553
"this signature should not match filter1, this avoid false passes if someone changes the code"
15641554
);
1565-
assert_eq!(
1566-
false,
1567-
filter.matches(&call(address(1), vec![10u8; 36])),
1555+
assert!(
1556+
!filter.matches(&call(address(1), vec![10u8; 36])),
15681557
"this signature should not match filter2 because the address is not the expected one"
15691558
);
1570-
assert_eq!(
1571-
true,
1559+
assert!(
15721560
filter.matches(&call(address(0), vec![10u8; 36])),
15731561
"this signature should match filter2 on the non wildcard clause"
15741562
);
1575-
assert_eq!(
1576-
true,
1563+
assert!(
15771564
filter.matches(&call(address(0), vec![11u8; 36])),
15781565
"this signature should match filter2 on the wildcard clause"
15791566
);
@@ -1673,7 +1660,7 @@ mod tests {
16731660

16741661
base.extend(extension);
16751662

1676-
assert_eq!(true, base.trigger_every_block);
1663+
assert!(base.trigger_every_block);
16771664
}
16781665

16791666
#[test]
@@ -1693,7 +1680,7 @@ mod tests {
16931680

16941681
base.extend(extension);
16951682

1696-
assert_eq!(true, base.trigger_every_block);
1683+
assert!(base.trigger_every_block);
16971684
assert_eq!(
16981685
HashSet::from_iter(vec![(10, address(2))]),
16991686
base.contract_addresses,
@@ -1717,7 +1704,7 @@ mod tests {
17171704

17181705
base.extend(extension);
17191706

1720-
assert_eq!(true, base.trigger_every_block);
1707+
assert!(base.trigger_every_block);
17211708
assert_eq!(
17221709
HashSet::from_iter(vec![(10, address(2)), (10, address(1))]),
17231710
base.contract_addresses,

chain/ethereum/src/codec.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,21 @@ impl BlockchainBlock for HeaderOnlyBlock {
499499
}
500500
}
501501

502+
fn get_to_address(trace: &TransactionTrace) -> Result<Option<H160>, Error> {
503+
// Try to detect contract creation transactions, which have no 'to' address
504+
let is_contract_creation = trace.to.is_empty()
505+
|| trace
506+
.calls
507+
.first()
508+
.is_some_and(|call| CallType::try_from(call.call_type) == Ok(CallType::Create));
509+
510+
if is_contract_creation {
511+
Ok(None)
512+
} else {
513+
Ok(Some(trace.to.try_decode_proto("transaction to address")?))
514+
}
515+
}
516+
502517
#[cfg(test)]
503518
mod test {
504519
use graph::{blockchain::Block as _, prelude::chrono::Utc};
@@ -529,18 +544,3 @@ mod test {
529544
);
530545
}
531546
}
532-
533-
fn get_to_address(trace: &TransactionTrace) -> Result<Option<H160>, Error> {
534-
// Try to detect contract creation transactions, which have no 'to' address
535-
let is_contract_creation = trace.to.is_empty()
536-
|| trace
537-
.calls
538-
.first()
539-
.is_some_and(|call| CallType::try_from(call.call_type) == Ok(CallType::Create));
540-
541-
if is_contract_creation {
542-
Ok(None)
543-
} else {
544-
Ok(Some(trace.to.try_decode_proto("transaction to address")?))
545-
}
546-
}

chain/ethereum/src/network.rs

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -352,35 +352,35 @@ mod tests {
352352
};
353353

354354
// Test all real combinations of capability comparisons
355-
assert_eq!(false, &full >= &archive);
356-
assert_eq!(false, &full >= &traces);
357-
assert_eq!(false, &full >= &archive_traces);
358-
assert_eq!(true, &full >= &full);
359-
assert_eq!(false, &full >= &full_traces);
360-
361-
assert_eq!(true, &archive >= &archive);
362-
assert_eq!(false, &archive >= &traces);
363-
assert_eq!(false, &archive >= &archive_traces);
364-
assert_eq!(true, &archive >= &full);
365-
assert_eq!(false, &archive >= &full_traces);
366-
367-
assert_eq!(false, &traces >= &archive);
368-
assert_eq!(true, &traces >= &traces);
369-
assert_eq!(false, &traces >= &archive_traces);
370-
assert_eq!(true, &traces >= &full);
371-
assert_eq!(true, &traces >= &full_traces);
372-
373-
assert_eq!(true, &archive_traces >= &archive);
374-
assert_eq!(true, &archive_traces >= &traces);
375-
assert_eq!(true, &archive_traces >= &archive_traces);
376-
assert_eq!(true, &archive_traces >= &full);
377-
assert_eq!(true, &archive_traces >= &full_traces);
378-
379-
assert_eq!(false, &full_traces >= &archive);
380-
assert_eq!(true, &full_traces >= &traces);
381-
assert_eq!(false, &full_traces >= &archive_traces);
382-
assert_eq!(true, &full_traces >= &full);
383-
assert_eq!(true, &full_traces >= &full_traces);
355+
assert!(!(full >= archive));
356+
assert!(!(full >= traces));
357+
assert!(!(full >= archive_traces));
358+
assert!(full >= full);
359+
assert!(!(full >= full_traces));
360+
361+
assert!(archive >= archive);
362+
assert!(!(archive >= traces));
363+
assert!(!(archive >= archive_traces));
364+
assert!(archive >= full);
365+
assert!(!(archive >= full_traces));
366+
367+
assert!(!(traces >= archive));
368+
assert!(traces >= traces);
369+
assert!(!(traces >= archive_traces));
370+
assert!(traces >= full);
371+
assert!(traces >= full_traces);
372+
373+
assert!(archive_traces >= archive);
374+
assert!(archive_traces >= traces);
375+
assert!(archive_traces >= archive_traces);
376+
assert!(archive_traces >= full);
377+
assert!(archive_traces >= full_traces);
378+
379+
assert!(!(full_traces >= archive));
380+
assert!(full_traces >= traces);
381+
assert!(!(full_traces >= archive_traces));
382+
assert!(full_traces >= full);
383+
assert!(full_traces >= full_traces);
384384
}
385385

386386
#[graph::test]
@@ -463,16 +463,15 @@ mod tests {
463463
})
464464
.await
465465
.unwrap();
466-
assert_eq!(adapter.is_call_only(), false);
466+
assert!(!adapter.is_call_only());
467467
}
468468

469469
// Check limits
470470
{
471471
let adapter = adapters.call_or_cheapest(None).unwrap();
472472
assert!(adapter.is_call_only());
473-
assert_eq!(
474-
adapters.call_or_cheapest(None).unwrap().is_call_only(),
475-
false
473+
assert!(
474+
!adapters.call_or_cheapest(None).unwrap().is_call_only()
476475
);
477476
}
478477

@@ -485,7 +484,7 @@ mod tests {
485484
traces: false,
486485
}))
487486
.unwrap();
488-
assert_eq!(adapter.is_call_only(), false);
487+
assert!(!adapter.is_call_only());
489488
}
490489
}
491490

@@ -553,11 +552,11 @@ mod tests {
553552

554553
// verify that after all call_only were exhausted, we can still
555554
// get normal adapters
556-
let keep: Vec<Arc<EthereumAdapter>> = vec![0; 10]
555+
let keep: Vec<Arc<EthereumAdapter>> = [0; 10]
557556
.iter()
558557
.map(|_| adapters.call_or_cheapest(None).unwrap())
559558
.collect();
560-
assert_eq!(keep.iter().any(|a| !a.is_call_only()), false);
559+
assert!(!keep.iter().any(|a| !a.is_call_only()));
561560
}
562561

563562
#[graph::test]
@@ -621,9 +620,8 @@ mod tests {
621620
// one reference above and one inside adapters struct
622621
assert_eq!(Arc::strong_count(&eth_call_adapter), 2);
623622
assert_eq!(Arc::strong_count(&eth_adapter), 2);
624-
assert_eq!(
625-
adapters.call_or_cheapest(None).unwrap().is_call_only(),
626-
false
623+
assert!(
624+
!adapters.call_or_cheapest(None).unwrap().is_call_only()
627625
);
628626
}
629627

@@ -667,9 +665,8 @@ mod tests {
667665
.await;
668666
// one reference above and one inside adapters struct
669667
assert_eq!(Arc::strong_count(&eth_adapter), 2);
670-
assert_eq!(
671-
adapters.call_or_cheapest(None).unwrap().is_call_only(),
672-
false
668+
assert!(
669+
!adapters.call_or_cheapest(None).unwrap().is_call_only()
673670
);
674671
}
675672

@@ -690,25 +687,23 @@ mod tests {
690687
let provider_metrics = Arc::new(ProviderEthRpcMetrics::new(mock_registry.clone()));
691688
let chain_id: Word = "chain_id".into();
692689

693-
let adapters = vec![
694-
fake_adapter(
690+
let adapters = [fake_adapter(
695691
&logger,
696-
&unavailable_provider,
692+
unavailable_provider,
697693
&provider_metrics,
698694
&metrics,
699695
false,
700696
)
701697
.await,
702-
fake_adapter(&logger, &error_provider, &provider_metrics, &metrics, false).await,
698+
fake_adapter(&logger, error_provider, &provider_metrics, &metrics, false).await,
703699
fake_adapter(
704700
&logger,
705-
&no_error_provider,
701+
no_error_provider,
706702
&provider_metrics,
707703
&metrics,
708704
false,
709705
)
710-
.await,
711-
];
706+
.await];
712707

713708
// Set errors
714709
metrics.report_for_test(&ProviderName::from(error_provider), false);
@@ -813,7 +808,7 @@ mod tests {
813808
archive: true,
814809
traces: false,
815810
},
816-
adapter: fake_adapter(&logger, &error_provider, &provider_metrics, &metrics, false)
811+
adapter: fake_adapter(&logger, error_provider, &provider_metrics, &metrics, false)
817812
.await,
818813
limit: SubgraphLimit::Unlimited,
819814
});
@@ -827,7 +822,7 @@ mod tests {
827822
},
828823
adapter: fake_adapter(
829824
&logger,
830-
&no_error_provider,
825+
no_error_provider,
831826
&provider_metrics,
832827
&metrics,
833828
false,
@@ -891,7 +886,7 @@ mod tests {
891886
},
892887
adapter: fake_adapter(
893888
&logger,
894-
&no_error_provider,
889+
no_error_provider,
895890
&provider_metrics,
896891
&metrics,
897892
false,
@@ -903,7 +898,7 @@ mod tests {
903898
logger,
904899
vec![(
905900
chain_id.clone(),
906-
no_available_adapter.iter().cloned().collect(),
901+
no_available_adapter.to_vec(),
907902
)]
908903
.into_iter(),
909904
ProviderCheckStrategy::MarkAsValid,
@@ -927,7 +922,7 @@ mod tests {
927922
call_only: bool,
928923
) -> Arc<EthereumAdapter> {
929924
let transport = Transport::new_rpc(
930-
Url::parse(&"http://127.0.0.1").unwrap(),
925+
Url::parse("http://127.0.0.1").unwrap(),
931926
HeaderMap::new(),
932927
endpoint_metrics.clone(),
933928
"",

0 commit comments

Comments
 (0)