|
| 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