Exemple #1
0
def test_initialisation():
    """Test the initialisation of the ledger APIs."""
    ledger_apis = LedgerApis
    assert ledger_apis.has_ledger(FetchAIApi.identifier)
    assert type(LedgerApis.get_api(FetchAIApi.identifier)) == FetchAIApi
    assert LedgerApis.has_ledger(EthereumApi.identifier)
    assert type(LedgerApis.get_api(EthereumApi.identifier)) == EthereumApi
    assert LedgerApis.has_ledger(CosmosApi.identifier)
    assert type(LedgerApis.get_api(CosmosApi.identifier)) == CosmosApi
    with pytest.raises(AEAEnforceError):
        ledger_apis.get_api("UNKNOWN")
def test_initialisation():
    """Test the initialisation of the ledger APIs."""
    ledger_apis = LedgerApis(
        {
            EthereumApi.identifier: ETHEREUM_TESTNET_CONFIG,
            FetchAIApi.identifier: FETCHAI_TESTNET_CONFIG,
            CosmosApi.identifier: COSMOS_TESTNET_CONFIG,
        },
        FetchAIApi.identifier,
    )
    assert ledger_apis.configs.get(
        EthereumApi.identifier) == ETHEREUM_TESTNET_CONFIG
    assert ledger_apis.has_ledger(FetchAIApi.identifier)
    assert type(ledger_apis.get_api(FetchAIApi.identifier)) == FetchAIApi
    assert ledger_apis.has_ledger(EthereumApi.identifier)
    assert type(ledger_apis.get_api(EthereumApi.identifier)) == EthereumApi
    assert ledger_apis.has_ledger(CosmosApi.identifier)
    assert type(ledger_apis.get_api(CosmosApi.identifier)) == CosmosApi
    unknown_config = {"UnknownPath": 8080}
    with pytest.raises(AEAException):
        LedgerApis({"UNKNOWN": unknown_config}, FetchAIApi.identifier)