Beispiel #1
0
def test_initialise_aea():
    """Tests the initialisation of the AEA."""
    node = LocalNode()
    private_key_path = os.path.join(CUR_PATH, "data", "fet_private_key.txt")
    wallet = Wallet({FETCHAI: private_key_path})
    identity = Identity("my_name", address=wallet.addresses[FETCHAI])
    connections1 = [
        OEFLocalConnection(identity.address,
                           node,
                           connection_id=OEFLocalConnection.connection_id)
    ]
    ledger_apis = LedgerApis({}, FETCHAI)
    my_AEA = AEA(
        identity,
        connections1,
        wallet,
        ledger_apis,
        resources=Resources(str(Path(CUR_PATH, "aea"))),
    )
    assert my_AEA.context == my_AEA._context, "Cannot access the Agent's Context"
    assert (not my_AEA.context.connection_status.is_connected
            ), "AEA should not be connected."
    my_AEA.setup()
    assert my_AEA.resources is not None, "Resources must not be None after setup"
    my_AEA.resources = Resources(str(Path(CUR_PATH, "aea")))
    assert my_AEA.resources is not None, "Resources must not be None after set"
    assert (my_AEA.context.shared_state
            is not None), "Shared state must not be None after set"
    assert my_AEA.context.task_manager is not None
    assert my_AEA.context.identity is not None, "Identity must not be None after set."
    my_AEA.stop()
Beispiel #2
0
def test_initialise_AEA():
    """Tests the initialisation of the AEA."""
    node = LocalNode()
    public_key_1 = "public_key"
    connections1 = [OEFLocalConnection(public_key_1, node)]
    private_key_pem_path = os.path.join(CUR_PATH, "data", "priv.pem")
    wallet = Wallet({'default': private_key_pem_path})
    ledger_apis = LedgerApis({})
    my_AEA = AEA("Agent0", connections1, wallet, ledger_apis, resources=Resources(str(Path(CUR_PATH, "aea"))))
    assert my_AEA.context == my_AEA._context, "Cannot access the Agent's Context"
    assert not my_AEA.context.connection_status.is_connected, "AEA should not be connected."
    my_AEA.setup()
    assert my_AEA.resources is not None,\
        "Resources must not be None after setup"
    my_AEA.resources = Resources(str(Path(CUR_PATH, "aea")))
    assert my_AEA.resources is not None,\
        "Resources must not be None after set"