Lesson 13: (13:53:17) AttributeError: 'function' object has no attribute 'transfer #746
Answered
by
cromewar
neerajnerlekar
asked this question in
Q&A
-
Hi, I am at lesson 13, trying to run the 1st unit test, test_token_farm.py. I am facing the following error and cannot resolve it on my own. Any help is greatly appreciated.Here is my code for the test_token_farm.py from brownie import network
from scripts.helpful_scripts import (
LOCAL_BLOCKCHAIN_ENVIRONMENTS,
get_account,
get_contract,
)
import pytest
from scripts.deploy import deploy_token_farm_and_dapp_token
def test_set_price_feed_contract():
# Arrange
if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
pytest.skip("Only for local testing!")
account = get_account
# checking for only owner test.
non_owner = get_account(index=1)
token_farm, dapp_token = deploy_token_farm_and_dapp_token()
# Act
price_feed_address = get_contract("eth_usd_price_feed")
# in address to address mapping, brownie know to only fetch the address for the second param and not the whole contract.
token_farm.setPriceFeedContract(
dapp_token.address, price_feed_address, {"from": account}
)
# Assert
assert token_farm.tokenPriceFeedMapping(dapp_token.address) == price_feed_address Here is my code for the deploy.py from scripts.helpful_scripts import get_account, get_contract
from brownie import DappToken, TokenFarm, config, network
from web3 import Web3
KEPT_BALANCE = Web3.toWei(100, "ether")
def deploy_token_farm_and_dapp_token():
account = get_account()
dapp_token = DappToken.deploy({"from": account})
token_farm = TokenFarm.deploy(
dapp_token.address,
{"from": account},
publish_source=config["networks"][network.show_active()]["verify"],
)
tx = dapp_token.transfer(
token_farm.address, dapp_token.totalSupply() - KEPT_BALANCE, {"from": account}
)
tx.wait(1)
# tokens to stake -> dapp_token, weth_token, fau_token/dai. Now lets get the address of these token. Adding them in brownie-config.
weth_token = get_contract("weth_token")
fau_token = get_contract("fau_token")
dict_of_allowed_tokens = {
dapp_token: get_contract("dai_usd_price_feed"),
fau_token: get_contract("dai_usd_price_feed"),
weth_token: get_contract("eth_usd_price_feed"),
}
add_allowed_tokens(token_farm, dict_of_allowed_tokens, account)
return token_farm, dapp_token
def add_allowed_tokens(token_farm, dict_of_allowed_tokens, account):
for token in dict_of_allowed_tokens:
add_tx = token_farm.addAllowedTokens(token.address, {"from": account})
add_tx.wait(1)
set_tx = token_farm.setPriceFeedContract(
token.address, dict_of_allowed_tokens[token], {"from": account}
)
set_tx.wait(1)
return token_farm
def main():
deploy_token_farm_and_dapp_token() |
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
Jan 10, 2022
Replies: 1 comment 7 replies
-
Hello @neerajnerlekar could you please share the following.
|
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
cromewar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @neerajnerlekar could you please share the following.
-s
identifier to get a detailed log, and share a screenshot here please.