@@ -0,0 +1,3457 @@
+/*%0A * This file is part of Bisq.%0A *%0A * Bisq is free software: you can redistribute it and/or modify it%0A * under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or (at%0A * your option) any later version.%0A *%0A * Bisq is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or%0A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public%0A * License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with Bisq. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage bisq.network.p2p;%0A%0Aimport bisq.core.network.p2p.seed.DefaultSeedNodeRepository;%0A%0Aimport bisq.network.p2p.network.Connection;%0Aimport bisq.network.p2p.network.InboundConnection;%0Aimport bisq.network.p2p.network.NetworkNode;%0Aimport bisq.network.p2p.network.OutboundConnection;%0Aimport bisq.network.p2p.network.Statistic;%0Aimport bisq.network.p2p.peers.PeerManager;%0Aimport bisq.network.p2p.peers.peerexchange.PeerList;%0A%0Aimport bisq.common.ClockWatcher;%0Aimport bisq.common.proto.persistable.PersistenceProtoResolver;%0Aimport bisq.common.storage.CorruptedDatabaseFilesHandler;%0Aimport bisq.common.storage.Storage;%0A%0Aimport java.io.File;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport lombok.Getter;%0A%0Aimport static org.mockito.Mockito.doNothing;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class MockNode %7B%0A    @Getter%0A    public NetworkNode networkNode;%0A    @Getter%0A    public PeerManager peerManager;%0A    @Getter%0A    public Set%3CConnection%3E connections;%0A    @Getter%0A    public int maxConnections;%0A%0A    public MockNode(int maxConnections) %7B%0A        this.maxConnections = maxConnections;%0A        networkNode = mock(NetworkNode.class);%0A        Storage%3CPeerList%3E storage = new Storage%3C%3E(mock(File.class), mock(PersistenceProtoResolver.class), mock(CorruptedDatabaseFilesHandler.class));%0A        peerManager = new PeerManager(networkNode, mock(DefaultSeedNodeRepository.class), new ClockWatcher(), maxConnections, storage);%0A        connections = new HashSet%3C%3E();%0A        when(networkNode.getAllConnections()).thenReturn(connections);%0A    %7D%0A%0A    public void addInboundConnection(Connection.PeerType peerType) %7B%0A        InboundConnection inboundConnection = mock(InboundConnection.class);%0A        when(inboundConnection.getPeerType()).thenReturn(peerType);%0A        Statistic statistic = mock(Statistic.class);%0A        long lastActivityTimestamp = System.currentTimeMillis();%0A        when(statistic.getLastActivityTimestamp()).thenReturn(lastActivityTimestamp);%0A        when(inboundConnection.getStatistic()).thenReturn(statistic);%0A        doNothing().when(inboundConnection).run();%0A        connections.add(inboundConnection);%0A    %7D%0A%0A    public void addOutboundConnection(Connection.PeerType peerType) %7B%0A        OutboundConnection outboundConnection = mock(OutboundConnection.class);%0A        when(outboundConnection.getPeerType()).thenReturn(peerType);%0A        Statistic statistic = mock(Statistic.class);%0A        long lastActivityTimestamp = System.currentTimeMillis();%0A        when(statistic.getLastActivityTimestamp()).thenReturn(lastActivityTimestamp);%0A        when(outboundConnection.getStatistic()).thenReturn(statistic);%0A        doNothing().when(outboundConnection).run();%0A        connections.add(outboundConnection);%0A    %7D%0A%7D%0A

Add MockNode that allows for simulating connections