Fixed yet another test

This commit is contained in:
Christian Basler 2016-05-10 07:26:25 +02:00
parent 05d9ea93d2
commit a67ac27921
3 changed files with 5 additions and 5 deletions

View File

@ -69,7 +69,7 @@ public class BitmessageContext {
private BitmessageContext(Builder builder) {
ctx = new InternalContext(builder);
labeler = builder.labeler;
ctx.getProofOfWorkService().doMissingProofOfWork();
ctx.getProofOfWorkService().doMissingProofOfWork(30_000); // TODO: this should be configurable
networkListener = new DefaultMessageListener(ctx, labeler, builder.listener);
sendPubkeyOnIdentityCreation = builder.sendPubkeyOnIdentityCreation;

View File

@ -30,7 +30,7 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
private ProofOfWorkRepository powRepo;
private MessageRepository messageRepo;
public void doMissingProofOfWork() {
public void doMissingProofOfWork(long delayInMilliseconds) {
final List<byte[]> items = powRepo.getItems();
if (items.isEmpty()) return;
@ -45,7 +45,7 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
ProofOfWorkService.this);
}
}
}, 30_000);
}, delayInMilliseconds);
}
public void doProofOfWork(ObjectMessage object) {

View File

@ -77,9 +77,9 @@ public class ProofOfWorkServiceTest {
when(proofOfWorkRepo.getItem(any(byte[].class))).thenReturn(new ProofOfWorkRepository.Item(null, 1001, 1002));
doNothing().when(cryptography).doProofOfWork(any(ObjectMessage.class), anyLong(), anyLong(), any(ProofOfWorkEngine.Callback.class));
proofOfWorkService.doMissingProofOfWork();
proofOfWorkService.doMissingProofOfWork(10);
verify(cryptography).doProofOfWork((ObjectMessage) isNull(), eq(1001L), eq(1002L),
verify(cryptography, timeout(1000)).doProofOfWork((ObjectMessage) isNull(), eq(1001L), eq(1002L),
any(ProofOfWorkEngine.Callback.class));
}