Skip to content

Commit

Permalink
tests: change entity name for integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 authored and zorancv committed Aug 15, 2024
1 parent 6d0bfb4 commit 7aacb63
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
9 changes: 4 additions & 5 deletions tests/integration-tests/subgraph-data-sources/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
type Data @entity {
id: ID!
foo: String
bar: Int
isTest: Boolean
type MirrorBlock @entity {
id: Bytes!
number: BigInt!
hash: Bytes!
}
12 changes: 10 additions & 2 deletions tests/integration-tests/subgraph-data-sources/src/mapping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Entity, log } from '@graphprotocol/graph-ts';
import { MirrorBlock } from '../generated/schema';

export function handleEntity(blockEntity: Entity): void {
let blockNumberString = blockEntity.getBigInt('number').toString();
log.info('===> Block: {}', [blockNumberString]);
let blockNumber = blockEntity.getBigInt('number');
let blockHash = blockEntity.getBytes('hash');

log.info('Block number: {}', [blockNumber.toString()]);

let block = new MirrorBlock(blockHash);
block.number = blockNumber;
block.hash = blockHash;
block.save();
}
27 changes: 26 additions & 1 deletion tests/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,32 @@ async fn test_eth_api(ctx: TestContext) -> anyhow::Result<()> {
Ok(())
}

async fn subgraph_data_sources(_ctx: TestContext) -> anyhow::Result<()> {
async fn subgraph_data_sources(ctx: TestContext) -> anyhow::Result<()> {
let subgraph = ctx.subgraph;
assert!(subgraph.healthy);
let expected_response = json!({
"mirrorBlocks": [
{ "number": "0" },
{ "number": "1" },
{ "number": "2" },
{ "number": "3" },
{ "number": "4" },
{ "number": "5" },
{ "number": "6" },
{ "number": "7" },
{ "number": "8" },
{ "number": "9" },
]
});

query_succeeds(
"Blocks should be right",
&subgraph,
"{ mirrorBlocks(where: {number_lt: 10}, orderBy: number) { number } }",
expected_response,
)
.await?;

Ok(())
}

Expand Down

0 comments on commit 7aacb63

Please sign in to comment.