From 8e380debab75a8b1c7152584630d7e8a36738e22 Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Tue, 26 Nov 2024 19:35:15 +0100 Subject: [PATCH] chore(deps): remove dependency on toolshed crate Signed-off-by: Lorenzo Delgado --- Cargo.lock | 23 ----------------------- Cargo.toml | 2 -- src/bytes.rs | 14 ++++++++++++++ src/chain.rs | 2 +- src/main.rs | 1 + src/reports.rs | 3 +-- 6 files changed, 17 insertions(+), 28 deletions(-) create mode 100644 src/bytes.rs diff --git a/Cargo.lock b/Cargo.lock index d9e4e4bb..e5b354e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1807,13 +1807,11 @@ dependencies = [ "serde_with", "snmalloc-rs", "tap_core", - "test-with", "thegraph-core", "thegraph-graphql-http", "thiserror", "tokio", "tokio-test", - "toolshed", "tower", "tower-http", "tower-test", @@ -4057,19 +4055,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "test-with" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3feb483cdf81866d103b411636e52d2e7af915cd9db562a8a6813b89cb55f55e" -dependencies = [ - "proc-macro-error2", - "proc-macro2", - "quote", - "regex", - "syn 2.0.89", -] - [[package]] name = "thegraph-core" version = "0.7.0" @@ -4324,14 +4309,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "toolshed" -version = "0.6.0" -source = "git+https://github.com/edgeandnode/toolshed?tag=toolshed-v0.6.0#c44cb91e8349c59bb7ff8d4eb086badc8c99491a" -dependencies = [ - "tokio", -] - [[package]] name = "tower" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 6455eca2..e38d7a08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,6 @@ tokio = { version = "1.38.0", features = [ "sync", "time", ] } -toolshed = { git = "https://github.com/edgeandnode/toolshed", tag = "toolshed-v0.6.0" } tower = "0.5.1" tower-http = { version = "0.6.1", features = ["cors"] } tracing = { version = "0.1", default-features = false } @@ -81,6 +80,5 @@ url = "2.5.0" assert_matches = "1.5.0" http-body-util = "0.1.1" hyper = "1.3.1" -test-with = { version = "0.14.0", default-features = false } tokio-test = "0.4.4" tower-test = "0.4.0" diff --git a/src/bytes.rs b/src/bytes.rs new file mode 100644 index 00000000..1967944e --- /dev/null +++ b/src/bytes.rs @@ -0,0 +1,14 @@ +// See https://doc.rust-lang.org/std/macro.concat_bytes.html +#[macro_export] +macro_rules! concat_bytes { + ($len:expr, [$($slices:expr),* $(,)?]) => { + { + let mut cursor = std::io::Cursor::new([0_u8; $len]); + $( + std::io::Write::write(&mut cursor, $slices).unwrap(); + )* + assert!(cursor.position() == $len); + cursor.into_inner() + } + } +} diff --git a/src/chain.rs b/src/chain.rs index 451be3b0..88013038 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -113,9 +113,9 @@ mod tests { rngs::SmallRng, seq::SliceRandom as _, thread_rng, Rng as _, RngCore as _, SeedableRng, }; use thegraph_core::{Address, BlockHash, IndexerId}; - use toolshed::concat_bytes; use super::{Block, Chain, MAX_LEN}; + use crate::concat_bytes; #[test] fn chain() { diff --git a/src/main.rs b/src/main.rs index f846a0cf..60f23b4f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod auth; mod block_constraints; mod blocks; mod budgets; +mod bytes; mod chain; mod chains; mod client_query; diff --git a/src/reports.rs b/src/reports.rs index 0715c80d..f98c1c84 100644 --- a/src/reports.rs +++ b/src/reports.rs @@ -3,9 +3,8 @@ use ordered_float::NotNan; use prost::Message; use thegraph_core::{Address, AllocationId, DeploymentId, IndexerId}; use tokio::sync::mpsc; -use toolshed::concat_bytes; -use crate::{errors, indexer_client::IndexerResponse, receipts::Receipt}; +use crate::{concat_bytes, errors, indexer_client::IndexerResponse, receipts::Receipt}; pub struct ClientRequest { pub id: String,