From a67ac27921fa89545109d61e42e42a27af7ea62b Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Tue, 10 May 2016 07:26:25 +0200 Subject: [PATCH] Fixed yet another test --- .../src/main/java/ch/dissem/bitmessage/BitmessageContext.java | 2 +- .../main/java/ch/dissem/bitmessage/ProofOfWorkService.java | 4 ++-- .../java/ch/dissem/bitmessage/ProofOfWorkServiceTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/ch/dissem/bitmessage/BitmessageContext.java b/core/src/main/java/ch/dissem/bitmessage/BitmessageContext.java index 2307958..aef6a67 100644 --- a/core/src/main/java/ch/dissem/bitmessage/BitmessageContext.java +++ b/core/src/main/java/ch/dissem/bitmessage/BitmessageContext.java @@ -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; diff --git a/core/src/main/java/ch/dissem/bitmessage/ProofOfWorkService.java b/core/src/main/java/ch/dissem/bitmessage/ProofOfWorkService.java index d242b79..04016b5 100644 --- a/core/src/main/java/ch/dissem/bitmessage/ProofOfWorkService.java +++ b/core/src/main/java/ch/dissem/bitmessage/ProofOfWorkService.java @@ -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 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) { diff --git a/core/src/test/java/ch/dissem/bitmessage/ProofOfWorkServiceTest.java b/core/src/test/java/ch/dissem/bitmessage/ProofOfWorkServiceTest.java index fa58cfe..c4529e3 100644 --- a/core/src/test/java/ch/dissem/bitmessage/ProofOfWorkServiceTest.java +++ b/core/src/test/java/ch/dissem/bitmessage/ProofOfWorkServiceTest.java @@ -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)); }