forked from flare-foundation/developer-hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFTSOV2FeedConsumer_hardhat.js
More file actions
53 lines (43 loc) · 1.64 KB
/
FTSOV2FeedConsumer_hardhat.js
File metadata and controls
53 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { artifacts, ethers } from "hardhat";
import { expect } from "chai";
import { deployFlareContractRegistry } from "../lib/utils";
const FtsoV2FeedConsumer = artifacts.require("FtsoV2FeedConsumer");
describe("FtsoV2FeedConsumer", () => {
let ftsoConsumer;
const mockFtsoV2Address = "0x1234567890123456789012345678901234567890";
const mockFeeCalcAddress = "0x2345678901234567890123456789012345678901";
const mockFlrUsdId = "0x0123456789012345678901234567890123456789012345";
beforeEach(async () => {
// Deploy mock Flare Contract Registry
await deployFlareContractRegistry();
// Deploy the FtsoV2FeedConsumer contract
ftsoConsumer = await FtsoV2FeedConsumer.new(
mockFtsoV2Address,
mockFeeCalcAddress,
mockFlrUsdId,
);
});
describe("Constructor", () => {
it("should set the initial values correctly", async () => {
const storedFlrUsdId = await ftsoConsumer.flrUsdId();
expect(storedFlrUsdId).to.equal(mockFlrUsdId);
const feedIds = await ftsoConsumer.feedIds(0);
expect(feedIds).to.equal(mockFlrUsdId);
});
});
describe("checkFees", () => {
it("should update and return the fee", async () => {
// Since we're using mocks, we'll just verify the function can be called
const fee = await ftsoConsumer.fee();
expect(fee).to.be.a("number");
});
});
describe("getFlrUsdPrice", () => {
it("should revert if fee does not match msg.value", async () => {
const fee = ethers.parseEther("1.0");
await ftsoConsumer.checkFees();
await expect(ftsoConsumer.getFlrUsdPrice({ value: fee + 1n })).to.be
.reverted;
});
});
});