Search in sources :

Example 1 with EvictResult

use of org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult in project besu by hyperledger.

the class PeerTableTest method evictPeerFromEmptyTableShouldNotEvict.

@Test
public void evictPeerFromEmptyTableShouldNotEvict() {
    final PeerTable table = new PeerTable(Peer.randomId(), 16);
    final DiscoveryPeer peer = helper.createDiscoveryPeer();
    final EvictResult evictResult = table.tryEvict(peer);
    assertThat(evictResult.getOutcome()).isEqualTo(EvictOutcome.ABSENT);
}
Also used : DiscoveryPeer(org.hyperledger.besu.ethereum.p2p.discovery.DiscoveryPeer) EvictResult(org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult) Test(org.junit.Test)

Example 2 with EvictResult

use of org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult in project besu by hyperledger.

the class PeerTableTest method evictAbsentPeerShouldNotEvict.

@Test
public void evictAbsentPeerShouldNotEvict() {
    final PeerTable table = new PeerTable(Peer.randomId(), 16);
    final DiscoveryPeer peer = helper.createDiscoveryPeer();
    final List<DiscoveryPeer> otherPeers = helper.createDiscoveryPeers(5);
    otherPeers.forEach(table::tryAdd);
    final EvictResult evictResult = table.tryEvict(peer);
    assertThat(evictResult.getOutcome()).isEqualTo(EvictOutcome.ABSENT);
}
Also used : DiscoveryPeer(org.hyperledger.besu.ethereum.p2p.discovery.DiscoveryPeer) EvictResult(org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult) Test(org.junit.Test)

Example 3 with EvictResult

use of org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult in project besu by hyperledger.

the class PeerTableTest method evictSelfPeerShouldReturnSelfOutcome.

@Test
public void evictSelfPeerShouldReturnSelfOutcome() {
    final DiscoveryPeer peer = helper.createDiscoveryPeer();
    final PeerTable table = new PeerTable(peer.getId(), 16);
    final EvictResult evictResult = table.tryEvict(peer);
    assertThat(evictResult.getOutcome()).isEqualTo(EvictOutcome.SELF);
}
Also used : DiscoveryPeer(org.hyperledger.besu.ethereum.p2p.discovery.DiscoveryPeer) EvictResult(org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult) Test(org.junit.Test)

Example 4 with EvictResult

use of org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult in project besu by hyperledger.

the class PeerTableTest method evictExistingPeerShouldEvict.

@Test
public void evictExistingPeerShouldEvict() {
    final PeerTable table = new PeerTable(Peer.randomId(), 16);
    final DiscoveryPeer peer = helper.createDiscoveryPeer();
    table.tryAdd(peer);
    final EvictResult evictResult = table.tryEvict(peer);
    assertThat(evictResult.getOutcome()).isEqualTo(EvictOutcome.EVICTED);
}
Also used : DiscoveryPeer(org.hyperledger.besu.ethereum.p2p.discovery.DiscoveryPeer) EvictResult(org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult) Test(org.junit.Test)

Aggregations

DiscoveryPeer (org.hyperledger.besu.ethereum.p2p.discovery.DiscoveryPeer)4 EvictResult (org.hyperledger.besu.ethereum.p2p.discovery.internal.PeerTable.EvictResult)4 Test (org.junit.Test)4