diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/contracts_unit_tests.yml similarity index 80% rename from .github/workflows/unit_tests.yml rename to .github/workflows/contracts_unit_tests.yml index 4017d71..a8e85d7 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/contracts_unit_tests.yml @@ -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 diff --git a/contracts/test/ChatGpt.ts b/contracts/test/ChatGpt.ts index 9bf799b..208d0b8 100644 --- a/contracts/test/ChatGpt.ts +++ b/contracts/test/ChatGpt.ts @@ -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"); diff --git a/contracts/test/ChatOracle.ts b/contracts/test/ChatOracle.ts index 1bb1ebe..bc079d9 100644 --- a/contracts/test/ChatOracle.ts +++ b/contracts/test/ChatOracle.ts @@ -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. @@ -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); @@ -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"); }); }); });