Skip to content

Commit 3512c67

Browse files
committed
all: Use #[graph::test] instead of #[tokio::test]
That ensures that all tests use the same runtime, and we therefore don't have issues with closed connections because a second runtime was dropped.
1 parent 0eaf3ee commit 3512c67

File tree

43 files changed

+298
-310
lines changed

Some content is hidden

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

43 files changed

+298
-310
lines changed

chain/ethereum/src/chain.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,6 @@ impl FirehoseMapperTrait<Chain> for FirehoseMapper {
12681268

12691269
#[cfg(test)]
12701270
mod tests {
1271-
use tokio;
1272-
12731271
use graph::blockchain::mock::MockChainStore;
12741272
use graph::slog;
12751273

@@ -1288,7 +1286,7 @@ mod tests {
12881286
}
12891287
}
12901288

1291-
#[tokio::test]
1289+
#[graph::test]
12921290
async fn test_fetch_unique_blocks_single_block() {
12931291
let logger = Logger::root(slog::Discard, o!());
12941292
let mut chain_store = MockChainStore::default();
@@ -1307,7 +1305,7 @@ mod tests {
13071305
assert!(missing.is_empty());
13081306
}
13091307

1310-
#[tokio::test]
1308+
#[graph::test]
13111309
async fn test_fetch_unique_blocks_duplicate_blocks() {
13121310
let logger = Logger::root(slog::Discard, o!());
13131311
let mut chain_store = MockChainStore::default();
@@ -1330,7 +1328,7 @@ mod tests {
13301328
assert_eq!(missing[0], 1);
13311329
}
13321330

1333-
#[tokio::test]
1331+
#[graph::test]
13341332
async fn test_fetch_unique_blocks_missing_blocks() {
13351333
let logger = Logger::root(slog::Discard, o!());
13361334
let mut chain_store = MockChainStore::default();
@@ -1349,7 +1347,7 @@ mod tests {
13491347
assert_eq!(missing, vec![2]);
13501348
}
13511349

1352-
#[tokio::test]
1350+
#[graph::test]
13531351
async fn test_fetch_unique_blocks_multiple_valid_blocks() {
13541352
let logger = Logger::root(slog::Discard, o!());
13551353
let mut chain_store = MockChainStore::default();
@@ -1371,7 +1369,7 @@ mod tests {
13711369
assert!(missing.is_empty());
13721370
}
13731371

1374-
#[tokio::test]
1372+
#[graph::test]
13751373
async fn test_fetch_unique_blocks_mixed_scenario() {
13761374
let logger = Logger::root(slog::Discard, o!());
13771375
let mut chain_store = MockChainStore::default();

chain/ethereum/src/ethereum_adapter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,6 @@ mod tests {
26582658
};
26592659
use graph::blockchain::BlockPtr;
26602660
use graph::prelude::ethabi::ethereum_types::U64;
2661-
use graph::prelude::tokio::{self};
26622661
use graph::prelude::web3::transports::test::TestTransport;
26632662
use graph::prelude::web3::types::{Address, Block, Bytes, H256};
26642663
use graph::prelude::web3::Web3;
@@ -2706,7 +2705,7 @@ mod tests {
27062705
);
27072706
}
27082707

2709-
#[tokio::test]
2708+
#[graph::test]
27102709
async fn test_check_block_receipts_support() {
27112710
let mut transport = TestTransport::default();
27122711

chain/ethereum/src/network.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ impl EthereumNetworkAdapters {
309309

310310
#[cfg(test)]
311311
mod tests {
312-
use tokio;
313-
314312
use graph::cheap_clone::CheapClone;
315313
use graph::components::network_provider::ProviderCheckStrategy;
316314
use graph::components::network_provider::ProviderManager;
@@ -385,7 +383,7 @@ mod tests {
385383
assert_eq!(true, &full_traces >= &full_traces);
386384
}
387385

388-
#[tokio::test]
386+
#[graph::test]
389387
async fn adapter_selector_selects_eth_call() {
390388
let metrics = Arc::new(EndpointMetrics::mock());
391389
let logger = graph::log::logger(true);
@@ -491,7 +489,7 @@ mod tests {
491489
}
492490
}
493491

494-
#[tokio::test]
492+
#[graph::test]
495493
async fn adapter_selector_unlimited() {
496494
let metrics = Arc::new(EndpointMetrics::mock());
497495
let logger = graph::log::logger(true);
@@ -562,7 +560,7 @@ mod tests {
562560
assert_eq!(keep.iter().any(|a| !a.is_call_only()), false);
563561
}
564562

565-
#[tokio::test]
563+
#[graph::test]
566564
async fn adapter_selector_disable_call_only_fallback() {
567565
let metrics = Arc::new(EndpointMetrics::mock());
568566
let logger = graph::log::logger(true);
@@ -629,7 +627,7 @@ mod tests {
629627
);
630628
}
631629

632-
#[tokio::test]
630+
#[graph::test]
633631
async fn adapter_selector_no_call_only_fallback() {
634632
let metrics = Arc::new(EndpointMetrics::mock());
635633
let logger = graph::log::logger(true);
@@ -675,7 +673,7 @@ mod tests {
675673
);
676674
}
677675

678-
#[tokio::test]
676+
#[graph::test]
679677
async fn eth_adapter_selection_multiple_adapters() {
680678
let logger = Logger::root(Discard, o!());
681679
let unavailable_provider = "unavailable-provider";
@@ -788,7 +786,7 @@ mod tests {
788786
);
789787
}
790788

791-
#[tokio::test]
789+
#[graph::test]
792790
async fn eth_adapter_selection_single_adapter() {
793791
let logger = Logger::root(Discard, o!());
794792
let unavailable_provider = "unavailable-provider";

chain/near/src/chain.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ mod test {
593593
use graph::{
594594
blockchain::{block_stream::BlockWithTriggers, DataSource as _, TriggersAdapter as _},
595595
data::subgraph::LATEST_VERSION,
596-
prelude::{tokio, Link},
596+
prelude::Link,
597597
semver::Version,
598598
slog::{self, o, Logger},
599599
};
@@ -917,7 +917,7 @@ mod test {
917917
}
918918
}
919919

920-
#[tokio::test]
920+
#[graph::test]
921921
async fn test_trigger_filter_empty() {
922922
let account1: String = "account1".into();
923923

@@ -935,7 +935,7 @@ mod test {
935935
assert_eq!(block_with_triggers.trigger_count(), 0);
936936
}
937937

938-
#[tokio::test]
938+
#[graph::test]
939939
async fn test_trigger_filter_every_block() {
940940
let account1: String = "account1".into();
941941

@@ -961,7 +961,7 @@ mod test {
961961
assert_eq!(height, vec![1]);
962962
}
963963

964-
#[tokio::test]
964+
#[graph::test]
965965
async fn test_trigger_filter_every_receipt() {
966966
let account1: String = "account1".into();
967967

chain/near/src/trigger.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ pub struct ReceiptWithOutcome {
154154
mod tests {
155155
use std::convert::TryFrom;
156156

157-
use tokio;
158-
159157
use super::*;
160158

161159
use graph::{
@@ -167,7 +165,7 @@ mod tests {
167165
util::mem::init_slice,
168166
};
169167

170-
#[tokio::test]
168+
#[graph::test]
171169
async fn block_trigger_to_asc_ptr() {
172170
let mut heap = BytesHeap::new(API_VERSION_0_0_5);
173171
let trigger = NearTrigger::Block(Arc::new(block()));
@@ -178,7 +176,7 @@ mod tests {
178176
assert!(result.is_ok());
179177
}
180178

181-
#[tokio::test]
179+
#[graph::test]
182180
async fn receipt_trigger_to_asc_ptr() {
183181
let mut heap = BytesHeap::new(API_VERSION_0_0_5);
184182
let trigger = NearTrigger::Receipt(Arc::new(ReceiptWithOutcome {

chain/substreams/src/data_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ mod test {
443443
assert_eq!(ds, expected);
444444
}
445445

446-
#[tokio::test]
446+
#[graph::test]
447447
async fn data_source_conversion() {
448448
let ds: UnresolvedDataSource = serde_yaml::from_str(TEMPLATE_DATA_SOURCE).unwrap();
449449
let link_resolver: Arc<dyn LinkResolver> = Arc::new(NoopLinkResolver {});
@@ -477,7 +477,7 @@ mod test {
477477
assert_eq!(ds, expected);
478478
}
479479

480-
#[tokio::test]
480+
#[graph::test]
481481
async fn data_source_conversion_override_params() {
482482
let mut package = gen_package();
483483
let mut modules = package.modules.unwrap();

core/src/polling_monitor/ipfs_service.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ mod test {
109109
use graph::ipfs::test_utils::add_files_to_local_ipfs_node_for_testing;
110110
use graph::ipfs::{IpfsContext, IpfsMetrics, IpfsRpcClient, ServerAddress};
111111
use graph::log::discard;
112-
use tokio;
113112
use tower::ServiceExt;
114113
use wiremock::matchers as m;
115114
use wiremock::Mock;
@@ -118,7 +117,7 @@ mod test {
118117

119118
use super::*;
120119

121-
#[tokio::test]
120+
#[graph::test]
122121
async fn cat_file_in_folder() {
123122
let random_bytes = "One morning, when Gregor Samsa woke \
124123
from troubled dreams, he found himself transformed in his bed \
@@ -155,7 +154,7 @@ mod test {
155154
assert_eq!(content.to_vec(), random_bytes);
156155
}
157156

158-
#[tokio::test]
157+
#[graph::test]
159158
async fn arweave_get() {
160159
const ID: &str = "8APeQ5lW0-csTcBaGdPBDLAL2ci2AT9pTn2tppGPU_8";
161160

@@ -169,7 +168,7 @@ mod test {
169168
assert_eq!(expected, body);
170169
}
171170

172-
#[tokio::test]
171+
#[graph::test]
173172
async fn no_client_retries_to_allow_polling_monitor_to_handle_retries_internally() {
174173
const CID: &str = "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn";
175174

core/src/polling_monitor/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ mod tests {
281281
(handle, monitor, rx)
282282
}
283283

284-
#[tokio::test]
284+
#[graph::test]
285285
async fn polling_monitor_shared_svc() {
286286
let (svc, mut handle) = mock::pair();
287287
let shared_svc = tower::buffer::Buffer::new(tower::limit::ConcurrencyLimit::new(svc, 1), 1);
@@ -303,7 +303,7 @@ mod tests {
303303
assert_eq!(rx1.recv().await, Some(("req-0", "res-0")));
304304
}
305305

306-
#[tokio::test]
306+
#[graph::test]
307307
async fn polling_monitor_simple() {
308308
let (mut handle, monitor, mut rx) = setup();
309309

@@ -313,7 +313,7 @@ mod tests {
313313
assert_eq!(rx.recv().await, Some(("req-0", "res-0")));
314314
}
315315

316-
#[tokio::test]
316+
#[graph::test]
317317
async fn polling_monitor_unordered() {
318318
let (mut handle, monitor, mut rx) = setup();
319319

@@ -330,7 +330,7 @@ mod tests {
330330
assert_eq!(rx.recv().await, Some(("req-1", "res-1")));
331331
}
332332

333-
#[tokio::test]
333+
#[graph::test]
334334
async fn polling_monitor_failed_push_to_back() {
335335
let (mut handle, monitor, mut rx) = setup();
336336

@@ -354,7 +354,7 @@ mod tests {
354354
assert_eq!(rx.recv().await, Some(("req-1", "res-1")));
355355
}
356356

357-
#[tokio::test]
357+
#[graph::test]
358358
async fn polling_monitor_cancelation() {
359359
// Cancelation on receiver drop, no pending request.
360360
let (mut handle, _monitor, rx) = setup();

graph/src/blockchain/block_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ mod test {
986986
}
987987
}
988988

989-
#[tokio::test]
989+
#[crate::test]
990990
async fn consume_stream() {
991991
let initial_block = 100;
992992
let buffer_size = 5;

graph/src/components/link_resolver/arweave.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ mod test {
128128
// This test ensures that passing txid/filename works when the txid refers to manifest.
129129
// the actual data seems to have some binary header and footer so these ranges were found
130130
// by inspecting the data with hexdump.
131-
#[tokio::test]
131+
#[crate::test]
132132
async fn fetch_bundler_url() {
133133
let url = Base64::from("Rtdn3QWEzM88MPC2dpWyV5waO7Vuz3VwPl_usS2WoHM/DriveManifest.json");
134134
#[derive(Deserialize, Debug, PartialEq)]

0 commit comments

Comments
 (0)