示例#1
0
def test_pandas_output():
    # Arrange
    cf = ChainlinkFeeds(output_format='pandas')

    # Act
    result = cf.get_prices(pair='eth_usd')

    # Asset
    assert isinstance(result, pd.DataFrame)
    assert result['assetPair'][0] == 'ETH/USD'
示例#2
0
def test_load_config():
    # Arrange
    cf = ChainlinkFeeds(rpc_env_var='RPC_URL')

    # Act
    cf.load_config('./test/test_data/test_addresses_data.cfg',
                   abi_or_address='address')

    # Assert
    assert cf.get_manual_addresses(
    )['mainnet']['test_test'] == '0x0000000000000000000000000000000000000000'
示例#3
0
def test_get_latest_round_data():
    # Arrange
    network = 'kovan'
    pair = 'eth_usd'
    cf = ChainlinkFeeds(rpc_env_var='RPC_URL')

    # Act
    result = cf.get_latest_round_data(network=network, pair=pair)

    # Assert
    assert isinstance(result, dict)
示例#4
0
def test_get_historical_price():
    # Arrange
    network = 'kovan'
    pair = 'eth_usd'
    round_id = 18446744073709556747
    cf = ChainlinkFeeds(rpc_env_var='RPC_URL')

    # Act
    result = cf.get_historical_price(round_id, network=network, pair=pair)

    # Assert
    assert isinstance(result, dict)
示例#5
0
def test_get_latest_round_data_with_abi_and_address(get_test_abi, get_test_address):
    # Arrange
    network = 'kovan'
    abi = get_test_abi
    address = get_test_address
    cf = ChainlinkFeeds(rpc_env_var='RPC_URL')

    # Act
    result = cf.get_latest_round_data(
        network=network, abi=abi, address=address)

    # Assert
    assert isinstance(result, dict)
示例#6
0
def test_convert_pair_format():
    # Arrange
    unconverted_pair = 'ETH_USD'

    # Act
    converted_pair = ChainlinkFeeds.convert_pair_format(unconverted_pair)

    # Assert
    assert converted_pair == 'ETH/USD'
示例#7
0
def chainlink_feed():
    cf = ChainlinkFeeds()
    return cf