Lottery: testing test_get_entrance_fee() fails #286
Unanswered
pavelgor84
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Hello @pavelgor84 it seems your
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
AggregatorV3Interface internal ethUsdPriceFeed;
function getEntranceFee() public view returns (uint256) {
(, int256 price, , , ) = ethUsdPriceFeed.latestRoundData();
// set entrance fee to $50
// Eth/Usd conversion has 8 decimals so in order to make it 18 (wei standard) it's necessary to multiply the price.
uint256 adjustedPrice = uint256(price) * (10**10); //18 decimals
uint256 costToEnter = (usdEntryFee * 10**18) / adjustedPrice;
return costToEnter;
}
I hope this info might help you. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I reached the first test for entrance fee function and have an error during testing this script:
**from brownie import Lottery, accounts, network, config
from web3 import Web3
def test_get_entrance_fee():
account = accounts[0]
lottery = Lottery.deploy(
config["networks"][network.show_active()]["eth_usd_price_feed"],
{"from": account},
)
ERROR:
E AssertionError: assert 0 > 10000000000000000
E + where 0 = <ContractCall 'getEntranceFee()'>()
E + where <ContractCall 'getEntranceFee()'> = <Lottery Contract '0xE7eD6747FaC5360f88a2EFC03E00d25789F69291'>.getEntranceFee
E + and 10000000000000000 = <function to_wei at 0x7fd9e59173a0>(0.01, 'ether')
E + where <function to_wei at 0x7fd9e59173a0> = Web3.toWei
tests/test_lottery.py:12: AssertionError
============================================== short test summary info ==============================================
FAILED tests/test_lottery.py::test_get_entrance_fee - AssertionError: assert 0 > 10000000000000000
================================================= 1 failed in 9.38s
It seems that test_get_entrance_fee() returns a number with floating point that raises the error " assert 0 > 10000000000000000". But on the video this test is passing.
My config:
etworks:
mainnet-fork:
eth_usd_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
Beta Was this translation helpful? Give feedback.
All reactions