Skip to content

Commit

Permalink
Merge pull request #52 from gildlab/13-02-2023-tests
Browse files Browse the repository at this point in the history
13 02 2023 tests
  • Loading branch information
thedavidmeister committed Feb 17, 2023
2 parents 6fba1dd + 9f63c7b commit 2b5bbff
Show file tree
Hide file tree
Showing 3 changed files with 671 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = [
{
implementation: "0x486303714EB5185742acBC63F119fda3b7E637AE",
receiptFactory: "0xd5753d6B68712bda48d4867186d7BED9db3656A5",
},
];
33 changes: 31 additions & 2 deletions test/IPFSPull.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
import erc1155Metadata from "../erc1155Metadata/ReceiptMetadata.json";
import assert from "assert";
import { artifacts, ethers } from "hardhat";
import { Receipt, ReceiptFactory } from "../typechain-types";
import { expectedUri, getEventArgs } from "./util";
import { Contract } from "ethers";

describe("IPFS pull", async function () {
it("Pulls data from ipfs and checks it", async function () {
this.timeout(0);
const resp = await fetch(
"https://ipfs.io/ipfs/bafkreih7cvpjocgrk7mgdel2hvjpquc26j4jo2jkez5y2qdaojfil7vley"

const signers = await ethers.getSigners();
const alice = signers[0];

const receiptFactoryFactory = await ethers.getContractFactory(
"ReceiptFactory"
);
const receiptFactoryContract =
(await receiptFactoryFactory.deploy()) as ReceiptFactory;
await receiptFactoryContract.deployed();

let tx = await receiptFactoryContract.createChild([]);

const { child } = await getEventArgs(
tx,
"NewChild",
receiptFactoryContract
);

let childContract = new Contract(
child,
(await artifacts.readArtifact("Receipt")).abi
) as Receipt;

let uri = await childContract.connect(alice).uri(1);

const resp = await fetch(`https://ipfs.io/ipfs/${uri.slice(7)}`);

const ipfsData = await resp.json().catch(console.error);

assert(
Expand Down
Loading

0 comments on commit 2b5bbff

Please sign in to comment.