Skip to content

Instantly share code, notes, and snippets.

@axiomatic-aardvark
Last active August 11, 2021 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axiomatic-aardvark/c460d1305f79b077b9d2be512451767d to your computer and use it in GitHub Desktop.
Save axiomatic-aardvark/c460d1305f79b077b9d2be512451767d to your computer and use it in GitHub Desktop.
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")]);
let contract = Contract.bind(contractAddress);
let result = contract.try_functionName(arg);
assert.equals(ethereum.Value.fromString("result"), ethereum.Value.fromString(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment