Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kskalski committed Aug 18, 2023
1 parent a3371c2 commit 5bcd0d6
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions crates/cli/src/parse/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::Arc;

use ethers::prelude::*;
use polars::prelude::*;

Expand Down Expand Up @@ -312,10 +310,10 @@ mod tests {
match test {
BlockTokenTest::WithMock((token, expected, latest)) => {
mock.push(U64::from(latest)).unwrap();
assert_eq!(block_token_test_executor(&token, expected, &provider).await, res);
assert_eq!(block_token_test_executor(token, expected, &provider).await, res);
}
BlockTokenTest::WithoutMock((token, expected)) => {
assert_eq!(block_token_test_executor(&token, expected, &provider).await, res);
assert_eq!(block_token_test_executor(token, expected, &provider).await, res);
}
}
}
Expand All @@ -331,20 +329,20 @@ mod tests {
{
match expected {
BlockChunk::Numbers(expected_block_numbers) => {
let block_chunks = parse_block_token(token, false, &provider).await.unwrap();
let block_chunks = parse_block_token(token, false, provider).await.unwrap();
assert!(matches!(block_chunks, BlockChunk::Numbers { .. }));
let BlockChunk::Numbers(block_numbers) = block_chunks else {
panic!("Unexpected shape")
};
return block_numbers == expected_block_numbers
block_numbers == expected_block_numbers
}
BlockChunk::Range(expected_range_start, expected_range_end) => {
let block_chunks = parse_block_token(token, true, &provider).await.unwrap();
let block_chunks = parse_block_token(token, true, provider).await.unwrap();
assert!(matches!(block_chunks, BlockChunk::Range { .. }));
let BlockChunk::Range(range_start, range_end) = block_chunks else {
panic!("Unexpected shape")
};
return expected_range_start == range_start && expected_range_end == range_end
expected_range_start == range_start && expected_range_end == range_end
}
}
}
Expand All @@ -360,24 +358,24 @@ mod tests {
match test {
BlockInputTest::WithMock((inputs, expected, latest)) => {
mock.push(U64::from(latest)).unwrap();
assert_eq!(block_input_test_executor(&inputs, expected, &provider).await, res);
assert_eq!(block_input_test_executor(inputs, expected, &provider).await, res);
}
BlockInputTest::WithoutMock((inputs, expected)) => {
assert_eq!(block_input_test_executor(&inputs, expected, &provider).await, res);
assert_eq!(block_input_test_executor(inputs, expected, &provider).await, res);
}
}
}
}

async fn block_input_test_executor<P>(
inputs: &String,
inputs: &str,
expected: Vec<BlockChunk>,
provider: &Provider<P>,
) -> bool
where
P: JsonRpcClient,
{
let block_chunks = parse_block_inputs(inputs, &provider).await.unwrap();
let block_chunks = parse_block_inputs(inputs, provider).await.unwrap();
assert_eq!(block_chunks.len(), expected.len());
for (i, block_chunk) in block_chunks.iter().enumerate() {
let expected_chunk = &expected[i];
Expand All @@ -388,7 +386,7 @@ mod tests {
panic!("Unexpected shape")
};
if expected_block_numbers != block_numbers {
return false
return false;
}
}
BlockChunk::Range(expected_range_start, expected_range_end) => {
Expand All @@ -397,12 +395,12 @@ mod tests {
panic!("Unexpected shape")
};
if expected_range_start != range_start || expected_range_end != range_end {
return false
return false;
}
}
}
}
return true
true
}

enum BlockNumberTest<'a> {
Expand All @@ -417,14 +415,14 @@ mod tests {
BlockNumberTest::WithMock((block_ref, range_position, expected, latest)) => {
mock.push(U64::from(latest)).unwrap();
assert_eq!(
block_number_test_executor(&block_ref, range_position, expected, &provider)
block_number_test_executor(block_ref, range_position, expected, &provider)
.await,
res
);
}
BlockNumberTest::WithoutMock((block_ref, range_position, expected)) => {
assert_eq!(
block_number_test_executor(&block_ref, range_position, expected, &provider)
block_number_test_executor(block_ref, range_position, expected, &provider)
.await,
res
);
Expand All @@ -442,8 +440,8 @@ mod tests {
where
P: JsonRpcClient,
{
let block_number = parse_block_number(block_ref, range_position, &provider).await.unwrap();
return block_number == expected
let block_number = parse_block_number(block_ref, range_position, provider).await.unwrap();
block_number == expected
}

#[tokio::test]
Expand Down

0 comments on commit 5bcd0d6

Please sign in to comment.