full-blockchain-solidity-course-py
full-blockchain-solidity-course-py copied to clipboard
Lesson 6 & 7 : Test using mainnet-fork giving error.
when I run brownie test --network mainnet-fork-dev
. I am getting below error:
What is the reason? I am not able to understand the exact issue based on this message. The test works fine if I run brownie test
i.e. development env
@cromewar : Can you please help me through this :( What am I missing?
Hello @shashankvivek
I'll need more info on this, seems your getEntraceFee
is reverting the transaction. So, please share the following information:
- What is the output at deploying on development?.
- The
brownie-config.yaml
. - The code of your test script.
Hi @cromewar ,
My bad about one info brownie run
is not working as I never handled eth_use_price_feed
. For Lesson 7, I am at the beginning where there is no deploy.py
script yet. I have created the contract and then created the mainnet-fork with API key and then run the test. Hence I see:
Here is
brownie-config.yaml
dependencies:
- smartcontractkit/[email protected]
compiler:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected]'
networks:
mainnet-fork:
eth_use_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
test_lottery.py
# 1 USD => 0.017 ETH
# 170000000000000000
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_use_price_feed"],
{"from": account}
)
print(lottery.getEntranceFee())
assert lottery.getEntranceFee() > 160000000000000000
assert lottery.getEntranceFee() > Web3.toWei(0.016,"ether")
assert lottery.getEntranceFee() < Web3.toWei(0.022,"ether")
Well the error shows the problem is with:
`eth_use_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419' So,
- on your contract, is the constructor well declared to receive that entrance fee?
- The key error also could be due to a bad
brownie-config.yaml
look for any typo or indentation error on that file. - Also just a good practice, the name should be
eth_usd_price_feed
.
I hope any of this info might help.
Well the error shows the problem is with:
`eth_use_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419' So,
- on your contract, is the constructor well declared to receive that entrance fee?
- The key error also could be due to a bad
brownie-config.yaml
look for any typo or indentation error on that file.- Also just a good practice, the name should be
eth_usd_price_feed
.I hope any of this info might help.
@cromewar Well, the error happened because I have not handled development
network in the my yaml file and hence getting error while accessing it via config["networks"][network.show_active()]["eth_use_price_feed"]
. I'll fix the typo to eth_usd_price_feed