Skip to content

Instantly share code, notes, and snippets.

@sbespalov
Created August 25, 2020 08:32
Show Gist options
  • Save sbespalov/830c96f1187988894a633573f8297688 to your computer and use it in GitHub Desktop.
Save sbespalov/830c96f1187988894a633573f8297688 to your computer and use it in GitHub Desktop.
ChallengeValidationTests.aliceReachesMaximumNumberOfDirectChallenges()
@Test
public void aliceReachesMaximumNumberOfDirectChallenges()
{
for (int i = 0; i < 10; i++)
{
TestUser anotherBob = createUser();
Challenge challenge = createChessChallenge(alice.getUser(), anotherBob.getUser());
String challengeUuid = challenge.getUuid();
LOG.info("Send direct challenge: from=[{}], to=[{}], challenge=[{}:{}]", alice.getClient().getUsername(), anotherBob.getClient().getUsername(), i + 1,
challengeUuid);
verify(anotherBob.getConnectionListener(), defaultTimeout()).onConnectionEstablished(any(),any(),any());
alice.getClient().getComponentManager(ChallengeManager.class).sendChallenge(challenge);
ArgumentCaptor<Challenge> challengeCaptor = ArgumentCaptor.forClass(Challenge.class);
verify(anotherBob.getChallengeListener(), defaultTimeout()).onChallengeReceived(challengeCaptor.capture());
Challenge receivedChallenge = challengeCaptor.getValue();
System.out.println(receivedChallenge);
//assertEquals(challengeUuid, receivedChallenge.getUuid());
}
TestUser anotherBob = createUser();
Challenge challenge = createChessChallenge(alice.getUser(), anotherBob.getUser());
alice.getClient().getComponentManager(ChallengeManager.class).sendChallenge(challenge);
verify(alice.getChallengeListener(), defaultTimeout()).onChallengeFailed(any(), eq(CodeMessage.ChallengeTooManySeeks));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment