-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Include test of catching incompatible block handler functions
- Loading branch information
Showing
6 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/cli/validation/block-handler-with-incompatible-mapping-function.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- Load subgraph from subgraph.yaml | ||
✖ Failed to load subgraph from subgraph.yaml: Error in subgraph.yaml: | ||
|
||
Path: dataSources > 0 > blockHandlers > 0 | ||
Matching mapping handler not found in './mapping.ts' for blockHandler: 'handleBlock'. | ||
Signature: | ||
handleBlock(block: ethereum.BlockWithTransactions): void |
7 changes: 7 additions & 0 deletions
7
tests/cli/validation/block-handler-with-incompatible-mapping-function/Abi.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
{ | ||
"type": "event", | ||
"name": "ExampleEvent", | ||
"inputs": [{ "type": "string" }] | ||
} | ||
] |
9 changes: 9 additions & 0 deletions
9
tests/cli/validation/block-handler-with-incompatible-mapping-function/mapping.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ethereum } from '@graphprotocol/graph-ts' | ||
import { ExampleBlockEntity } from './generated/schema' | ||
|
||
export function handleBlock(block: ethereum.BlockWithReceipts): void { | ||
let entity = new ExampleBlockEntity(block.hash.toHexString()) | ||
entity.number = block.number | ||
entity.hash = block.hash | ||
entity.save() | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/cli/validation/block-handler-with-incompatible-mapping-function/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type ExampleBlockEntity @entity { | ||
id: ID! | ||
number: BigInt! | ||
hash: Bytes! | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/cli/validation/block-handler-with-incompatible-mapping-function/subgraph.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
specVersion: 0.0.1 | ||
schema: | ||
file: ./schema.graphql | ||
dataSources: | ||
- kind: ethereum/contract | ||
name: ExampleSubgraph | ||
network: mainnet | ||
source: | ||
abi: ExampleContract | ||
mapping: | ||
kind: ethereum/events | ||
apiVersion: 0.0.1 | ||
language: wasm/assemblyscript | ||
file: ./mapping.ts | ||
entities: | ||
- ExampleBlockEntity | ||
abis: | ||
- name: ExampleContract | ||
file: ./Abi.json | ||
blockHandlers: | ||
- handler: handleBlock | ||
blockFormat: block-with-transactions |