use of org.hyperledger.besu.tests.acceptance.dsl.node.Node in project besu by hyperledger.
the class AccountLocalAndOnchainPermissioningAcceptanceTest method testAccountCannotSendTxWhenNotOnOnchainAllowList.
@Test
public void testAccountCannotSendTxWhenNotOnOnchainAllowList() {
// Onchain allowlist: Primary, Secondary, Receiver
// Local allowlist: Primary, Secondary, C, Receiver
final Account receiverAccount = accounts.createAccount("Rec-A");
final Node node = permissionedNode("node1", Arrays.asList(accounts.getPrimaryBenefactor().getAddress(), accounts.getSecondaryBenefactor().getAddress(), senderC.getAddress(), receiverAccount.getAddress()));
permissionedCluster.start(node);
// ensure SenderC has got some ether available
node.execute(accountTransactions.createTransfer(senderC, 10));
node.verify(senderC.balanceEquals(10));
// add accounts to onchain allowlist
node.execute(allowAccount(accounts.getPrimaryBenefactor()));
node.verify(accountIsAllowed(accounts.getPrimaryBenefactor()));
node.execute(allowAccount(accounts.getSecondaryBenefactor()));
node.verify(accountIsAllowed(accounts.getSecondaryBenefactor()));
node.execute(allowAccount(receiverAccount));
node.verify(accountIsAllowed(receiverAccount));
// verify senderC is forbidden because it is not on Onchain allowlist
node.verify(accountIsForbidden(senderC));
// sender C should not be able to send Tx
verifyTransferForbidden(node, senderC, accounts.getSecondaryBenefactor());
// final check, other account should be able to send tx
node.execute(accountTransactions.createTransfer(accounts.getPrimaryBenefactor(), receiverAccount, 5));
node.verify(receiverAccount.balanceEquals(5));
}
use of org.hyperledger.besu.tests.acceptance.dsl.node.Node in project besu by hyperledger.
the class Cluster method start.
public void start(final List<? extends RunnableNode> nodes) {
if (nodes.isEmpty()) {
throw new IllegalArgumentException("Can't start a cluster with no nodes");
}
this.originalNodes = nodes;
this.nodes.clear();
this.bootnodes.clear();
nodes.forEach(node -> this.nodes.put(node.getName(), node));
final Optional<? extends RunnableNode> bootnode = selectAndStartBootnode(nodes);
nodes.parallelStream().filter(node -> {
LOG.info("starting non-bootnode {}", node.getName());
return bootnode.map(boot -> boot != node).orElse(true);
}).forEach(this::startNode);
if (clusterConfiguration.isAwaitPeerDiscovery()) {
for (final RunnableNode node : nodes) {
LOG.info("Awaiting peer discovery for node {}, expecting {} peers", node.getName(), nodes.size() - 1);
node.awaitPeerDiscovery(net.awaitPeerCount(nodes.size() - 1));
}
}
LOG.info("Cluster startup complete.");
}
use of org.hyperledger.besu.tests.acceptance.dsl.node.Node in project besu by hyperledger.
the class Web3JSupportAcceptanceTest method setUp.
@Before
public void setUp() throws Exception {
socketPath = Files.createTempFile("besu-test-", ".ipc");
node = besu.createNode("node1", (configurationBuilder) -> configurationBuilder.jsonRpcIpcConfiguration(new JsonRpcIpcConfiguration(true, socketPath, Collections.singletonList(RpcApis.NET.name()))));
cluster.start(node);
}
use of org.hyperledger.besu.tests.acceptance.dsl.node.Node in project besu by hyperledger.
the class AccountLocalAndOnchainPermissioningAcceptanceTest method testAccountCannotSendTxWhenNotOnLocalAllowList.
@Test
public void testAccountCannotSendTxWhenNotOnLocalAllowList() {
// Onchain allowlist: Primary, Secondary, C
// Local allowlist: Primary, Secondary
final Node node = permissionedNode("node1", Arrays.asList(accounts.getPrimaryBenefactor().getAddress(), accounts.getSecondaryBenefactor().getAddress()));
permissionedCluster.start(node);
// ensure SenderC has got some ether available
node.execute(accountTransactions.createTransfer(senderC, 10));
node.verify(senderC.balanceEquals(10));
// add accounts to onchain allowlist
node.execute(allowAccount(accounts.getPrimaryBenefactor()));
node.verify(accountIsAllowed(accounts.getPrimaryBenefactor()));
node.execute(allowAccount(accounts.getSecondaryBenefactor()));
node.verify(accountIsAllowed(accounts.getSecondaryBenefactor()));
node.execute(allowAccount(senderC));
node.verify(accountIsAllowed(senderC));
// sender C should not be able to send Tx
verifyTransferForbidden(node, senderC, accounts.getSecondaryBenefactor());
}
Aggregations