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
import { test } from "matchstick-as/assembly/index"; | |
import { log } from "matchstick-as/assembly/log"; | |
export function runTests(): void { | |
test("Success", () => { | |
log.success("Success!"); | |
}); | |
test("Error", () => { | |
log.error("Error :( "); | |
}); |
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
import { assert } from "matchstick-as/assembly/index"; | |
import { ethereum } from "@graphprotocol/graph-ts"; | |
assert.equals(ethereum.Value.fromString("hello"), ethereum.Value.fromString("hello")); |
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
import { newMockEvent } from "matchstick-as/assembly/index"; | |
import { ethereum, Address } from "@graphprotocol/graph-ts"; | |
import { NewCustomEntity } from "../generated/MyDataSource/Example"; | |
let newEntityEvent = newMockEvent(new NewCustomEntity()) as NewCustomEntity; | |
// Read | |
let logType = newEntityEvent.logType; | |
// Write |
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
import { addMetadata } from "matchstick-as/assembly/index"; | |
import { ethereum } from "@graphprotocol/graph-ts"; | |
import { NewCustomEntity } from "../generated/MyDataSource/Example"; | |
let base: ethereum.Event = new NewCustomEntity(); | |
let newEntityEvent: NewCustomEntity = addMetadata(base); |
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
import { assert, createMockedFunction } from "matchstick-as/assembly/index"; | |
import { Contract } from "../../generated/MyDataSource/Example"; | |
import { Address, ethereum } from "@graphprotocol/graph-ts"; | |
let contractAddress = Address.fromString("0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7"); | |
let arg = ethereum.Value.fromString("example string arg"); | |
createMockedFunction(contractAddress, "functionName", "functionName(string):(string)") | |
.withArgs([arg]) | |
.reverts(); |
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
import { assert, createMockedFunction } from "matchstick-as/assembly/index"; | |
import { Contract } from "../../generated/MyDataSource/Example"; | |
import { Address, ethereum } from "@graphprotocol/graph-ts"; | |
let contractAddress = Address.fromString("0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7"); | |
let arg = ethereum.Value.fromString("example string arg"); | |
createMockedFunction(contractAddress, "functionName", "functionName(string):(string)") | |
.withArgs([arg]) | |
.returns([ethereum.Value.fromString("result")]); |
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
import { test, assert } from "matchstick-as/assembly/index"; | |
import { CustomEntity } from '../../generated/schema'; | |
import { Value } from "@graphprotocol/graph-ts"; | |
export function runTests(): void { | |
test("Next test", () => { | |
let customEntity = new CustomEntity("434"); | |
customEntity.set("name", Value.fromString("Frederick")); | |
customEntity.save(); |
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
import { clearStore, test, assert, newMockEvent } from "matchstick-as/assembly/index"; | |
import { ethereum } from "@graphprotocol/graph-ts"; | |
import { NewCustomEntity } from "../generated/MyDataSource/Example"; | |
import { handleNewCustomEntity } from "../mapping"; | |
export function runTests(): void { | |
test("Example", () => { | |
// Initialise event (this can be generalised into a separate function) | |
let newEntityEvent = newMockEvent(new NewCustomEntity()) as NewCustomEntity; | |
newEntityEvent.parameters = []; |
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
import { NewCustomEntity } from "../generated/MyDataSource/Example"; | |
import { CustomEntity } from '../generated/schema'; | |
export function handleNewCustomEntity(event: NewCustomEntity): void { | |
let customEntity = new CustomEntity(event.params.id.toString()); | |
customEntity.name = event.params.name; | |
customEntity.save(); | |
} |
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
import { NewEntity } from "../generated/Example/Example"; | |
import { CustomEntity } from '../../generated/schema'; | |
export function handleNewEntity(event: NewEntity): void { | |
let customEntity = new CustomEntity(event.params.id.toHex()); | |
customEntity.name = event.params.displayName; | |
customEntity.save(); | |
} |
NewerOlder