Search in sources :

Example 1 with Action

use of org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action in project besu by hyperledger.

the class PeerPermissionsAdapterTest method allowOutboundBonding_outOfSyncRemoteIsABootnode.

@Test
public void allowOutboundBonding_outOfSyncRemoteIsABootnode() {
    mockSyncStatusNodePermissioning(true, false);
    bootNodes.add(remoteNode.getEnodeURL());
    final Action action = Action.DISCOVERY_ALLOW_OUTBOUND_BONDING;
    mockControllerPermissions(true, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(true, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
}
Also used : Action(org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action) Test(org.junit.Test)

Example 2 with Action

use of org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action in project besu by hyperledger.

the class PeerPermissionsAdapterTest method allowOutboundNeighborsRequest_inSyncRemoteIsBootnode.

@Test
public void allowOutboundNeighborsRequest_inSyncRemoteIsBootnode() {
    mockSyncStatusNodePermissioning(true, true);
    bootNodes.add(remoteNode.getEnodeURL());
    final Action action = Action.DISCOVERY_ALLOW_OUTBOUND_NEIGHBORS_REQUEST;
    mockControllerPermissions(true, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(true, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
}
Also used : Action(org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action) Test(org.junit.Test)

Example 3 with Action

use of org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action in project besu by hyperledger.

the class PeerPermissionsAdapterTest method allowRemotelyInitiatedConnection.

@Test
public void allowRemotelyInitiatedConnection() {
    final Action action = Action.RLPX_ALLOW_NEW_INBOUND_CONNECTION;
    mockControllerPermissions(true, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(false, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(true, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
}
Also used : Action(org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action) Test(org.junit.Test)

Example 4 with Action

use of org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action in project besu by hyperledger.

the class PeerPermissionsAdapterTest method allowOutboundNeighborsRequest_inSyncRemoteIsNotABootnode.

@Test
public void allowOutboundNeighborsRequest_inSyncRemoteIsNotABootnode() {
    mockSyncStatusNodePermissioning(true, true);
    final Action action = Action.DISCOVERY_ALLOW_OUTBOUND_NEIGHBORS_REQUEST;
    mockControllerPermissions(true, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(true, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isTrue();
    mockControllerPermissions(false, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
}
Also used : Action(org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action) Test(org.junit.Test)

Example 5 with Action

use of org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action in project besu by hyperledger.

the class PeerPermissionsAdapterTest method allowOutboundNeighborsRequest_outOfSyncRemoteIsABootnode.

@Test
public void allowOutboundNeighborsRequest_outOfSyncRemoteIsABootnode() {
    mockSyncStatusNodePermissioning(true, false);
    bootNodes.add(remoteNode.getEnodeURL());
    final Action action = Action.DISCOVERY_ALLOW_OUTBOUND_NEIGHBORS_REQUEST;
    mockControllerPermissions(true, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(false, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(true, true);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
    mockControllerPermissions(false, false);
    assertThat(adapter.isPermitted(localNode, remoteNode, action)).isFalse();
}
Also used : Action(org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action) Test(org.junit.Test)

Aggregations

Action (org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissions.Action)18 Test (org.junit.Test)18 DefaultPeer (org.hyperledger.besu.ethereum.p2p.peers.DefaultPeer)1 Peer (org.hyperledger.besu.ethereum.p2p.peers.Peer)1