Skip to content

Commit eb5e46a

Browse files
committed
Subgraph composition : Add Integration Tests
1 parent a051073 commit eb5e46a

File tree

16 files changed

+337
-2330
lines changed

16 files changed

+337
-2330
lines changed

tests/contracts/out/LimitedContract.sol/LimitedContract.json

Lines changed: 1 addition & 450 deletions
Large diffs are not rendered by default.

tests/contracts/out/OverloadedContract.sol/OverloadedContract.json

Lines changed: 1 addition & 583 deletions
Large diffs are not rendered by default.

tests/contracts/out/RevertingContract.sol/RevertingContract.json

Lines changed: 1 addition & 450 deletions
Large diffs are not rendered by default.

tests/contracts/out/SimpleContract.sol/SimpleContract.json

Lines changed: 1 addition & 845 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[
2+
{
3+
"inputs": [],
4+
"stateMutability": "nonpayable",
5+
"type": "constructor"
6+
},
7+
{
8+
"anonymous": false,
9+
"inputs": [
10+
{
11+
"indexed": false,
12+
"internalType": "uint16",
13+
"name": "x",
14+
"type": "uint16"
15+
}
16+
],
17+
"name": "Trigger",
18+
"type": "event"
19+
},
20+
{
21+
"inputs": [
22+
{
23+
"internalType": "uint16",
24+
"name": "x",
25+
"type": "uint16"
26+
}
27+
],
28+
"name": "emitTrigger",
29+
"outputs": [],
30+
"stateMutability": "nonpayable",
31+
"type": "function"
32+
}
33+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "source-subgraph",
3+
"version": "0.1.0",
4+
"scripts": {
5+
"build-contracts": "../../common/build-contracts.sh",
6+
"codegen": "graph codegen --skip-migrations",
7+
"test": "yarn build-contracts && truffle test --compile-none --network test",
8+
"create:test": "graph create test/source-subgraph --node $GRAPH_NODE_ADMIN_URI",
9+
"deploy:test": "graph deploy test/source-subgraph --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI"
10+
},
11+
"devDependencies": {
12+
"@graphprotocol/graph-cli": "0.69.0",
13+
"@graphprotocol/graph-ts": "0.34.0",
14+
"solc": "^0.8.2"
15+
},
16+
"dependencies": {
17+
"@truffle/contract": "^4.3",
18+
"@truffle/hdwallet-provider": "^1.2",
19+
"apollo-fetch": "^0.7.0",
20+
"babel-polyfill": "^6.26.0",
21+
"babel-register": "^6.26.0",
22+
"gluegun": "^4.6.1",
23+
"truffle": "^5.2"
24+
}
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
type Block @entity {
4+
id: ID!
5+
number: BigInt!
6+
hash: Bytes!
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ethereum, log } from '@graphprotocol/graph-ts';
2+
import { Block } from '../generated/schema';
3+
4+
export function handleBlock(block: ethereum.Block): void {
5+
log.info('handleBlock {}', [block.number.toString()]);
6+
let blockEntity = new Block(block.number.toString());
7+
blockEntity.number = block.number;
8+
blockEntity.hash = block.hash;
9+
blockEntity.save();
10+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
specVersion: 0.0.8
2+
schema:
3+
file: ./schema.graphql
4+
dataSources:
5+
- kind: ethereum/contract
6+
name: BlockHandlerTest
7+
network: test
8+
source:
9+
address: "@SimpleContract@"
10+
abi: Contract
11+
startBlock: 1
12+
mapping:
13+
kind: ethereum/events
14+
apiVersion: 0.0.7
15+
language: wasm/assemblyscript
16+
abis:
17+
- name: Contract
18+
file: ./abis/Contract.abi
19+
entities:
20+
- Call
21+
blockHandlers:
22+
- handler: handleBlock
23+
file: ./src/mapping.ts
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
{
3+
"anonymous": false,
4+
"inputs": [
5+
{
6+
"indexed": false,
7+
"internalType": "string",
8+
"name": "testCommand",
9+
"type": "string"
10+
}
11+
],
12+
"name": "TestEvent",
13+
"type": "event"
14+
}
15+
]

0 commit comments

Comments
 (0)