From 14dd664e72af2338935ec7a84a3c0cc607e70e97 Mon Sep 17 00:00:00 2001 From: Daksh Miglani Date: Sat, 8 May 2021 03:25:21 +0530 Subject: [PATCH] add test for getPosition --- contracts/protocols/mainnet/cream.sol | 18 ++++++++---------- hardhat.config.js | 11 ++++++++--- test/cream.js | 8 +++++++- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/contracts/protocols/mainnet/cream.sol b/contracts/protocols/mainnet/cream.sol index 95473a5..9bbb1ee 100644 --- a/contracts/protocols/mainnet/cream.sol +++ b/contracts/protocols/mainnet/cream.sol @@ -213,18 +213,16 @@ contract Resolver is Helpers { function getPosition(address owner, address[] memory crAddress) public - returns ( - CreamData[] memory, - CompReadInterface.CompBalanceMetadataExt memory - ) + returns (CreamData[] memory) + // CompReadInterface.CompBalanceMetadataExt memory { return ( - getCreamData(owner, crAddress), - CompReadInterface(getCreamReadAddress()).getCompBalanceMetadataExt( - getCreamToken(), - getComptroller(), - owner - ) + getCreamData(owner, crAddress) + // CompReadInterface(getCreamReadAddress()).getCompBalanceMetadataExt( + // getCreamToken(), + // getComptroller(), + // owner + // ) ); } } diff --git a/hardhat.config.js b/hardhat.config.js index 3a79f39..b2e46f7 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -31,17 +31,22 @@ module.exports = { { version: "0.7.3" } - ] + ], + optimizer: { + enabled: true, + runs: 200, + }, }, networks: { hardhat: { forking: { - url: "https://eth-mainnet.alchemyapi.io/v2/" + ALCHEMY_API_KEY + url: "https://eth-mainnet.alchemyapi.io/v2/" + ALCHEMY_API_KEY, + blockNumber: 12386345 } } }, mocha: { - timeout: 50000, + timeout: 100000, } }; diff --git a/test/cream.js b/test/cream.js index d97902d..da2546b 100644 --- a/test/cream.js +++ b/test/cream.js @@ -1,4 +1,5 @@ const { expect } = require("chai"); +const { ethers } = require("hardhat"); describe("InstaCreamResolver", function () { let cream; @@ -13,7 +14,12 @@ describe("InstaCreamResolver", function () { await cream.deployed(); }); - it("should fetch cream data from CrUSDT", async function () { + it("should fetch cream data for CrUSDT", async function () { expect(await cream.getCreamData(signer.address, [CrUSDT])).to.exist; }); + + it("should fetch cream position for CrUSDT", async function () { + const res = await cream.callStatic.getPosition(signer.address, [CrUSDT]); + expect(res).to.exist + }); });