Lesson 8: brownie test seems to get stuck on test_api_consumer.py #1828
              
                Unanswered
              
          
                  
                    
                      klovertexarkana
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 2 comments 13 replies
-
| Hello @klovertexarkana | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| Test script is the same script when you run "brownie bake chainlink-mix" from within your demos/mixes folder: import time
import pytest
from brownie import APIConsumer, network, config
from scripts.helpful_scripts import (
    BLOCK_CONFIRMATIONS_FOR_VERIFICATION,
    LOCAL_BLOCKCHAIN_ENVIRONMENTS,
    get_account,
    listen_for_event,
    get_contract,
    fund_with_link,
)
@pytest.fixture
def deploy_api_contract(get_job_id, chainlink_fee):
    # Arrange / Act
    api_consumer = APIConsumer.deploy(
        get_contract("oracle").address,
        get_job_id,
        chainlink_fee,
        get_contract("link_token").address,
        {"from": get_account()},
    )
    api_consumer.tx.wait(BLOCK_CONFIRMATIONS_FOR_VERIFICATION)
    # Assert
    assert api_consumer is not None
    return api_consumer
def test_send_api_request_local(
    deploy_api_contract,
    chainlink_fee,
    get_data,
):
    # Arrange
    if network.show_active() not in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        pytest.skip("Only for local testing")
    api_contract = deploy_api_contract
    get_contract("link_token").transfer(
        api_contract.address, chainlink_fee * 2, {"from": get_account()}
    )
    # Act
    transaction_receipt = api_contract.requestVolumeData({"from": get_account()})
    requestId = transaction_receipt.events["ChainlinkRequested"]["id"]
    # Assert
    get_contract("oracle").fulfillOracleRequest(
        requestId, get_data, {"from": get_account()}
    )
    assert isinstance(api_contract.volume(), int)
    assert api_contract.volume() > 0
def test_send_api_request_testnet(deploy_api_contract, chainlink_fee):
    # Arrange
    if network.show_active() not in ["kovan", "rinkeby", "goerli", "mainnet"]:
        pytest.skip("Only for testnet testing")
    api_contract = deploy_api_contract
    if config["networks"][network.show_active()].get("verify", False):
        APIConsumer.publish_source(api_contract)
    tx = fund_with_link(api_contract.address, amount=chainlink_fee)
    tx.wait(1)
    # Act
    transaction = api_contract.requestVolumeData({"from": get_account()})
    transaction.wait(1)
    # Assert
    event_response = listen_for_event(api_contract, "DataFullfilled")
    assert event_response.event is not None
    assert isinstance(api_contract.volume(), int)
    assert api_contract.volume() > 0And the command is "brownie test". Once brownie test command is executed my terminal stalls with the output I detailed in the orginal post. | 
Beta Was this translation helpful? Give feedback.
                  
                    13 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.
-
Running "brownie test", after pulling the chainlink mix from github, creates a testing session that never seems to finish. The terminal gets stuck here:
=============================test session starts======================================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/harry/Dropbox/crypto/web_dev_py/demos/mixes/chainlink
plugins: eth-brownie-1.19.1, xdist-1.34.0, hypothesis-6.27.3, web3-5.30.0, forked-1.4.0
collected 7 items
Launching 'ganache-cli --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
tests/test_api_consumer.py
Beta Was this translation helpful? Give feedback.
All reactions