Current bitcoin-master on testnet, `maxconnections=8` in the config file. Running in VM that doesn't have public IP and is not reachable from the Internet.

Wait until you have 8 peers.

```
telnet localhost 18333
```

It will result in:

```
Assertion failed: (nMaxInbound > 0), function AcceptConnection, file net.cpp, line 973.
```

First found in https://github.com/bitcoin/bitcoin/pull/8996, but can be reproduced on master.

if (it == vSendMsg.begin())
        nOptimisticBytesWritten += SocketSendData(this);
    LEAVE_CRITICAL_SECTION(cs_vSend);
}
bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func)
{
    CNode* found = nullptr;
    LOCK(cs_vNodes);
    for (auto&& pnode : vNodes) {
        if(pnode->id == id) {
            found = pnode;
            break;
        }
    }
    return found != nullptr && func(found);
}
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) {
    return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 ) * average_interval_seconds * -1000000.0 + 0.5);
}
CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id)
{
    return CSipHasher(nSeed0, nSeed1).Write(id);
}
uint64_t CConnman::CalculateKeyedNetGroup(const CAddress& ad)
{
    std::vector<unsigned char> vchNetGroup(ad.GetGroup());
    return GetDeterministicRandomizer(RANDOMIZER_ID_NETGROUP).Write(&vchNetGroup[0], vchNetGroup.size()).Finalize();
}