diff --git a/tests/cli/validation.test.js b/tests/cli/validation.test.js index f1947cd92..02c5d9e95 100644 --- a/tests/cli/validation.test.js +++ b/tests/cli/validation.test.js @@ -197,4 +197,13 @@ describe('Validation', () => { exitCode: 1, }, ) + + cliTest( + 'Block handler with incompatible mapping function', + ['codegen', '--skip-migrations'], + 'validation/block-handler-with-incompatible-mapping-function', + { + exitCode: 1, + }, + ) }) diff --git a/tests/cli/validation/block-handler-with-incompatible-mapping-function.stderr b/tests/cli/validation/block-handler-with-incompatible-mapping-function.stderr new file mode 100644 index 000000000..34cafba50 --- /dev/null +++ b/tests/cli/validation/block-handler-with-incompatible-mapping-function.stderr @@ -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 diff --git a/tests/cli/validation/block-handler-with-incompatible-mapping-function/Abi.json b/tests/cli/validation/block-handler-with-incompatible-mapping-function/Abi.json new file mode 100644 index 000000000..4d05f5839 --- /dev/null +++ b/tests/cli/validation/block-handler-with-incompatible-mapping-function/Abi.json @@ -0,0 +1,7 @@ +[ + { + "type": "event", + "name": "ExampleEvent", + "inputs": [{ "type": "string" }] + } +] diff --git a/tests/cli/validation/block-handler-with-incompatible-mapping-function/mapping.ts b/tests/cli/validation/block-handler-with-incompatible-mapping-function/mapping.ts new file mode 100644 index 000000000..55376e559 --- /dev/null +++ b/tests/cli/validation/block-handler-with-incompatible-mapping-function/mapping.ts @@ -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() +} \ No newline at end of file diff --git a/tests/cli/validation/block-handler-with-incompatible-mapping-function/schema.graphql b/tests/cli/validation/block-handler-with-incompatible-mapping-function/schema.graphql new file mode 100644 index 000000000..96ba50b79 --- /dev/null +++ b/tests/cli/validation/block-handler-with-incompatible-mapping-function/schema.graphql @@ -0,0 +1,5 @@ +type ExampleBlockEntity @entity { + id: ID! + number: BigInt! + hash: Bytes! +} diff --git a/tests/cli/validation/block-handler-with-incompatible-mapping-function/subgraph.yaml b/tests/cli/validation/block-handler-with-incompatible-mapping-function/subgraph.yaml new file mode 100644 index 000000000..66d422fe0 --- /dev/null +++ b/tests/cli/validation/block-handler-with-incompatible-mapping-function/subgraph.yaml @@ -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 \ No newline at end of file