Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing timer in unlockwallet(pwd, timeout) #4558

Closed
wants to merge 15 commits into from
Closed
11 changes: 10 additions & 1 deletion apitest/src/test/java/bisq/apitest/method/MethodTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import bisq.proto.grpc.UnlockWalletRequest;

import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.MEDIATOR;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.REFUNDAGENT;



Expand Down Expand Up @@ -66,7 +68,7 @@ protected final GetFundingAddressesRequest createGetFundingAddressesRequest() {

protected final RegisterDisputeAgentRequest createRegisterDisputeAgentRequest(String disputeAgentType) {
return RegisterDisputeAgentRequest.newBuilder()
.setDisputeAgentType(disputeAgentType)
.setDisputeAgentType(disputeAgentType.toLowerCase())
.setRegistrationKey(DEV_PRIVILEGE_PRIV_KEY).build();
}

Expand Down Expand Up @@ -96,4 +98,11 @@ protected final String getUnusedBtcAddress(BisqAppConfig bisqAppConfig) {
.get()
.getAddress();
}

@SuppressWarnings("ResultOfMethodCallIgnored")
protected final void registerDisputeAgents(BisqAppConfig bisqAppConfig) {
var disputeAgentsService = grpcStubs(bisqAppConfig).disputeAgentsService;
disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(MEDIATOR.name()));
disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(REFUNDAGENT.name()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import static bisq.apitest.config.BisqAppConfig.arbdaemon;
import static bisq.apitest.config.BisqAppConfig.seednode;
import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.ARBITRATOR;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.MEDIATOR;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.REFUNDAGENT;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
Expand All @@ -44,10 +47,6 @@
@TestMethodOrder(OrderAnnotation.class)
public class RegisterDisputeAgentsTest extends MethodTest {

private static final String ARBITRATOR = "arbitrator";
private static final String MEDIATOR = "mediator";
private static final String REFUNDAGENT = "refundagent";

@BeforeAll
public static void setUp() {
try {
Expand All @@ -61,7 +60,7 @@ public static void setUp() {
@Order(1)
public void testRegisterArbitratorShouldThrowException() {
var req =
createRegisterDisputeAgentRequest(ARBITRATOR);
createRegisterDisputeAgentRequest(ARBITRATOR.name());
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req));
assertEquals("INVALID_ARGUMENT: arbitrators must be registered in a Bisq UI",
Expand All @@ -83,7 +82,7 @@ public void testInvalidDisputeAgentTypeArgShouldThrowException() {
@Order(3)
public void testInvalidRegistrationKeyArgShouldThrowException() {
var req = RegisterDisputeAgentRequest.newBuilder()
.setDisputeAgentType(REFUNDAGENT)
.setDisputeAgentType(REFUNDAGENT.name().toLowerCase())
.setRegistrationKey("invalid" + DEV_PRIVILEGE_PRIV_KEY).build();
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req));
Expand All @@ -95,15 +94,15 @@ public void testInvalidRegistrationKeyArgShouldThrowException() {
@Order(4)
public void testRegisterMediator() {
var req =
createRegisterDisputeAgentRequest(MEDIATOR);
createRegisterDisputeAgentRequest(MEDIATOR.name());
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req);
}

@Test
@Order(5)
public void testRegisterRefundAgent() {
var req =
createRegisterDisputeAgentRequest(REFUNDAGENT);
createRegisterDisputeAgentRequest(REFUNDAGENT.name());
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
public abstract class DisputeAgent implements ProtectedStoragePayload, ExpirablePayload {
public static final long TTL = TimeUnit.DAYS.toMillis(10);

public enum DisputeAgentType {
ARBITRATOR,
MEDIATOR,
REFUNDAGENT
ghubstan marked this conversation as resolved.
Show resolved Hide resolved
}

protected final NodeAddress nodeAddress;
protected final PubKeyRing pubKeyRing;
protected final List<String> languageCodes;
Expand Down