Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- what should be the problem over here?
- test.js =>
- const { expect } = require("chai");
- describe("test for price feed", async function ()
- {
- let Token;
- let hahrdhatToken;
- let owner;
- let add1;
- let add2;
- let add3;
- beforeEach(async function ()
- {
- [owner, add1, add2, add3, ...addrs] = await ethers.getSigners();
- PriceConsumerV3 = await ethers.getContractFactory("PriceConsumerV3");
- hardhatToken = await PriceConsumerV3.deploy();
- });
- it("lets see it gives the error or not after transfer", async function ()
- {
- const pricefromcontract = await hardhatToken.getLatestPrice();
- expect(pricefromcontract).to.equal(116415000000);
- console.log(pricefromcontract);
- })
- })
- PriceaConsumerv3 =>
- // SPDX-License-Identifier: MIT
- pragma solidity ^0.8.7;
- import "./AggregatorV3Interface.sol";
- contract PriceConsumerV3 {
- AggregatorV3Interface internal priceFeed;
- /**
- * Network: Kovan
- * Aggregator: ETH/USD
- * Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
- */
- constructor() {
- priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
- }
- /**
- * Returns the latest price
- */
- function getLatestPrice() public view returns (int) {
- (
- /*uint80 roundID*/,
- int price,
- /*uint startedAt*/,
- /*uint timeStamp*/,
- /*uint80 answeredInRound*/
- ) = priceFeed.latestRoundData();
- return price;
- }
- }
Add Comment
Please, Sign In to add comment