start testing MyProposalListService.

This commit is contained in:
Christoph Sturm 2019-08-13 12:08:23 +02:00
parent d62d440068
commit ac6068b728
4 changed files with 39 additions and 4 deletions

View file

@ -42,7 +42,7 @@ import javax.annotation.Nullable;
@Slf4j @Slf4j
@EqualsAndHashCode @EqualsAndHashCode
@Getter @Getter
public final class PubKeyRing implements NetworkPayload, UsedForTradeContractJson { public class PubKeyRing implements NetworkPayload, UsedForTradeContractJson {
private final byte[] signaturePubKeyBytes; private final byte[] signaturePubKeyBytes;
private final byte[] encryptionPubKeyBytes; private final byte[] encryptionPubKeyBytes;
@Nullable @Nullable

View file

@ -32,7 +32,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@Slf4j @Slf4j
public final class PeriodService { public class PeriodService {
private final DaoStateService daoStateService; private final DaoStateService daoStateService;

View file

@ -239,8 +239,8 @@ public class MyProposalListService implements PersistedDataHost, DaoStateListene
} }
private boolean canRemoveProposal(Proposal proposal, DaoStateService daoStateService, PeriodService periodService) { private boolean canRemoveProposal(Proposal proposal, DaoStateService daoStateService, PeriodService periodService) {
boolean inPhase = periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.PROPOSAL); boolean inProposalPhase = periodService.isInPhase(daoStateService.getChainHeight(), DaoPhase.Phase.PROPOSAL);
return isMine(proposal) && inPhase; return isMine(proposal) && inProposalPhase;
} }
} }

View file

@ -0,0 +1,35 @@
package bisq.core.dao.governance.proposal;
import bisq.core.btc.wallet.WalletsManager;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.state.DaoStateService;
import bisq.network.p2p.P2PService;
import bisq.common.crypto.KeyRing;
import bisq.common.crypto.PubKeyRing;
import bisq.common.storage.Storage;
import javafx.beans.property.SimpleIntegerProperty;
import org.junit.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class MyProposalListServiceTest {
@Test
public void canInstantiate() {
KeyRing keyring = mock(KeyRing.class);
when(keyring.getPubKeyRing()).thenReturn(mock(PubKeyRing.class));
P2PService p2PService = mock(P2PService.class);
when(p2PService.getNumConnectedPeers()).thenReturn(new SimpleIntegerProperty(0));
Storage storage = mock(Storage.class);
MyProposalListService service = new MyProposalListService(p2PService,
mock(DaoStateService.class),
mock(PeriodService.class), mock(WalletsManager.class), storage, keyring
);
}
}