Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PIE-1593] Fix for permissioned network with single bootnode #1479

Merged
merged 3 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.junit.Before;
import org.junit.Test;

public class NodeNodeSmartContractNodePermissioningAcceptanceTest
extends NodeSmartContractNodePermissioningAcceptanceTestBase {
public class NodeSmartContractPermissioningAcceptanceTest
extends NodeSmartContractPermissioningAcceptanceTestBase {

private Node bootnode;
private Node permissionedNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import java.io.IOException;

class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTestBase {
class NodeSmartContractPermissioningAcceptanceTestBase extends AcceptanceTestBase {

private final NodeSmartContractPermissioningTransactions smartContractNodePermissioning;
private final NodeSmartContractPermissioningConditions nodeSmartContractPermissioningConditions;
Expand All @@ -35,7 +35,7 @@ class NodeSmartContractNodePermissioningAcceptanceTestBase extends AcceptanceTes

protected final Cluster permissionedCluster;

protected NodeSmartContractNodePermissioningAcceptanceTestBase() {
protected NodeSmartContractPermissioningAcceptanceTestBase() {
super();
smartContractNodePermissioning = new NodeSmartContractPermissioningTransactions(accounts);
nodeSmartContractPermissioningConditions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public NodePermissioningController create(
providers.add(smartContractProvider);
}

final SyncStatusNodePermissioningProvider syncStatusProvider =
new SyncStatusNodePermissioningProvider(synchronizer, fixedNodes);
syncStatusProviderOptional = Optional.of(syncStatusProvider);
if (fixedNodes.isEmpty()) {
syncStatusProviderOptional = Optional.empty();
} else {
syncStatusProviderOptional =
Optional.of(new SyncStatusNodePermissioningProvider(synchronizer, fixedNodes));
}
} else {
syncStatusProviderOptional = Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testCreateWithSmartContractNodePermissioningEnabledOnly() {

NodePermissioningProvider p1 = providers.get(0);
assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class);
assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent();
assertThat(controller.getSyncStatusNodePermissioningProvider()).isEmpty();
}

@Test
Expand Down Expand Up @@ -137,6 +137,26 @@ public void testCreateWithLocalNodeAndSmartContractPermissioningEnabled() {
assertThat(p2).isInstanceOf(NodeLocalConfigPermissioningController.class);
assertThat(p1).isInstanceOf(NodeSmartContractPermissioningController.class);
}
assertThat(controller.getSyncStatusNodePermissioningProvider()).isEmpty();
}

@Test
public void testCreateWithSmartContractNodePermissioningEnabledOnlyAndBootnode() {
final Collection<EnodeURL> fixedNodes = Collections.singleton(selfEnode);

smartContractPermissioningConfiguration = new SmartContractPermissioningConfiguration();
smartContractPermissioningConfiguration.setNodeSmartContractAddress(
Address.fromHexString("0x0000000000000000000000000000000000001234"));
smartContractPermissioningConfiguration.setSmartContractNodeWhitelistEnabled(true);
config =
new PermissioningConfiguration(
Optional.empty(), Optional.of(smartContractPermissioningConfiguration));

NodePermissioningControllerFactory factory = new NodePermissioningControllerFactory();
NodePermissioningController controller =
factory.create(
config, synchronizer, fixedNodes, selfEnode.getNodeId(), transactionSimulator);

assertThat(controller.getSyncStatusNodePermissioningProvider()).isPresent();
}
}