Skip to content

Commit 95515e4

Browse files
committed
Add resetNetwork method to reset local devnet cluster
1 parent bcf06b5 commit 95515e4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

hd-wallet/src/it/java/com/bloxbean/cardano/hdwallet/QuickTxBaseIT.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,31 @@ protected static void topUpFund(String address, long adaAmount) {
7979
}
8080
}
8181

82+
protected static void resetNetwork() {
83+
try {
84+
// URL to reset the network
85+
String url = DEVKIT_ADMIN_BASE_URL + "local-cluster/api/admin/devnet/reset";
86+
URL obj = new URL(url);
87+
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
88+
89+
// Set request method to POST
90+
connection.setRequestMethod("POST");
91+
connection.setRequestProperty("Content-Type", "application/json; utf-8");
92+
connection.setRequestProperty("Accept", "application/json");
93+
connection.setDoOutput(true);
94+
95+
// Check the response code
96+
int responseCode = connection.getResponseCode();
97+
if (responseCode == HttpURLConnection.HTTP_OK) {
98+
System.out.println("Funds topped up successfully.");
99+
} else {
100+
System.out.println("Failed to top up funds. Response code: " + responseCode);
101+
}
102+
} catch (Exception e) {
103+
e.printStackTrace();
104+
}
105+
}
106+
82107
public void waitForTransaction(Result<String> result) {
83108
try {
84109
if (result.isSuccessful()) { //Wait for transaction to be mined

0 commit comments

Comments
 (0)