import { assert, describe, test, clearStore, beforeAll, afterAll } from "matchstick-as/assembly/index" import { BigInt, Address } from "@graphprotocol/graph-ts" import { PositionCreated } from "../generated/schema" import { PositionCreated as PositionCreatedEvent } from "../generated/Stake/Stake" import { handlePositionCreated } from "../src/stake" import { createPositionCreatedEvent } from "./stake-utils" // Tests structure (matchstick-as >=0.5.0) // https://thegraph.com/docs/en/developer/matchstick/#tests-structure-0-5-0 describe("Describe entity assertions", () => { beforeAll(() => { let positionId = BigInt.fromI32(234) let owner = Address.fromString("0x0000000000000000000000000000000000000001") let share = BigInt.fromI32(234) let creationTime = BigInt.fromI32(234) let taxRate = BigInt.fromI32(234) let newPositionCreatedEvent = createPositionCreatedEvent( positionId, owner, share, creationTime, taxRate ) handlePositionCreated(newPositionCreatedEvent) }) afterAll(() => { clearStore() }) // For more test scenarios, see: // https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test test("PositionCreated created and stored", () => { assert.entityCount("PositionCreated", 1) // 0xa16081f360e3847006db660bae1c6d1b2e17ec2a is the default address used in newMockEvent() function assert.fieldEquals( "PositionCreated", "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", "positionId", "234" ) assert.fieldEquals( "PositionCreated", "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", "owner", "0x0000000000000000000000000000000000000001" ) assert.fieldEquals( "PositionCreated", "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", "share", "234" ) assert.fieldEquals( "PositionCreated", "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", "creationTime", "234" ) assert.fieldEquals( "PositionCreated", "0xa16081f360e3847006db660bae1c6d1b2e17ec2a-1", "taxRate", "234" ) // More assert options: // https://thegraph.com/docs/en/developer/matchstick/#asserts }) })