Lesson 7 TEST error #1726
Answered
by
moayaan1911
moayaan1911
asked this question in
Q&A
-
I am facing a TIMEOUT ERROR while testing my constructor of FundMe.sol file.
its showing like this. Here is my FundMe.Sol file:- //SPDX-License-Identifier:MIT
pragma solidity ^0.8.8;
import "./PriceConverter.sol";
/// @title A contract to raise funds
/// @author Mohammad Ayaan Siddiqui
/// @dev This implements price Feeds as our library
contract FundMe {
using PriceConverter for uint256;
// This contract will fund the user. Withdraw funds by the user. Set minimum value of USD a person can send
uint256 public constant minimumUSD = 50 * 1e18;
address[] public funders;
mapping(address => uint256) public addressToAmountFunded;
address public immutable owner;
AggregatorV3Interface public priceFeed;
constructor(address priceFeedAddress) {
owner = msg.sender;
priceFeed = AggregatorV3Interface(priceFeedAddress);
}
function fund() public payable {
// msg.value;// global keyword in solidity with which we can see how much ether is being transferred to the contract
require(
msg.value.getConversionRate(priceFeed) >= minimumUSD,
"Ddin't sent enough ether"
);
funders.push(msg.sender);
addressToAmountFunded[msg.sender] += msg.value;
}
function withdraw() public onlyOwner {
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
//reset the array
funders = new address[](0);
// withdraw the funds
// METHOD 1: transfer=> payable(msg.sender).transfer(address(this).balance);
// METHOD 2: send=> bool sendSuccess=payable(msg.sender).send(address(this).balance); require(sendSuccess,'Failed');
//METHOD 3: CALL METHOD RECOMMENDED FOR MOST PART
(bool callSuccess, ) = payable(msg.sender).call{
value: address(this).balance
}("");
require(callSuccess, "Call Failed");
}
modifier onlyOwner() {
require(msg.sender == owner, "Sender now owner");
_;
}
receive() external payable {
fund();
}
fallback() external payable {
fund();
}
} Here's my hardhat config file:- require("@nomicfoundation/hardhat-toolbox");
require("hardhat-deploy");
require("dotenv").config();
/** @type import('hardhat/config').HardhatUserConfig */
const RINKEBY_PRIVATE_KEY = process.env.RINKEBY_PRIVATE_KEY;
const RINKEBY_HOST = process.env.RINKEBY_HOST;
const ETHERSCAN_API = process.env.ETHERSCAN_API;
module.exports = {
solidity: {
compilers: [
{
version: "0.8.8",
},
{
version: "0.6.6",
},
],
},
defaultNetwork: "hardhat",
namedAccounts: {
deployer: {
default: 0,
},
user: {
default: 1,
},
},
networks: {
rinkeby: {
url: RINKEBY_HOST,
accounts: [RINKEBY_PRIVATE_KEY],
chainId: 4,
blockConfirmations: 6,
},
},
etherscan: {
apiKey: ETHERSCAN_API,
},
gasReporter: {
enabled: false,
outputFile: "gasReport.txt",
noColors: true,
currency: "USD",
coinmarketcap: process.env.CMC_API,
},
}; |
Beta Was this translation helpful? Give feedback.
Answered by
moayaan1911
Aug 12, 2022
Replies: 2 comments 2 replies
-
Basically I think I need to increase timeout settings in a configuration file, just don't know how to do it as I am testing on mock network |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
moayaan1911
-
@moayaan1911 In module.exports, inside your hardhat config file, add this: (like how networks, gasReporter etc. are) mocha: {
timeout: 500000, // 500 seconds max for running tests
}, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basically I think I need to increase timeout settings in a configuration file, just don't know how to do it as I am testing on mock network