Skip to content

Commit

Permalink
chain, server: Allow feature detection for specVersion < 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Aug 19, 2021
1 parent 8d199b4 commit 9512e52
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
31 changes: 31 additions & 0 deletions chain/ethereum/tests/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,34 @@ dataSources:
.is_none());
});
}

#[test]
fn can_detect_features_in_subgraphs_with_spec_version_lesser_than_0_0_4() {
const YAML: &str = "
specVersion: 0.0.2
features:
- nonFatalErrors
dataSources: []
schema:
file:
/: /ipfs/Qmschema
";
test_store::run_test_sequentially(|store| async move {
let store = store.subgraph_store();
let unvalidated = resolve_unvalidated(YAML).await;
assert!(unvalidated
.validate(store.clone())
.expect_err("Validation must fail")
.into_iter()
.find(|e| {
matches!(
e,
SubgraphManifestValidationError::FeatureValidationError(_)
)
})
.is_none());

let manifest = resolve_manifest(YAML).await;
assert!(manifest.features.contains(&SubgraphFeature::NonFatalErrors))
});
}
7 changes: 1 addition & 6 deletions server/index-node/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use either::Either;
use std::collections::{BTreeMap, HashMap};

use graph::data::subgraph::features::detect_features;
use graph::data::subgraph::{status, SPEC_VERSION_0_0_4};
use graph::data::subgraph::status;
use graph::prelude::*;
use graph::{
components::store::StatusStore,
Expand Down Expand Up @@ -199,11 +199,6 @@ where
.map_err(|_error| QueryExecutionError::SubgraphManifestResolveError)?
};

// Feature management is not available for subgraphs with specVersion below 0.0.4
if *unvalidated_subgraph_manifest.spec_version() < SPEC_VERSION_0_0_4 {
return Err(QueryExecutionError::InvalidSubgraphManifest);
}

// Then validate the subgraph we've just obtained.
//
// Note that feature valiadation errors will be inside the error variant vector (because
Expand Down

0 comments on commit 9512e52

Please sign in to comment.