full-blockchain-solidity-course-py
full-blockchain-solidity-course-py copied to clipboard
TypeError: string indices must be integers
I am trying to run test_lottery.py file but keep getting testcase failed due to type error.
def test_get_entrance_fee():
account = accounts[0]
lottery = Lottery.deploy(
config["networks"][network.show_active()]["eth_usd_price_feed"],
{"from": account},
)
below is the config.yaml file code
dependencies:
- smartcontractkit/[email protected]
compiler:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected]'
version: 0.6.6
networks:
mainnet-fork:
eth_usd_price_feed='0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
Trying to run test using following command: -
brownie test --network mainnet-fork
Keep getting following output: -
Brownie v1.16.4 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.6.6
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
Generating build data...
- smartcontractkit/[email protected]/AggregatorV3Interface
- Lottery
========================================================================== test session starts ===========================================================================
platform win32 -- Python 3.10.1, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: C:\Users\ASUS\demos\smartcontract-lottery
plugins: eth-brownie-1.16.4, hypothesis-6.21.6, forked-1.3.0, xdist-1.34.0, web3-5.23.1
collected 1 item
Launching 'ganache-cli.cmd --accounts 10 --fork https://eth-mainnet.alchemyapi.io/v2/vLxA0j3T4X8CSsbcj2iVQkisZqDUQS17 --mnemonic brownie --port 8545 --hardfork istanbul'...
tests\test_lottery.py F [100%]
================================================================================ FAILURES ================================================================================
_________________________________________________________________________ test_get_entrance_fee __________________________________________________________________________
def test_get_entrance_fee():
account = accounts[0]
lottery = Lottery.deploy(
> config["networks"][network.show_active()]["eth_usd_price_feed"],
{"from": account},
)
E TypeError: string indices must be integers
tests\test_lottery.py:10: TypeError
======================================================================== short test summary info =========================================================================
FAILED tests/test_lottery.py::test_get_entrance_fee - TypeError: string indices must be integers
=========================================================================== 1 failed in 9.94s ============================================================================
Terminating local RPC client...
Unable to find the reason for the error.
Hello @Rda-sg
Try replacing this line:
eth_usd_price_feed='0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
you should not use =
use :
instead,
also if you are going to test on a local environment (ganache) you should also add the eth_price_feed
to the development network.
Curious if this worked and also any guidance on how to add eth_price_feed to the dev network Thx