Skip to content

Commit 74753b0

Browse files
committed
test: add integration tests
1 parent 18db52d commit 74753b0

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

tests/integration-tests/subgraph-data-sources/schema.graphql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,17 @@ type MirrorBlock @entity {
44
hash: Bytes!
55
testMessage: String
66
}
7+
8+
type MirrorBlock2 @entity {
9+
id: Bytes!
10+
number: BigInt!
11+
hash: Bytes!
12+
testMessage: String
13+
}
14+
15+
type MirrorBlock3 @entity {
16+
id: Int8!
17+
number: BigInt!
18+
hash: Bytes!
19+
testMessage: String
20+
}

tests/integration-tests/subgraph-data-sources/src/mapping.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, store } from '@graphprotocol/graph-ts';
2-
import { Block, Block2 } from '../generated/subgraph-QmWi3H11QFE2PiWx6WcQkZYZdA5UasaBptUJqGn54MFux5';
3-
import { MirrorBlock } from '../generated/schema';
2+
import { Block, Block2, Block3, Block4 } from '../generated/subgraph-QmbsbSz4kZojY99eJdSt7djfeBnxkAj4aePVPo38TEwm35';
3+
import { MirrorBlock, MirrorBlock2, MirrorBlock3 } from '../generated/schema';
44

55
export function handleEntity(block: Block): void {
66
let id = block.id;
@@ -23,6 +23,28 @@ export function handleEntity2(block: Block2): void {
2323
blockEntity.save();
2424
}
2525

26+
export function handleEntity3(block: Block3): void {
27+
let id = block.id;
28+
29+
let blockEntity = new MirrorBlock2(id);
30+
blockEntity.number = block.number;
31+
blockEntity.hash = block.hash;
32+
blockEntity.testMessage = block.testMessage;
33+
34+
blockEntity.save();
35+
}
36+
37+
export function handleEntity4(block: Block4): void {
38+
let id = block.id;
39+
40+
let blockEntity = new MirrorBlock3(id);
41+
blockEntity.number = block.number;
42+
blockEntity.hash = block.hash;
43+
blockEntity.testMessage = block.testMessage;
44+
45+
blockEntity.save();
46+
}
47+
2648
export function loadOrCreateMirrorBlock(id: string): MirrorBlock {
2749
let block = MirrorBlock.load(id);
2850
if (!block) {

tests/integration-tests/subgraph-data-sources/subgraph.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dataSources:
66
name: Contract
77
network: test
88
source:
9-
address: 'QmWi3H11QFE2PiWx6WcQkZYZdA5UasaBptUJqGn54MFux5'
9+
address: 'QmbsbSz4kZojY99eJdSt7djfeBnxkAj4aePVPo38TEwm35'
1010
startBlock: 0
1111
mapping:
1212
apiVersion: 0.0.7
@@ -18,4 +18,8 @@ dataSources:
1818
entity: Block
1919
- handler: handleEntity2
2020
entity: Block2
21+
- handler: handleEntity3
22+
entity: Block3
23+
- handler: handleEntity4
24+
entity: Block4
2125
file: ./src/mapping.ts

0 commit comments

Comments
 (0)