Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Enhance integration tests to do multiple account create/lookups to crash the server. #10

Closed
wants to merge 1 commit into from
Closed
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 @@ -41,6 +41,34 @@ public class IntegrationTest {
account2.setCode(2);
}

private static Account[] randomAccounts(int num) {

var accounts = new Account[num];

for (int i = 0; i < accounts.length; i++) {
var account = new Account();
account.setId(UUID.randomUUID());
account.setUserData(UUID.randomUUID());
account.setLedger(720);
account.setCode(1);

accounts[i] = account;
}

return accounts;
}

private static UUID[] accountsToUuids(Account[] accounts) {

var uuids = new UUID[accounts.length];

for (int i = 0; i < accounts.length; i++) {
uuids[i] = accounts[i].getId();
}

return uuids;
}

@Test(expected = NullPointerException.class)
public void testConstructorNullReplicaAddresses() throws Throwable {

Expand Down Expand Up @@ -124,14 +152,21 @@ public void testCreateAccountsArray() throws Throwable {
try (var server = new Server()) {
try (var client = new Client(0, new String[] {Server.TB_PORT})) {

var errors = client.createAccounts(new Account[] {account1, account2});
assertTrue(errors.length == 0);
final int numTries = 10;
final int numAccounts = 1;

var lookupAccounts =
client.lookupAccounts(new UUID[] {account1.getId(), account2.getId()});
assertAccounts(account1, lookupAccounts[0]);
assertAccounts(account2, lookupAccounts[1]);
for (int onTry = 0; onTry < numTries; onTry++) {
final var accounts = randomAccounts(numAccounts);
final var ids = accountsToUuids(accounts);

final var errors = client.createAccounts(accounts);
assertTrue(errors.length == 0);

final var lookupAccounts = client.lookupAccounts(ids);
for (int i = 0; i < accounts.length; i++) {
assertAccounts(accounts[i], lookupAccounts[i]);
}
}
} catch (Throwable any) {
throw any;
}
Expand Down