Skip to content

Commit 029b367

Browse files
authored
Attempted fix for fn fatal_error test spurious failure (graphprotocol#5113)
* refactor(tests): Refactor `TestInfo` out of `RunnerTestRecipe` * fix(tests): merge `poi_for_deterministically_failed_sg` into `fatal_error` They are both using the same subgraph, which I think is causing race conditions and flaky failures in CI, and they have some duplicated code. * fix(tests): fix `data_source_revert`
1 parent b95dd20 commit 029b367

File tree

2 files changed

+143
-366
lines changed

2 files changed

+143
-366
lines changed

tests/src/fixture/mod.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,15 @@ pub async fn stores(test_name: &str, store_config_path: &str) -> Stores {
419419
}
420420
}
421421

422+
pub struct TestInfo {
423+
pub test_dir: String,
424+
pub test_name: String,
425+
pub subgraph_name: SubgraphName,
426+
pub hash: DeploymentHash,
427+
}
428+
422429
pub async fn setup<C: Blockchain>(
423-
test_name: &str,
424-
subgraph_name: SubgraphName,
425-
hash: &DeploymentHash,
430+
test_info: &TestInfo,
426431
stores: &Stores,
427432
chain: &impl TestChainTrait<C>,
428433
graft_block: Option<BlockPtr>,
@@ -433,14 +438,14 @@ pub async fn setup<C: Blockchain>(
433438
None => EnvVars::from_env().unwrap(),
434439
});
435440

436-
let logger = test_logger(test_name);
441+
let logger = test_logger(&test_info.test_name);
437442
let mock_registry: Arc<MetricsRegistry> = Arc::new(MetricsRegistry::mock());
438443
let logger_factory = LoggerFactory::new(logger.clone(), None, mock_registry.clone());
439444
let node_id = NodeId::new(NODE_ID).unwrap();
440445

441446
// Make sure we're starting from a clean state.
442447
let subgraph_store = stores.network_store.subgraph_store();
443-
cleanup(&subgraph_store, &subgraph_name, hash).unwrap();
448+
cleanup(&subgraph_store, &test_info.subgraph_name, &test_info.hash).unwrap();
444449

445450
let mut blockchain_map = BlockchainMap::new();
446451
blockchain_map.insert(stores.network_name.clone(), chain.chain());
@@ -526,14 +531,17 @@ pub async fn setup<C: Blockchain>(
526531
Arc::new(Settings::default()),
527532
));
528533

529-
SubgraphRegistrar::create_subgraph(subgraph_registrar.as_ref(), subgraph_name.clone())
530-
.await
531-
.expect("unable to create subgraph");
534+
SubgraphRegistrar::create_subgraph(
535+
subgraph_registrar.as_ref(),
536+
test_info.subgraph_name.clone(),
537+
)
538+
.await
539+
.expect("unable to create subgraph");
532540

533541
let deployment = SubgraphRegistrar::create_subgraph_version(
534542
subgraph_registrar.as_ref(),
535-
subgraph_name.clone(),
536-
hash.clone(),
543+
test_info.subgraph_name.clone(),
544+
test_info.hash.clone(),
537545
node_id.clone(),
538546
None,
539547
None,
@@ -550,7 +558,7 @@ pub async fn setup<C: Blockchain>(
550558
provider: subgraph_provider,
551559
store: subgraph_store,
552560
deployment,
553-
subgraph_name,
561+
subgraph_name: test_info.subgraph_name.clone(),
554562
graphql_runner,
555563
instance_manager: subgraph_instance_manager,
556564
link_resolver,

0 commit comments

Comments
 (0)