private void NetworkConnectionStable() { NetworkConnectionSchema connectionSchema = null; var apiInstance = new DefaultApi(nodeAddress); var connections = apiInstance.NetworkConnections(); Assert.Empty(connections.Connections); var err404 = Assert.Throws <ApiException>(() => connectionSchema = apiInstance.NetworkConnection("127.0.0.1:4444")); Assert.Equal(404, err404.ErrorCode); Assert.Equal("Error calling NetworkConnection: 404 Not Found\n", err404.Message); Assert.Null(connectionSchema); }
private void NetworkConnectionLive() { var apiInstance = new DefaultApi(nodeAddress); var connections = apiInstance.NetworkConnections(); if (liveDisableNetworking) { Assert.Empty(connections.Connections); return; } Assert.NotEmpty(connections.Connections); var check = false; connections.Connections.ForEach(cc => { NetworkConnectionSchema connection = null; try { connection = apiInstance.NetworkConnection(cc.Address); } catch (ApiException err) { if (err.ErrorCode == 404 || err.Message == "Error calling NetworkConnection: 404 Not Found\n") { return; } } Assert.NotNull(cc.Address); Assert.Equal(cc.Address, connection?.Address); Assert.Equal(cc.Id, connection?.Id); Assert.Equal(cc.ListenPort, connection?.ListenPort); Assert.Equal(cc.Mirror, connection?.Mirror); switch (cc.State) { case NetworkConnectionSchema.StateEnum.Introduced: Assert.Equal(NetworkConnectionSchema.StateEnum.Introduced, connection?.State); break; case NetworkConnectionSchema.StateEnum.Connected: Assert.NotEqual(NetworkConnectionSchema.StateEnum.Pending, connection?.State); break; } if (cc.State == NetworkConnectionSchema.StateEnum.Pending) { Assert.Equal(0, cc.Id); } else { Assert.NotEqual(0, cc.Id); } Assert.Equal(cc.Outgoing, connection?.Outgoing); Assert.True(cc.LastReceived <= connection?.LastReceived); Assert.True(cc.LastSent <= connection.LastSent); Assert.Equal(cc.ConnectedAt, connection.ConnectedAt); check = true; }); Assert.True(check, "Was not able to find any connection by address, despite finding connections when querying all"); connections = apiInstance.NetworkConnections(states: "pending"); connections.Connections.ForEach( cc => { Assert.Equal(NetworkConnectionSchema.StateEnum.Pending, cc.State); }); connections = apiInstance.NetworkConnections(direction: "incoming"); connections.Connections.ForEach(cc => { Assert.False(cc.Outgoing); }); }