Search in sources :

Example 1 with NodesAllowlistResult

use of org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult in project besu by hyperledger.

the class NodeLocalConfigPermissioningControllerTest method whenAddNodesInputHasExistingNodeShouldReturnAddErrorExistingEntry.

@Test
public void whenAddNodesInputHasExistingNodeShouldReturnAddErrorExistingEntry() {
    controller.addNodes(Arrays.asList(enode1));
    NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.ERROR_EXISTING_ENTRY);
    NodesAllowlistResult actualResult = controller.addNodes(Lists.newArrayList(enode1, enode2));
    assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
}
Also used : NodesAllowlistResult(org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult) Test(org.junit.Test)

Example 2 with NodesAllowlistResult

use of org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult in project besu by hyperledger.

the class NodeLocalConfigPermissioningControllerTest method whenAddNodesInputHasDuplicatedNodesShouldReturnDuplicatedEntryError.

@Test
public void whenAddNodesInputHasDuplicatedNodesShouldReturnDuplicatedEntryError() {
    NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.ERROR_DUPLICATED_ENTRY);
    NodesAllowlistResult actualResult = controller.addNodes(Arrays.asList(enode1, enode1));
    assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
}
Also used : NodesAllowlistResult(org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult) Test(org.junit.Test)

Example 3 with NodesAllowlistResult

use of org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult in project besu by hyperledger.

the class NodeLocalConfigPermissioningControllerTest method whenRemoveNodesInputHasAbsentNodeShouldReturnRemoveErrorAbsentEntry.

@Test
public void whenRemoveNodesInputHasAbsentNodeShouldReturnRemoveErrorAbsentEntry() {
    NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.ERROR_ABSENT_ENTRY);
    NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1, enode2));
    assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
}
Also used : NodesAllowlistResult(org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult) Test(org.junit.Test)

Example 4 with NodesAllowlistResult

use of org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult in project besu by hyperledger.

the class NodeLocalConfigPermissioningControllerTest method whenRemoveNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry.

@Test
public void whenRemoveNodesInputHasEmptyListOfNodesShouldReturnErrorEmptyEntry() {
    NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.ERROR_EMPTY_ENTRY);
    NodesAllowlistResult actualResult = controller.removeNodes(new ArrayList<>());
    assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
}
Also used : NodesAllowlistResult(org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult) Test(org.junit.Test)

Example 5 with NodesAllowlistResult

use of org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult in project besu by hyperledger.

the class NodeLocalConfigPermissioningControllerTest method whenRemovingBootnodeShouldReturnRemoveBootnodeError.

@Test
public void whenRemovingBootnodeShouldReturnRemoveBootnodeError() {
    NodesAllowlistResult expected = new NodesAllowlistResult(AllowlistOperationResult.ERROR_FIXED_NODE_CANNOT_BE_REMOVED);
    bootnodesList.add(EnodeURLImpl.fromString(enode1));
    controller.addNodes(Lists.newArrayList(enode1, enode2));
    NodesAllowlistResult actualResult = controller.removeNodes(Lists.newArrayList(enode1));
    assertThat(actualResult).isEqualToComparingOnlyGivenFields(expected, "result");
    assertThat(controller.getNodesAllowlist()).containsExactly(enode1, enode2);
}
Also used : NodesAllowlistResult(org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult) Test(org.junit.Test)

Aggregations

NodesAllowlistResult (org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController.NodesAllowlistResult)34 Test (org.junit.Test)32 JsonRpcRequestContext (org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext)22 JsonRpcResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse)22 JsonRpcErrorResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse)16 JsonRpcSuccessResponse (org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse)10 ArrayList (java.util.ArrayList)4 StringListParameter (org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.StringListParameter)2 P2PDisabledException (org.hyperledger.besu.ethereum.p2p.network.exceptions.P2PDisabledException)2