From b3e2776b87a52655bbde743b31388492cc433ac9 Mon Sep 17 00:00:00 2001 From: paco Date: Sun, 13 Nov 2022 23:11:51 -0300 Subject: [PATCH] failing tests for new implementation of add-program --- package.json | 2 ++ test/deployments.ts | 39 ++++++++++++++++++++++++++++++++++++--- yarn.lock | 2 +- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index c6ef51e..9f62a56 100644 --- a/package.json +++ b/package.json @@ -62,9 +62,11 @@ "@ethersproject/wallet": "5.7.0", "@openzeppelin/contracts": "4.6.0", "@rari-capital/solmate": "6.4.0", + "@types/chai-as-promised": "^7.1.5", "@uniswap/lib": "https://github.com/Uniswap/solidity-lib", "@uniswap/v2-periphery": "https://github.com/Uniswap/v2-periphery", "alchemist": "https://github.com/itirabasso/alchemist", + "chai-as-promised": "^7.1.1", "ds-auth": "https://github.com/dapphub/ds-auth", "ds-math": "https://github.com/dapphub/ds-math", "ds-test": "https://github.com/dapphub/ds-test", diff --git a/test/deployments.ts b/test/deployments.ts index 59a4115..fd999a3 100644 --- a/test/deployments.ts +++ b/test/deployments.ts @@ -1,4 +1,4 @@ -import { expect } from "chai"; +import chai, { expect } from "chai"; import { AbiCoder } from "ethers/lib/utils"; import { deployments, ethers, run } from "hardhat"; import { @@ -10,7 +10,9 @@ import { RewardPoolFactory, } from "../typechain-types"; import { GEYSER_V2_VANITY_ADDRESS } from "../constants"; +import chaiAsPromised from "chai-as-promised"; import { DAYS } from "./utils"; +chai.use(chaiAsPromised); describe("Aludel factory deployments", function () { describe("WHEN deploying a template set", () => { @@ -58,15 +60,15 @@ describe("Aludel factory deployments", function () { ); preexistingProgram = (await ethersFactory.deploy()) as Aludel; }); + describe("WHEN adding it with the add-program task, AND passing al parameters", () => { beforeEach(async () => { await run("add-program", { - aludelFactory: factory.address, program: preexistingProgram.address, template: GEYSER_V2_VANITY_ADDRESS, name: "some name", stakingTokenUrl: "http://buy.here", - startTime: "69", + startTime: 69, }); }); it("THEN it is listed", async () => { @@ -74,6 +76,37 @@ describe("Aludel factory deployments", function () { expect(program.name).to.eq("some name"); }); }); + + it("WHEN adding it with the add-program task, AND omitting the template THEN it fails because the template is not optional", async () => { + await expect( + run("add-program", { + program: preexistingProgram.address, + name: "some name", + stakingTokenUrl: "http://buy.here", + startTime: 69, + }) + ).to.be.rejectedWith( + "HH306: The 'template' parameter expects a value, but none was passed" + ); + }); + + describe("WHEN adding it with the add-program task, AND omitting the startTime", () => { + beforeEach(async () => { + await run("add-program", { + program: preexistingProgram.address, + template: GEYSER_V2_VANITY_ADDRESS, + name: "some name", + stakingTokenUrl: "http://buy.here", + }); + }); + it("THEN the current timestamp is used", async () => { + const program = await factory.programs(preexistingProgram.address); + const currentTime = Date.now() / 1000; + // we're going to have bigger problems on the epochalipse + expect(program.startTime.toNumber()).to.be.lt(currentTime); + expect(program.startTime.toNumber()).to.be.gt(currentTime - 20); + }); + }); }); describe("GIVEN a PowerSwitchFactory, a CrucibleFactory, a RewardPoolFactory, and some other stuff", () => { diff --git a/yarn.lock b/yarn.lock index 50d583e..76fea68 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1326,7 +1326,7 @@ "@types/node" "*" "@types/responselike" "*" -"@types/chai-as-promised@^7.1.3": +"@types/chai-as-promised@^7.1.3", "@types/chai-as-promised@^7.1.5": version "7.1.5" resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-7.1.5.tgz#6e016811f6c7a64f2eed823191c3a6955094e255" integrity sha512-jStwss93SITGBwt/niYrkf2C+/1KTeZCZl1LaeezTlqppAKeoQC7jxyqYuP72sxBGKCIbw7oHgbYssIRzT5FCQ==