From 5d4ab86ca71dd9d6e6d96e9fcd2235ff1de55ebe Mon Sep 17 00:00:00 2001 From: Jamil Bousquet Date: Wed, 3 Jan 2024 10:44:46 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20`PassportIssuer`=20subgraph?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📌 Pin dependencies and build 📝 Add local testing guide 💚 Add `codegen` command 📄 Add license to `package.json` 💚 Fixing `npm` step ✅ Fix test event setups ✅ Add `Revoke` test 📝 Add more info on unit testing --- .github/workflows/build.yml | 20 +- README.md | 30 ++ .../build/PassportIssuer/PassportIssuer.wasm | Bin 0 -> 38899 bytes .../PassportIssuer/abis/PassportIssuer.json | 510 ++++++++++++++++++ passportissuance/build/schema.graphql | 43 ++ passportissuance/build/subgraph.yaml | 38 ++ passportissuance/package.json | 2 +- passportissuance/tests/.latest.json | 4 + .../tests/passport-issuer-utils.ts | 67 ++- .../tests/passport-issuer.test.ts | 52 +- 10 files changed, 732 insertions(+), 34 deletions(-) create mode 100644 passportissuance/build/PassportIssuer/PassportIssuer.wasm create mode 100644 passportissuance/build/PassportIssuer/abis/PassportIssuer.json create mode 100644 passportissuance/build/schema.graphql create mode 100644 passportissuance/build/subgraph.yaml create mode 100644 passportissuance/tests/.latest.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9735b63..d85fcf1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,23 +8,21 @@ on: jobs: build: - strategy: - matrix: - os: [ubuntu-latest] - node-version: [16.x, 18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - runs-on: ${{ matrix.os }} + + runs-on: ubuntu-latest defaults: run: - working-directory: passportissuance + working-directory: ./passportissuance + steps: - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + + - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - cache-dependency-path: passportissuance/package-lock.json + node-version: '20.x' - run: npm install - - run: nom run build + - run: npm run codegen + - run: npm run build - run: npm run test diff --git a/README.md b/README.md index ec42dfa..0af8484 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,33 @@ Refer to the following guide from [The Graph's docs](https://thegraph.com/docs/e ## Contributing Refer to [this document from The Graph's docs](https://thegraph.com/docs/en/developing/creating-a-subgraph/) on how to set up your development environment for making changes to, and deploying new, subgraphs. + +## Testing + +Two options are available for testing: + +1. [Local Graph deployment (integration testing)](/#Local) +2. [Matchstick unit tests](/#Matchstick) + +### Local + +To test your changes to the subgraph locally you will need a local IPFS Gateway for the subgraph to deploy files to. + +Refer to [this guide](https://docs.ipfs.tech/how-to/command-line-quick-start/) to learn how to do so and ensure your gateway points to `http://localhost:5001`. + +Then run the following commands in the subgraph's directory (e.g. the [PassportIssuer](./passportissuance/) subgraph directory): + +```console +npm run codegen +npm run build +npm run create-local +npm run deploy-local +``` + +### [Matchstick](https://github.com/LimeChain/matchstick/blob/main/README.md) + +Simply run the following command to run the available tests in their respective subgraph directories (e.g. [PassportIssuer](./passportissuance/)): + +```console +npm run test +``` diff --git a/passportissuance/build/PassportIssuer/PassportIssuer.wasm b/passportissuance/build/PassportIssuer/PassportIssuer.wasm new file mode 100644 index 0000000000000000000000000000000000000000..db291aae0a53bbcc4bcd88fc020dd9b11d357252 GIT binary patch literal 38899 zcmeHw3z!tuwQf~c&$FhXdB3%1Km>WrlVJu#r~z8=1qwc5OvYxWfu2YA(A|TQ7#S56 z6&2s8Bq7nL$;D{S_1x<@;oeIUHE4(-FXO$(BqW*yl_VxHiAgx|{{PxlUDeGD3>5j! zx!-qZzP;A2{aAbLwbovH?HZ`9#WLNxrfGU@+12`Hee>0U&4kA0&6_n8Xp%#Lrd=IG z84AzqOcsi3vCC6nq^~4wF9%rxFl#ORrrlkp!a%MiY!77)vmY zU_8MDf{6r^2u>q7oghL`Nl-;FnP3XR83a=a&Lo&dFrDBmf*Axe31$(@Ca5N;A*dy& zBd8~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Ai7ES9lJQB05N)%Rcvd^j6)+OEk4wkG{`(tM23d zO+L}w4cNEoKF-7WG@U!MZ`XZ$Dn`*%Hm}LP&=ir=Is5++gp~eY{~%R=4`vdv)L2g}U|pKL1YBIi=n2UwOF` z)dT*;o};A>2oL&SN;!(F;@O9E-){)Kh31lx zw;;RxEDMKLI+o1D(newMockEvent()) + let mockEvent = newMockEvent() + + let attestEvent = new Attest( + mockEvent.address, + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + [], + mockEvent.receipt + ) attestEvent.parameters = new Array() @@ -26,8 +37,19 @@ export function createAttestEvent(_to: Address, _tokenId: BigInt): Attest { return attestEvent } -export function createInitializedEvent(version: i32): Initialized { - let initializedEvent = changetype(newMockEvent()) +export function createInitializedEvent(version: number): Initialized { + let mockEvent = newMockEvent() + + let initializedEvent = new Initialized( + mockEvent.address, + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + [], + mockEvent.receipt + ) initializedEvent.parameters = new Array() @@ -45,8 +67,17 @@ export function createOwnershipTransferredEvent( previousOwner: Address, newOwner: Address ): OwnershipTransferred { - let ownershipTransferredEvent = changetype( - newMockEvent() + let mockEvent = newMockEvent() + + let ownershipTransferredEvent = new OwnershipTransferred( + mockEvent.address, + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + [], + mockEvent.receipt ) ownershipTransferredEvent.parameters = new Array() @@ -65,7 +96,18 @@ export function createOwnershipTransferredEvent( } export function createRevokeEvent(_to: Address, _tokenId: BigInt): Revoke { - let revokeEvent = changetype(newMockEvent()) + let mockEvent = newMockEvent() + + let revokeEvent = new Revoke( + mockEvent.address, + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + [], + mockEvent.receipt + ) revokeEvent.parameters = new Array() @@ -86,7 +128,18 @@ export function createUpdateRequirementsEvent( claimRequiredBalance: BigInt, revokeUnderBalance: BigInt ): UpdateRequirements { - let updateRequirementsEvent = changetype(newMockEvent()) + let mockEvent = newMockEvent() + + let updateRequirementsEvent = new UpdateRequirements( + mockEvent.address, + mockEvent.logIndex, + mockEvent.transactionLogIndex, + mockEvent.logType, + mockEvent.block, + mockEvent.transaction, + [], + mockEvent.receipt + ) updateRequirementsEvent.parameters = new Array() diff --git a/passportissuance/tests/passport-issuer.test.ts b/passportissuance/tests/passport-issuer.test.ts index b5c2f35..be5e91c 100644 --- a/passportissuance/tests/passport-issuer.test.ts +++ b/passportissuance/tests/passport-issuer.test.ts @@ -7,20 +7,15 @@ import { afterAll } from "matchstick-as/assembly/index" import { Address, BigInt } from "@graphprotocol/graph-ts" -import { Attest } from "../generated/schema" -import { Attest as AttestEvent } from "../generated/PassportIssuer/PassportIssuer" -import { handleAttest } from "../src/passport-issuer" -import { createAttestEvent } from "./passport-issuer-utils" +import { handleAttest, handleRevoke } from "../src/passport-issuer" +import { createAttestEvent, createRevokeEvent } from "./passport-issuer-utils" // Tests structure (matchstick-as >=0.5.0) // https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 -describe("Describe entity assertions", () => { +describe("Test `Attest` Event Handling", () => { + beforeAll(() => { - let _to = Address.fromString("0x0000000000000000000000000000000000000001") - let _tokenId = BigInt.fromI32(234) - let newAttestEvent = createAttestEvent(_to, _tokenId) - handleAttest(newAttestEvent) }) afterAll(() => { @@ -31,23 +26,50 @@ describe("Describe entity assertions", () => { // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test test("Attest created and stored", () => { + let _to = Address.fromString("0x0000000000000000000000000000000000000001") + let _tokenId = BigInt.fromI32(234) + let newAttestEvent = createAttestEvent(_to, _tokenId) + handleAttest(newAttestEvent) + assert.entityCount("Attest", 1) - - // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function + + let event_id = newAttestEvent.transaction.hash.concatI32(newAttestEvent.logIndex.toI32()) assert.fieldEquals( "Attest", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + event_id.toHexString(), "_to", "0x0000000000000000000000000000000000000001" ) assert.fieldEquals( "Attest", - "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", + event_id.toHexString(), + "_tokenId", + "234" + ) + + }) + + test("Revoke invocation created and stored", () => { + let _to = Address.fromString("0x0000000000000000000000000000000000000001") + let _tokenId = BigInt.fromI32(234) + let newRevokeEvent = createRevokeEvent(_to, _tokenId) + handleRevoke(newRevokeEvent) + + assert.entityCount("Revoke", 1) + + let event_id = newRevokeEvent.transaction.hash.concatI32(newRevokeEvent.logIndex.toI32()) + assert.fieldEquals( + "Revoke", + event_id.toHexString(), + "_to", + "0x0000000000000000000000000000000000000001" + ) + assert.fieldEquals( + "Revoke", + event_id.toHexString(), "_tokenId", "234" ) - // More assert options: - // https://thegraph.com/docs/en/developer/matchstick/#asserts }) })