Skip to content

Commit cd2d014

Browse files
committed
tests: Add a test for file_link_resolver
1 parent e67930a commit cd2d014

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

.github/workflows/ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ jobs:
107107
command: test
108108
args: --package graph-tests --test runner_tests
109109

110+
- name: Run file link resolver test
111+
id: file-link-resolver-test
112+
uses: actions-rs/cargo@v1
113+
with:
114+
command: test
115+
args: --package graph-tests --test file_link_resolver
116+
110117
integration-tests:
111118
name: Run integration tests
112119
runs-on: ubuntu-latest

tests/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod fixture;
44
pub mod helpers;
55
#[macro_use]
66
pub mod macros;
7-
pub mod subgraph;
87
pub mod recipe;
8+
pub mod subgraph;
99

1010
pub use config::{Config, DbConfig, EthConfig, CONFIG};

tests/tests/file_link_resolver.rs

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use graph::object;
2+
use graph_tests::{
3+
fixture::{
4+
self,
5+
ethereum::{chain, empty_block, genesis},
6+
test_ptr,
7+
},
8+
recipe::RunnerTestRecipe,
9+
};
10+
11+
#[tokio::test]
12+
async fn file_link_resolver() -> anyhow::Result<()> {
13+
std::env::set_var("GRAPH_NODE_DISABLE_DEPLOYMENT_HASH_VALIDATION", "true");
14+
let RunnerTestRecipe { stores, test_info } = RunnerTestRecipe::new_with_file_link_resolver(
15+
"file_link_resolver",
16+
"file-link-resolver",
17+
"subgraph.yaml",
18+
)
19+
.await;
20+
21+
let blocks = {
22+
let block_0 = genesis();
23+
let block_1 = empty_block(block_0.ptr(), test_ptr(1));
24+
let block_2 = empty_block(block_1.ptr(), test_ptr(2));
25+
let block_3 = empty_block(block_2.ptr(), test_ptr(3));
26+
27+
vec![block_0, block_1, block_2, block_3]
28+
};
29+
30+
let chain = chain(&test_info.test_name, blocks, &stores, None).await;
31+
32+
let ctx = fixture::setup_with_file_link_resolver(&test_info, &stores, &chain, None, None).await;
33+
ctx.start_and_sync_to(test_ptr(3)).await;
34+
let query = r#"{ blocks(first: 4, orderBy: number) { id, hash } }"#;
35+
let query_res = ctx.query(query).await.unwrap();
36+
37+
assert_eq!(
38+
query_res,
39+
Some(object! {
40+
blocks: vec![
41+
object! {
42+
id: test_ptr(0).number.to_string(),
43+
hash: format!("0x{}", test_ptr(0).hash_hex()),
44+
},
45+
object! {
46+
id: test_ptr(1).number.to_string(),
47+
hash: format!("0x{}", test_ptr(1).hash_hex()),
48+
},
49+
object! {
50+
id: test_ptr(2).number.to_string(),
51+
hash: format!("0x{}", test_ptr(2).hash_hex()),
52+
},
53+
object! {
54+
id: test_ptr(3).number.to_string(),
55+
hash: format!("0x{}", test_ptr(3).hash_hex()),
56+
},
57+
]
58+
})
59+
);
60+
61+
Ok(())
62+
}

0 commit comments

Comments
 (0)