-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4525 from ghubstan/2-refactor-apitest-grpcstubs
Refactor apitest for api calls to any daemon type
- Loading branch information
Showing
9 changed files
with
185 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
apitest/src/test/java/bisq/apitest/method/RegisterDisputeAgentsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.apitest.method; | ||
|
||
import bisq.proto.grpc.RegisterDisputeAgentRequest; | ||
|
||
import io.grpc.StatusRuntimeException; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
|
||
import static bisq.apitest.config.BisqAppConfig.arbdaemon; | ||
import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
import static org.junit.jupiter.api.MethodOrderer.OrderAnnotation; | ||
|
||
|
||
@SuppressWarnings("ResultOfMethodCallIgnored") | ||
@Slf4j | ||
@TestMethodOrder(OrderAnnotation.class) | ||
public class RegisterDisputeAgentsTest extends MethodTest { | ||
|
||
@BeforeAll | ||
public static void setUp() { | ||
try { | ||
setUpScaffold("bitcoind,seednode,arbdaemon"); | ||
} catch (Exception ex) { | ||
fail(ex); | ||
} | ||
} | ||
|
||
@Test | ||
@Order(1) | ||
public void testRegisterArbitratorShouldThrowException() { | ||
var req = | ||
createRegisterDisputeAgentRequest("arbitrator"); | ||
Throwable exception = assertThrows(StatusRuntimeException.class, () -> | ||
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req)); | ||
assertEquals("INVALID_ARGUMENT: arbitrators must be registered in a Bisq UI", | ||
exception.getMessage()); | ||
} | ||
|
||
@Test | ||
@Order(2) | ||
public void testInvalidDisputeAgentTypeArgShouldThrowException() { | ||
var req = | ||
createRegisterDisputeAgentRequest("badagent"); | ||
Throwable exception = assertThrows(StatusRuntimeException.class, () -> | ||
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req)); | ||
assertEquals("INVALID_ARGUMENT: unknown dispute agent type badagent", | ||
exception.getMessage()); | ||
} | ||
|
||
@Test | ||
@Order(3) | ||
public void testInvalidRegistrationKeyArgShouldThrowException() { | ||
var req = RegisterDisputeAgentRequest.newBuilder() | ||
.setDisputeAgentType("refundagent") | ||
.setRegistrationKey("invalid" + DEV_PRIVILEGE_PRIV_KEY).build(); | ||
Throwable exception = assertThrows(StatusRuntimeException.class, () -> | ||
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req)); | ||
assertEquals("INVALID_ARGUMENT: invalid registration key", | ||
exception.getMessage()); | ||
} | ||
|
||
@Test | ||
@Order(4) | ||
public void testRegisterMediator() { | ||
var req = | ||
createRegisterDisputeAgentRequest("mediator"); | ||
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req); | ||
} | ||
|
||
@Test | ||
@Order(5) | ||
public void testRegisterRefundAgent() { | ||
var req = | ||
createRegisterDisputeAgentRequest("refundagent"); | ||
grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req); | ||
} | ||
|
||
@AfterAll | ||
public static void tearDown() { | ||
tearDownScaffold(); | ||
} | ||
} |
Oops, something went wrong.