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

Bump deps and fix clippy issues. #382

Merged
merged 1 commit into from
Feb 14, 2023
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
1,169 changes: 739 additions & 430 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/compiler/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn handle_import(in_file: &Path, import: &Path, imports: &mut HashSet<PathBuf>)
if import.is_dir() {
for entry in import
.read_dir()
.unwrap_or_else(|_| panic!("Could not read dir: {:?}", import))
.unwrap_or_else(|_| panic!("Could not read dir: {import:?}"))
{
handle_import(in_file, &entry.unwrap().path(), imports)
}
Expand Down Expand Up @@ -210,9 +210,9 @@ mod compiler_tests {
assert_eq!(
includes,
HashSet::from([
PathBuf::from(format!("{}/mocks/as/utils.ts", root_path_str)),
PathBuf::from(format!("{}/mocks/generated/schema.ts", root_path_str)),
PathBuf::from(format!("{}/mocks/src/gravity.ts", root_path_str))
PathBuf::from(format!("{root_path_str}/mocks/as/utils.ts")),
PathBuf::from(format!("{root_path_str}/mocks/generated/schema.ts")),
PathBuf::from(format!("{root_path_str}/mocks/src/gravity.ts"))
])
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn generate_coverage_report() {
}

fn is_called(wat_content: &str, handler: &str) -> bool {
let pattern = format!(r#"call.+{}"#, handler);
let pattern = format!(r#"call.+{handler}"#);
let regex = Regex::new(&pattern).expect("Not a valid regex pattern.");

regex.is_match(wat_content)
Expand Down
2 changes: 1 addition & 1 deletion src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<C: Blockchain> MatchstickInstance<C> {
let name_for_metrics = host_fn.name.replace('.', "_");
let stopwatch = &instance.wasm_ctx.host_metrics.stopwatch;
let _section =
stopwatch.start_section(&format!("host_export_{}", name_for_metrics));
stopwatch.start_section(&format!("host_export_{name_for_metrics}"));

let ctx = HostFnCtx {
logger: instance.wasm_ctx.ctx.logger.cheap_clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(test)]
mod integration_tests {
mod tests {
use graph_chain_ethereum::Chain;
use serial_test::serial;
use std::path::PathBuf;
Expand Down
18 changes: 9 additions & 9 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn flush() -> String {
unsafe {
ACCUM = false;
LOGS.iter().for_each(|s| {
writeln!(&mut buf, "{}", s).unwrap_or_else(|err| panic!("{}", Log::Critical(err)))
writeln!(&mut buf, "{s}").unwrap_or_else(|err| panic!("{}", Log::Critical(err)))
});
LOGS.clear();
};
Expand Down Expand Up @@ -72,20 +72,20 @@ impl<T: fmt::Display> Log<T> {
return;
}
}
println!("{}", s);
println!("{s}");
}
}

impl<T: fmt::Display> fmt::Display for Log<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Log::Critical(s) => format!("🆘 {}", s).bold().red(),
Log::Error(s) => format!("𝖷 {}", s).bold().red(),
Log::Warning(s) => format!("⚠️ {}", s).yellow(),
Log::Info(s) => format!("💬 {}", s).italic(),
Log::Debug(s) => format!("🛠 {}", s).italic().cyan(),
Log::Success(s) => format!("√ {}", s).bold().green(),
Log::Default(s) => format!("{}", s).normal(),
Log::Critical(s) => format!("🆘 {s}").bold().red(),
Log::Error(s) => format!("𝖷 {s}").bold().red(),
Log::Warning(s) => format!("⚠️ {s}").yellow(),
Log::Info(s) => format!("💬 {s}").italic(),
Log::Debug(s) => format!("🛠 {s}").italic().cyan(),
Log::Success(s) => format!("√ {s}").bold().green(),
Log::Default(s) => format!("{s}").normal(),
};
unsafe { write!(f, "{}{}", " ".repeat(INDENT), s) }
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ fn run_test_suites(test_suites: HashMap<String, TestGroup>) -> i32 {
.collect();

if *num_failed > 0 {
let failed = format!("{} failed", num_failed).red();
let passed = format!("{} passed", num_passed).green();
let failed = format!("{num_failed} failed").red();
let passed = format!("{num_passed} passed").green();
let total = format!("{} total", *num_failed + *num_passed);

logging::log_with_style!(red, "\nFailed tests:\n");
Expand Down
6 changes: 3 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub fn parse_yaml(path: &str) -> Value {
fn extract_string(value: &Value, key: &str) -> String {
value
.get(key)
.unwrap_or_else(|| panic!("Couldn't find key `{}` in subgraph.yaml", key))
.unwrap_or_else(|| panic!("Couldn't find key `{key}` in subgraph.yaml"))
.as_str()
.unwrap_or_else(|| panic!("Couldn't parse `{}` as str", key))
.unwrap_or_else(|| panic!("Couldn't parse `{key}` as str"))
.to_owned()
}

Expand All @@ -51,7 +51,7 @@ fn extract_vec(value: &Value, key: &str) -> Sequence {
.get(key)
.unwrap_or(&Value::Sequence(vec![]))
.as_sequence()
.unwrap_or_else(|| panic!("Couldn't parse `{}` as Sequence", key))
.unwrap_or_else(|| panic!("Couldn't parse `{key}` as Sequence"))
.to_vec()
}

Expand Down
2 changes: 1 addition & 1 deletion src/test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Test {
let msg = format!(
"{} - {}",
self.name.clone(),
format!("{:.3?}ms", elapsed_in_ms).bright_blue()
format!("{elapsed_in_ms:.3?}ms").bright_blue()
);
if passed {
logging::success!(msg);
Expand Down
18 changes: 7 additions & 11 deletions src/unit_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(test)]
mod unit_tests {
mod tests {
use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;
Expand Down Expand Up @@ -110,7 +110,7 @@ mod unit_tests {

assert_eq!(context.meta_tests.len(), 1);
assert_eq!(context.meta_tests[0].0, "test");
assert_eq!(context.meta_tests[0].1, false);
assert!(!context.meta_tests[0].1);
assert_eq!(context.meta_tests[0].2, 0);
}

Expand Down Expand Up @@ -786,7 +786,7 @@ mod unit_tests {
.expect("Couldn't call ethereum_call.");

let fn_args: Vec<Token> = asc_get::<_, Array<AscPtr<AscEnum<EthereumValueKind>>>, _>(
&mut context.wasm_ctx,
&context.wasm_ctx,
result,
&GasCounter::new(),
)
Expand Down Expand Up @@ -1167,12 +1167,9 @@ mod unit_tests {
.unwrap();

assert_eq!(context.ipfs.len(), 1);
assert_eq!(
context
.ipfs
.contains_key("QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D"),
true
);
assert!(context
.ipfs
.contains_key("QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D"));
assert_eq!(
context
.ipfs
Expand All @@ -1198,8 +1195,7 @@ mod unit_tests {
.unwrap();

let result_ptr = context.mock_ipfs_cat(&GasCounter::new(), hash_ptr).unwrap();
let result: Vec<u8> =
asc_get(&mut context.wasm_ctx, result_ptr, &GasCounter::new()).unwrap();
let result: Vec<u8> = asc_get(&context.wasm_ctx, result_ptr, &GasCounter::new()).unwrap();
let string = std::fs::read_to_string("./mocks/ipfs/cat.json").expect("File not found!");

assert_eq!(result, string.as_bytes());
Expand Down