use of com.quorum.tessera.partyinfo.model.Party in project tessera by ConsenSys.
the class ResendPartyStoreTest method failedRequestDoesntMakePartyAvailableForUseIfAtThreeshold.
@Test
public void failedRequestDoesntMakePartyAvailableForUseIfAtThreeshold() {
final int presetAttempts = 20;
final Party party = new Party("badurl.com");
final SyncableParty failedReq = new SyncableParty(party, presetAttempts);
this.resendPartyStore.incrementFailedAttempt(failedReq);
final Optional<SyncableParty> partyOne = resendPartyStore.getNextParty();
assertThat(partyOne).isNotPresent();
}
use of com.quorum.tessera.partyinfo.model.Party in project tessera by ConsenSys.
the class ResendPartyStoreTest method newPeersAreServed.
@Test
public void newPeersAreServed() {
final List<Party> peers = Arrays.asList(new Party("newurl1.com"), new Party("newurl2.com"));
this.resendPartyStore.addUnseenParties(peers);
final Optional<SyncableParty> partyOne = resendPartyStore.getNextParty();
final Optional<SyncableParty> partyTwo = resendPartyStore.getNextParty();
assertThat(partyOne).isPresent();
assertThat(partyTwo).isPresent();
assertThat(partyOne.get().getAttempts()).isEqualTo(0);
assertThat(partyTwo.get().getAttempts()).isEqualTo(0);
final List<Party> resultList = Arrays.asList(partyOne.get().getParty(), partyTwo.get().getParty());
assertThat(resultList).containsExactlyInAnyOrder(new Party("newurl1.com"), new Party("newurl2.com"));
final Optional<SyncableParty> partyThree = resendPartyStore.getNextParty();
assertThat(partyThree).isNotPresent();
}
use of com.quorum.tessera.partyinfo.model.Party in project tessera by ConsenSys.
the class SyncPollerTest method singlePartySubmitsSingleTask.
@Test
public void singlePartySubmitsSingleTask() {
final String targetUrl = "fakeurl.com";
final SyncableParty syncableParty = new SyncableParty(new Party(targetUrl), 0);
doReturn(true).when(transactionRequester).requestAllTransactionsFromNode(targetUrl);
doReturn(Optional.of(syncableParty), Optional.empty()).when(resendPartyStore).getNextParty();
syncPoller.run();
final ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(executorService).submit(captor.capture());
verify(resendPartyStore, times(2)).getNextParty();
verify(resendPartyStore).addUnseenParties(emptySet());
final Runnable task = captor.getValue();
task.run();
verify(transactionRequester).requestAllTransactionsFromNode(targetUrl);
verify(partyInfoService, times(2)).getCurrent();
verify(partyInfoParser).to(any());
verify(p2pClient).sendPartyInfo(eq(targetUrl), any());
verify(partyInfoService, times(2)).getCurrent();
}
use of com.quorum.tessera.partyinfo.model.Party in project tessera by ConsenSys.
the class SyncPollerTest method singlePartyTaskUpdatePartyInfoFailsAndNotifiesStore.
@Test
public void singlePartyTaskUpdatePartyInfoFailsAndNotifiesStore() {
final String targetUrl = "fakeurl.com";
final SyncableParty syncableParty = new SyncableParty(new Party(targetUrl), 0);
doReturn(false).when(p2pClient).sendPartyInfo(anyString(), any());
doReturn(Optional.of(syncableParty), Optional.empty()).when(resendPartyStore).getNextParty();
syncPoller.run();
final ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(executorService).submit(captor.capture());
verify(resendPartyStore, times(2)).getNextParty();
final Runnable task = captor.getValue();
task.run();
verify(transactionRequester, times(0)).requestAllTransactionsFromNode(targetUrl);
verify(resendPartyStore).incrementFailedAttempt(syncableParty);
verify(resendPartyStore).addUnseenParties(emptySet());
verify(partyInfoService, times(2)).getCurrent();
}
use of com.quorum.tessera.partyinfo.model.Party in project tessera by ConsenSys.
the class PartyInfoParserTest method multiplePartiesParses.
@Test
public void multiplePartiesParses() {
final PartyInfo result = partyInfoParser.from(dataTwo);
assertThat(result.getParties()).containsExactlyInAnyOrder(new Party("https://127.0.0.5:9005/"), new Party("https://127.0.0.3:9003/"), new Party("https://127.0.0.1:9001/"), new Party("https://127.0.0.7:9007/"), new Party("https://127.0.0.6:9006/"), new Party("https://127.0.0.4:9004/"), new Party("https://127.0.0.2:9002/"));
assertThat(result.getRecipients()).containsExactlyInAnyOrder(Recipient.of(toKey("ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="), "https://127.0.0.7:9007/"), Recipient.of(toKey("BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="), "https://127.0.0.1:9001/"), Recipient.of(toKey("QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="), "https://127.0.0.2:9002/"), Recipient.of(toKey("1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg="), "https://127.0.0.3:9003/"), Recipient.of(toKey("UfNSeSGySeKg11DVNEnqrUtxYRVor4+CvluI8tVv62Y="), "https://127.0.0.6:9006/"), Recipient.of(toKey("oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8="), "https://127.0.0.4:9004/"), Recipient.of(toKey("R56gy4dn24YOjwyesTczYa8m5xhP6hF2uTMCju/1xkY="), "https://127.0.0.5:9005/"));
}
Aggregations