1- /*
2- * This Kotlin source file was generated by the Gradle 'init' task.
3- */
41package org.lightningdevkit.ldknode
52
63import kotlin.UInt
@@ -11,6 +8,8 @@ import java.net.URI
118import java.net.http.HttpClient
129import java.net.http.HttpRequest
1310import java.net.http.HttpResponse
11+ import kotlin.io.path.createTempDirectory
12+ import kotlin.test.assertEquals
1413
1514fun runCommandAndWait (vararg cmd : String ): String {
1615 println (" Running command \" ${cmd.joinToString(" " )} \" " )
@@ -29,7 +28,7 @@ fun mine(blocks: UInt): String {
2928 val output = runCommandAndWait(" bitcoin-cli" , " -regtest" , " generatetoaddress" , blocks.toString(), address)
3029 println (" Mining output: $output " )
3130 val re = Regex (" \n .+\n\\ ]$" )
32- val lastBlock = re.find(output)!! .value.replace(" ]" ," " ).replace(" \" " , " " ).replace(" \n " ," " ).trim()
31+ val lastBlock = re.find(output)!! .value.replace(" ]" , " " ).replace(" \" " , " " ).replace(" \n " , " " ).trim()
3332 println (" Last block: $lastBlock " )
3433 return lastBlock
3534}
@@ -54,32 +53,32 @@ fun setup() {
5453
5554fun waitForTx (esploraEndpoint : String , txid : String ) {
5655 var esploraPickedUpTx = false
57- val re = Regex (" \" txid\" :\" $txid \" " );
56+ val re = Regex (" \" txid\" :\" $txid \" " )
5857 while (! esploraPickedUpTx) {
5958 val client = HttpClient .newBuilder().build()
6059 val request = HttpRequest .newBuilder()
6160 .uri(URI .create(esploraEndpoint + " /tx/" + txid))
62- .build();
61+ .build()
6362
64- val response = client.send(request, HttpResponse .BodyHandlers .ofString());
63+ val response = client.send(request, HttpResponse .BodyHandlers .ofString())
6564
66- esploraPickedUpTx = re.containsMatchIn(response.body());
65+ esploraPickedUpTx = re.containsMatchIn(response.body())
6766 Thread .sleep(500 )
6867 }
6968}
7069
7170fun waitForBlock (esploraEndpoint : String , blockHash : String ) {
7271 var esploraPickedUpBlock = false
73- val re = Regex (" \" in_best_chain\" :true" );
72+ val re = Regex (" \" in_best_chain\" :true" )
7473 while (! esploraPickedUpBlock) {
7574 val client = HttpClient .newBuilder().build()
7675 val request = HttpRequest .newBuilder()
7776 .uri(URI .create(esploraEndpoint + " /block/" + blockHash + " /status" ))
78- .build();
77+ .build()
7978
80- val response = client.send(request, HttpResponse .BodyHandlers .ofString());
79+ val response = client.send(request, HttpResponse .BodyHandlers .ofString())
8180
82- esploraPickedUpBlock = re.containsMatchIn(response.body());
81+ esploraPickedUpBlock = re.containsMatchIn(response.body())
8382 Thread .sleep(500 )
8483 }
8584}
@@ -172,7 +171,7 @@ class LibraryTest {
172171
173172 val fundingTxid = when (channelPendingEvent1) {
174173 is Event .ChannelPending -> channelPendingEvent1.fundingTxo.txid
175- else -> return
174+ else -> return
176175 }
177176
178177 waitForTx(esploraEndpoint, fundingTxid)
@@ -202,7 +201,7 @@ class LibraryTest {
202201
203202 val channelId = when (channelReadyEvent2) {
204203 is Event .ChannelReady -> channelReadyEvent2.channelId
205- else -> return
204+ else -> return
206205 }
207206
208207 val invoice = node2.receivePayment(2500000u , " asdf" , 9217u )
0 commit comments