Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robert committed Oct 11, 2021
1 parent 5d1421e commit 76cc860
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts } = hre;
const { deployer } = await getNamedAccounts();

// all sports can use the same fetcher
await deployments.deploy("SportsFetcher", {
from: deployer,
args: [],
Expand Down
11 changes: 8 additions & 3 deletions packages/smart/test/link-factory-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,13 @@ describe("NBA", () => {
expect(sportsEvent.awayScore, "awayScore").to.equal(0);
});

let fetcher: SportsFetcher;
beforeEach(async () => {
fetcher = (await ethers.getContract("SportsFetcher")) as SportsFetcher;
});

it("lists resolvable events", async () => {
const events = await marketFactory.listResolvableEvents();
const [events, index] = await fetcher.listResolvableEvents(marketFactory.address, 0, 100);
expect(events.length).to.equal(1);
expect(Number(events[0])).to.equal(eventId);
});
Expand All @@ -218,7 +223,7 @@ describe("NBA", () => {
});

it("stops listing resolved events", async () => {
const events = await marketFactory.listResolvableEvents();
const [events, index] = await fetcher.listResolvableEvents(marketFactory.address, 0, 100);
expect(events.length).to.equal(0);
});
});
Expand Down Expand Up @@ -363,7 +368,7 @@ describe("Sports fetcher", () => {

it("is deployable", async () => {
fetcher = await new SportsFetcher__factory(signer).deploy();
expect(await fetcher.marketType()).to.equal("NBA");
expect(await fetcher.marketType()).to.equal("Sports");
expect(await fetcher.version()).to.be.a("string");
});

Expand Down
11 changes: 8 additions & 3 deletions packages/smart/test/mma-factory-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deployments, ethers } from "hardhat";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signers";
import { expect } from "chai";

import { Cash, MMAMarketFactoryV3, OwnedERC20__factory } from "../typechain";
import { Cash, MMAMarketFactoryV3, OwnedERC20__factory, SportsFetcher } from "../typechain";
import { BigNumber } from "ethers";
import { MMAWhoWon, SportsLinkEventStatus } from "../src";

Expand Down Expand Up @@ -66,8 +66,13 @@ describe("MMA Factory", () => {
expect(await home.name()).to.equal(homeTeamName);
});

let fetcher: SportsFetcher;
beforeEach(async () => {
fetcher = (await ethers.getContract("SportsFetcher")) as SportsFetcher;
});

it("lists resolvable events", async () => {
const events = await marketFactory.listResolvableEvents();
const [events, index] = await fetcher.listResolvableEvents(marketFactory.address, 0, 100);
expect(events.length).to.equal(1);
expect(Number(events[0])).to.equal(eventId);
});
Expand All @@ -83,7 +88,7 @@ describe("MMA Factory", () => {
});

it("stops listing resolved events", async () => {
const events = await marketFactory.listResolvableEvents();
const [events, index] = await fetcher.listResolvableEvents(marketFactory.address, 0, 100);
expect(events.length).to.equal(0);
});
});
Expand Down
15 changes: 11 additions & 4 deletions packages/smart/test/nfl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
NFLMarketFactoryV3,
NFLMarketFactoryV3__factory,
OwnedERC20__factory,
SportsFetcher,
} from "../typechain";
import { BigNumber } from "ethers";
import { calcShareFactor, SportsLinkEventStatus } from "../src";
Expand Down Expand Up @@ -171,10 +172,16 @@ describe("NFL", () => {
expect(sportsEvent.awayScore, "awayScore").to.equal(0);
});

let fetcher: SportsFetcher;
beforeEach(async () => {
fetcher = (await ethers.getContract("SportsFetcher")) as SportsFetcher;
});

it("lists resolvable events", async () => {
const events = await marketFactory.listResolvableEvents();
expect(events.length).to.equal(1);
expect(Number(events[0])).to.equal(eventId);
const [events, index] = await fetcher.listResolvableEvents(marketFactory.address, 0, 100);
expect(events.length, "events.length").to.equal(1);
expect(Number(events[0]), "event id").to.equal(eventId);
expect(index, "index").to.equal(0);
});

it("can resolve markets", async () => {
Expand All @@ -191,7 +198,7 @@ describe("NFL", () => {
});

it("stops listing resolved events", async () => {
const events = await marketFactory.listResolvableEvents();
const [events, index] = await fetcher.listResolvableEvents(marketFactory.address, 0, 100);
expect(events.length).to.equal(0);
});
});
Expand Down

0 comments on commit 76cc860

Please sign in to comment.