golemfactory / golem-unlimited

Golem-unlimited
GNU General Public License v3.0
46 stars 8 forks source link

Peer info doesn't return tags, which ends in a deserialization error #201

Closed marmistrz closed 5 years ago

marmistrz commented 5 years ago

Indeed, http://localhost:61622/peers/0x0f871f87d8c1b73974c4e94f3ad89d665bfaf9ab doesn't have the field tags, which is a required field for PeerInfo

Looking at gu-hub/src/peer.rs, the resource returns PeerDetails instead.

prekucki commented 5 years ago

I do not have a deserialization error.

    Finished dev [unoptimized + debuginfo] target(s) in 0.20s
     Running target/debug/deps/gu_client-f884adfe81af3ec0

running 1 test
peers=[PeerInfo { node_id: 0x5512cfe2e1a7f8feb9826eeeb327bd3dc7e0ffaf, node_name: Some(""), peer_addr: "10.30.10.202:36918", tags: {} }, PeerInfo { node_id: 0xe1c9509c36860bf8a80b3288b75127328c5ad521, node_name: Some(""), peer_addr: "10.30.10.95:39444", tags: {} }, PeerInfo { node_id: 0xecc4fa58c2cdba16f47a58c82bcdd0d88cd2323d, node_name: Some(""), peer_addr: "10.30.10.218:49702", tags: {} }]
session_peers=[PeerInfo { node_id: 0x5512cfe2e1a7f8feb9826eeeb327bd3dc7e0ffaf, node_name: None, peer_addr: "", tags: {} }, PeerInfo { node_id: 0xe1c9509c36860bf8a80b3288b75127328c5ad521, node_name: None, peer_addr: "", tags: {} }, PeerInfo { node_id: 0xecc4fa58c2cdba16f47a58c82bcdd0d88cd2323d, node_name: None, peer_addr: "", tags: {} }]
test integration_tests::test_list_peers ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests gu-client

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
#[test]
fn test_list_peers() {
    let mut sys = System::new("test");

    let connection = HubConnection::default();

    let alloc_peers = connection
        .list_peers()
        .and_then(move |peers| {
            connection
                .new_session(HubSessionSpec::default())
                .and_then(move |session| Ok((connection, session, peers)))
        })
        .and_then(|(connection, session, peers)| {
            let peers: Vec<_> = peers.collect();
            session
                .add_peers(peers.clone().into_iter().map(|p| p.node_id))
                .and_then(|_| {
                    session.list_peers().and_then(|session_peers| {
                        Ok((peers, session_peers.collect::<Vec<_>>(), session))
                    })
                })
        });

    let (peers, session_peers, session) = sys.block_on(alloc_peers).unwrap();

    eprintln!("peers={:?}", peers);
    eprintln!("session_peers={:?}", session_peers);
    assert_eq!(peers.len(), session_peers.len());
}
marmistrz commented 5 years ago

@prekucki It's because you're not using Peer::info https://github.com/golemfactory/golem-unlimited/blob/master/gu-client/src/async.rs#L504'

list_peers is accessing {sessionId}/peers and Peer::info is accessing {sessionId}/peers/{nodeId}

marmistrz commented 5 years ago

@prekucki the fix has already been merged, hasn't it? I guess we can close this.

github-actions[bot] commented 5 years ago

Stale issue message