Skip to content

Commit

Permalink
Fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KasparPeterson committed Mar 27, 2024
1 parent fd55be9 commit d6878e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
node-version: 20
cache: 'npm'
cache-dependency-path: contracts/package-lock.json
- name: "Install Dependencies"
id: install
run: cd contracts && npm ci
Expand Down
1 change: 1 addition & 0 deletions contracts/test/ChatGpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe("ChatGpt", function () {

await chatGpt.startChat("Hello");
await oracle.connect(oracleAccount).addResponse(0, 0, "Hi", "");
await oracle.connect(oracleAccount).markPromptAsProcessed(0);
await expect(
oracle.connect(oracleAccount).addResponse(0, 0, "Hi", "")
).to.be.revertedWith("Prompt already processed");
Expand Down
9 changes: 5 additions & 4 deletions contracts/test/ChatOracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {loadFixture,} from "@nomicfoundation/hardhat-toolbox/network-helpers";
import {expect} from "chai";
import {ethers} from "hardhat";

describe("ChatGpt", function () {
describe("ChatOracle", function () {
// We define a fixture to reuse the same setup in every test.
// We use loadFixture to run this setup once, snapshot that state,
// and reset Hardhat Network to that snapshot in every test.
Expand All @@ -20,7 +20,8 @@ describe("ChatGpt", function () {
describe("Deployment", function () {
it("Can update attestation", async () => {
const {oracle, owner, allSigners} = await loadFixture(deploy);
await oracle.addAttestation(allSigners[1].address, "attestation");
await oracle.connect(owner).updateWhitelist(allSigners[1], true);
await oracle.connect(allSigners[1]).addAttestation("attestation");

const attestationOwner = await oracle.latestAttestationOwner();
const attestation = await oracle.attestations(attestationOwner);
Expand All @@ -30,8 +31,8 @@ describe("ChatGpt", function () {
const {oracle, owner, allSigners} = await loadFixture(deploy);

await expect(
oracle.connect(allSigners[1]).addAttestation(allSigners[1].address, "attestation")
).to.be.rejectedWith("Caller is not owner");
oracle.connect(allSigners[1]).addAttestation("attestation")
).to.be.rejectedWith("Caller is not whitelisted");
});
});
});

0 comments on commit d6878e7

Please sign in to comment.