Skip to content

Commit 8f4563b

Browse files
committed
tests: change entity name for integration test
1 parent ce90cd9 commit 8f4563b

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
type Data @entity {
2-
id: ID!
3-
foo: String
4-
bar: Int
5-
isTest: Boolean
1+
type MirrorBlock @entity {
2+
id: Bytes!
3+
number: BigInt!
4+
hash: Bytes!
65
}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { Entity, log } from '@graphprotocol/graph-ts';
2+
import { MirrorBlock } from '../generated/schema';
23

34
export function handleEntity(blockEntity: Entity): void {
4-
let blockNumberString = blockEntity.getBigInt('number').toString();
5-
log.info('===> Block: {}', [blockNumberString]);
5+
let blockNumber = blockEntity.getBigInt('number');
6+
let blockHash = blockEntity.getBytes('hash');
7+
8+
log.info('Block number: {}', [blockNumber.toString()]);
9+
10+
let block = new MirrorBlock(blockHash);
11+
block.number = blockNumber;
12+
block.hash = blockHash;
13+
block.save();
614
}

tests/tests/integration_tests.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,32 @@ async fn test_eth_api(ctx: TestContext) -> anyhow::Result<()> {
517517
Ok(())
518518
}
519519

520-
async fn subgraph_data_sources(_ctx: TestContext) -> anyhow::Result<()> {
520+
async fn subgraph_data_sources(ctx: TestContext) -> anyhow::Result<()> {
521+
let subgraph = ctx.subgraph;
522+
assert!(subgraph.healthy);
523+
let expected_response = json!({
524+
"mirrorBlocks": [
525+
{ "number": "0" },
526+
{ "number": "1" },
527+
{ "number": "2" },
528+
{ "number": "3" },
529+
{ "number": "4" },
530+
{ "number": "5" },
531+
{ "number": "6" },
532+
{ "number": "7" },
533+
{ "number": "8" },
534+
{ "number": "9" },
535+
]
536+
});
537+
538+
query_succeeds(
539+
"Blocks should be right",
540+
&subgraph,
541+
"{ mirrorBlocks(where: {number_lt: 10}, orderBy: number) { number } }",
542+
expected_response,
543+
)
544+
.await?;
545+
521546
Ok(())
522547
}
523548

0 commit comments

Comments
 (0)