Search in sources :

Example 11 with Party

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();
}
Also used : Party(com.quorum.tessera.partyinfo.model.Party) Test(org.junit.Test)

Example 12 with Party

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();
}
Also used : Party(com.quorum.tessera.partyinfo.model.Party) Test(org.junit.Test)

Example 13 with Party

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();
}
Also used : Party(com.quorum.tessera.partyinfo.model.Party) Test(org.junit.Test)

Example 14 with Party

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();
}
Also used : Party(com.quorum.tessera.partyinfo.model.Party) Test(org.junit.Test)

Example 15 with Party

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/"));
}
Also used : Party(com.quorum.tessera.partyinfo.model.Party) PartyInfo(com.quorum.tessera.partyinfo.model.PartyInfo) Test(org.junit.Test)

Aggregations

Party (com.quorum.tessera.partyinfo.model.Party)17 Test (org.junit.Test)13 PartyInfo (com.quorum.tessera.partyinfo.model.PartyInfo)7 Recipient (com.quorum.tessera.partyinfo.model.Recipient)5 NodeInfo (com.quorum.tessera.partyinfo.node.NodeInfo)5 PublicKey (com.quorum.tessera.encryption.PublicKey)4 Discovery (com.quorum.tessera.discovery.Discovery)3 PartyInfoParser (com.quorum.tessera.p2p.partyinfo.PartyInfoParser)3 Entity (jakarta.ws.rs.client.Entity)3 Response (jakarta.ws.rs.core.Response)3 NodeUri (com.quorum.tessera.discovery.NodeUri)2 com.quorum.tessera.enclave (com.quorum.tessera.enclave)2 GetPartyInfoResponse (com.quorum.tessera.p2p.model.GetPartyInfoResponse)2 PartyStore (com.quorum.tessera.p2p.partyinfo.PartyStore)2 NodeInfoUtil (com.quorum.tessera.partyinfo.model.NodeInfoUtil)2 Constants (com.quorum.tessera.shared.Constants)2 Operation (io.swagger.v3.oas.annotations.Operation)2 Parameter (io.swagger.v3.oas.annotations.Parameter)2 ArraySchema (io.swagger.v3.oas.annotations.media.ArraySchema)2 Content (io.swagger.v3.oas.annotations.media.Content)2