Following the steps taken in the bootcamp day2 video on testing solidity contracts with brownie, I stumbled upon an error when testing the chainlink-mix scripts locally.
Here are the steps are taken to introduce the error:
ganache is selected as the default network and the server is listening on the ip/port 127.0.0.1:8545.
brownie run scripts/price_feed_scripts/02_read_price_feed.py
Brownie v1.18.1 - Python development framework for Ethereum
ChainlinkMixProject is the active project.
/usr/local/lib/python3.9/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 14
warnings.warn(
Attached to local RPC client listening at '127.0.0.1:8545'...
Running 'scripts/price_feed_scripts/02_read_price_feed.py::main'...
<brownie.network.contract.ContractContainer object at 0x10e410dc0>
File "brownie/_cli/run.py", line 51, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/price_feed_scripts/02_read_price_feed.py", line 7, in main
price_feed_contract = PriceFeedConsumer[-1]
File "brownie/network/contract.py", line 175, in __getitem__
return self._contracts[i]
IndexError: list index out of range
ganache is set as default network in the brownie-config.yaml
Brownie doesn't save the location of deployed contracts to a local running chain by default since they get deleted so often and would take up a ton of space, so you have to tell brownie to remember stuff deployed to ganache.
In your brownie-config.yaml
add
dev_deployment_artifacts: true
And rerun your scripts