Skip to content

Commit

Permalink
Fix nightly clippy errors (#984)
Browse files Browse the repository at this point in the history
* Remove unused private db field

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Mock chain_id field is not used

Signed-off-by: Thane Thomson <connect@thanethomson.com>
  • Loading branch information
thanethomson committed Sep 20, 2021
1 parent e21d39d commit dd37137
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 18 deletions.
2 changes: 0 additions & 2 deletions light-client/src/store/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub struct SledStore {
verified_db: HeightIndexedDb<LightBlock>,
trusted_db: HeightIndexedDb<LightBlock>,
failed_db: HeightIndexedDb<LightBlock>,
db: sled::Db,
}

impl SledStore {
Expand All @@ -39,7 +38,6 @@ impl SledStore {
verified_db: HeightIndexedDb::new(db.open_tree(VERIFIED).unwrap()),
trusted_db: HeightIndexedDb::new(db.open_tree(TRUSTED).unwrap()),
failed_db: HeightIndexedDb::new(db.open_tree(FAILED).unwrap()),
db,
}
}

Expand Down
10 changes: 2 additions & 8 deletions light-client/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,7 @@ mod tests {
let mut peer_list = PeerList::builder();

if let Some(primary) = primary {
let io = MockIo::new(
primary[0].signed_header.header.chain_id.to_string(),
primary.clone(),
);
let io = MockIo::new(primary.clone());

let primary_instance =
make_instance(primary[0].provider, trust_options.clone(), io, now);
Expand All @@ -535,10 +532,7 @@ mod tests {
if let Some(witnesses) = witnesses {
for provider in witnesses.into_iter() {
let peer_id = provider[0].provider;
let io = MockIo::new(
provider[0].signed_header.header.chain_id.to_string(),
provider,
);
let io = MockIo::new(provider);
let instance = make_instance(peer_id, trust_options.clone(), io.clone(), now);
peer_list.witness(peer_id, instance);
}
Expand Down
4 changes: 1 addition & 3 deletions light-client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ impl Clock for MockClock {

#[derive(Clone)]
pub struct MockIo {
chain_id: String,
light_blocks: HashMap<Height, LightBlock>,
latest_height: Height,
}

impl MockIo {
pub fn new(chain_id: String, light_blocks: Vec<LightBlock>) -> Self {
pub fn new(light_blocks: Vec<LightBlock>) -> Self {
let latest_height = light_blocks.iter().map(|lb| lb.height()).max().unwrap();

let light_blocks = light_blocks
Expand All @@ -99,7 +98,6 @@ impl MockIo {
.collect();

Self {
chain_id,
light_blocks,
latest_height,
}
Expand Down
3 changes: 1 addition & 2 deletions light-client/tests/backward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ struct TestCase {

fn make(chain: LightChain, trusted_height: Height) -> (LightClient, State) {
let primary = default_peer_id();
let chain_id = "testchain-1".parse().unwrap();

let clock = MockClock {
/// Set the current time to be ahead of the latest block in the chain
Expand All @@ -65,7 +64,7 @@ fn make(chain: LightChain, trusted_height: Height) -> (LightClient, State) {
.map(testgen_to_lb)
.collect();

let io = MockIo::new(chain_id, light_blocks);
let io = MockIo::new(light_blocks);

let trusted_state = io
.fetch_light_block(AtHeight::At(trusted_height))
Expand Down
2 changes: 1 addition & 1 deletion light-client/tests/light_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn run_test(tc: LightClientTest<LightBlock>) -> BisectionTestResult {
};

let provider = tc.primary;
let io = MockIo::new(provider.chain_id, provider.lite_blocks);
let io = MockIo::new(provider.lite_blocks);

let trusted_height = tc.trust_options.height;
let trusted_state = io
Expand Down
4 changes: 2 additions & 2 deletions light-client/tests/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn run_multipeer_test(tc: LightClientTest<LightBlock>) {
None => false,
};

let io = MockIo::new(tc.primary.chain_id, tc.primary.lite_blocks);
let io = MockIo::new(tc.primary.lite_blocks);
let primary_instance = make_instance(primary, tc.trust_options.clone(), io.clone(), tc.now);

let mut peer_list = PeerList::builder();
Expand All @@ -78,7 +78,7 @@ fn run_multipeer_test(tc: LightClientTest<LightBlock>) {
for provider in tc.witnesses.into_iter() {
let peer_id = provider.value.lite_blocks[0].provider;
println!("Witness: {}", peer_id);
let io = MockIo::new(provider.value.chain_id, provider.value.lite_blocks);
let io = MockIo::new(provider.value.lite_blocks);
let instance = make_instance(peer_id, tc.trust_options.clone(), io.clone(), tc.now);
peer_list.witness(peer_id, instance);
}
Expand Down

0 comments on commit dd37137

Please sign in to comment.