Skip to content

Commit d5cfbdf

Browse files
committed
tests: fix subgraph datasource test failing
1 parent 169ed5b commit d5cfbdf

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

tests/integration-tests/subgraph-data-sources/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"deploy:test": "graph deploy test/subgraph-data-sources --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI"
88
},
99
"devDependencies": {
10-
"@graphprotocol/graph-cli": "0.91.0-alpha-20241129215038-b75cda9",
10+
"@graphprotocol/graph-cli": "0.93.4-alpha-20250105163501-f401d0c57c4ba1f1af95a928d447efd63a56ecdc",
1111
"@graphprotocol/graph-ts": "0.36.0-alpha-20241129215038-b75cda9"
1212
}
1313
}
Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
1-
import { Entity, log, store } from '@graphprotocol/graph-ts';
1+
import { Entity, log, store, BigInt, EntityTrigger, EntityOp } from '@graphprotocol/graph-ts';
2+
import { Block } from '../generated/subgraph-Qmaqf8cRxfxbduZppSHKG9DMuX5JZPMoGuwGb2DQuo48sq';
23
import { MirrorBlock } from '../generated/schema';
34

4-
export class EntityTrigger {
5-
constructor(
6-
public entityOp: u32,
7-
public entityType: string,
8-
public entity: Entity,
9-
public vid: i64,
10-
) {}
11-
}
12-
13-
export function handleEntity(trigger: EntityTrigger): void {
14-
let blockEntity = trigger.entity;
15-
let blockNumber = blockEntity.getBigInt('number');
16-
let blockHash = blockEntity.getBytes('hash');
17-
let testMessage = blockEntity.get('testMessage');
18-
let id = blockEntity.getString('id');
5+
export function handleEntity(trigger: EntityTrigger<Block>): void {
6+
let blockEntity = trigger.data;
7+
let id = blockEntity.id;
198

20-
log.info('Block number: {}', [blockNumber.toString()]);
21-
22-
if (trigger.entityOp == 2) {
9+
if (trigger.operation === EntityOp.Remove) {
2310
log.info('Removing block entity with id: {}', [id]);
2411
store.remove('MirrorBlock', id);
2512
return;
2613
}
2714

2815
let block = loadOrCreateMirrorBlock(id);
29-
block.number = blockNumber;
30-
block.hash = blockHash;
31-
if (testMessage) {
32-
block.testMessage = testMessage.toString();
16+
block.number = blockEntity.number;
17+
block.hash = blockEntity.hash;
18+
19+
if (blockEntity.testMessage) {
20+
block.testMessage = blockEntity.testMessage;
3321
}
3422

3523
block.save();
@@ -41,6 +29,5 @@ export function loadOrCreateMirrorBlock(id: string): MirrorBlock {
4129
log.info('Creating new block entity with id: {}', [id]);
4230
block = new MirrorBlock(id);
4331
}
44-
4532
return block;
4633
}

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

Lines changed: 1 addition & 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: 'Qmaqf8cRxfxbduZppSHKG9DMuX5JZPMoGuwGb2DQuo48sq'
9+
address: 'QmQCiSBooPHZTrqxJknG9W1YJ8EZXj8c8baFs24eY9pXM8'
1010
startBlock: 0
1111
mapping:
1212
apiVersion: 0.0.7

0 commit comments

Comments
 (0)