Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.lightspark.sdk.model.ComplianceProvider
import com.lightspark.sdk.model.CreateApiTokenOutput
import com.lightspark.sdk.model.CurrencyAmount
import com.lightspark.sdk.model.FeeEstimate
import com.lightspark.sdk.model.IncomingPayment
import com.lightspark.sdk.model.Invoice
import com.lightspark.sdk.model.InvoiceData
import com.lightspark.sdk.model.InvoiceType
Expand Down Expand Up @@ -395,7 +396,7 @@ class LightsparkFuturesClient(config: ClientConfig) {
localNodeId: String,
encodedInvoice: String,
amountMsats: Long? = null,
): CompletableFuture<OutgoingPayment> = coroutineScope.future {
): CompletableFuture<IncomingPayment> = coroutineScope.future {
coroutinesClient.createTestModePayment(
localNodeId,
encodedInvoice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ class LightsparkCoroutinesClient private constructor(
localNodeId: String,
encodedInvoice: String,
amountMsats: Long? = null,
): OutgoingPayment {
): IncomingPayment {
requireValidAuth()
return executeQuery(
Query(
Expand All @@ -808,7 +808,7 @@ class LightsparkCoroutinesClient private constructor(
val outputJson =
requireNotNull(it["create_test_mode_payment"]) { "No payment output found in response" }
val paymentJson =
requireNotNull(outputJson.jsonObject["payment"]) { "No payment found in response" }
requireNotNull(outputJson.jsonObject["incoming_payment"]) { "No payment found in response" }
serializerFormat.decodeFromJsonElement(paymentJson)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class LightsparkSyncClient constructor(config: ClientConfig) {
localNodeId: String,
encodedInvoice: String,
amountMsats: Long? = null,
): OutgoingPayment = runBlocking {
): IncomingPayment = runBlocking {
asyncClient.createTestModePayment(
localNodeId,
encodedInvoice,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.lightspark.sdk.graphql

import com.lightspark.sdk.model.OutgoingPayment
import com.lightspark.sdk.model.IncomingPayment

const val CreateTestModePayment = """
mutation CreateTestModePayment(
Expand All @@ -13,11 +13,11 @@ mutation CreateTestModePayment(
encoded_invoice: ${'$'}encoded_invoice
amount_msats: ${'$'}amount_msats
}) {
payment {
...OutgoingPaymentFragment
incoming_payment {
...IncomingPaymentFragment
}
}
}

${OutgoingPayment.FRAGMENT}
${IncomingPayment.FRAGMENT}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.lightspark.sdk.core.util.getPlatform
import com.lightspark.sdk.crypto.PasswordRecoverySigningKeyLoader
import com.lightspark.sdk.model.Account
import com.lightspark.sdk.model.BitcoinNetwork
import com.lightspark.sdk.model.IncomingPayment
import com.lightspark.sdk.model.LightsparkNode
import com.lightspark.sdk.model.OutgoingPayment
import com.lightspark.sdk.model.Transaction
import com.lightspark.sdk.model.TransactionStatus
import io.kotest.matchers.collections.shouldBeIn
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.collections.shouldNotBeEmpty
import io.kotest.matchers.nulls.shouldNotBeNull
Expand Down Expand Up @@ -227,9 +227,14 @@ class ClientIntegrationTests {
fun `test creating a test mode payment`() = runTest {
val node = getFirstNode()
val invoice = client.createInvoice(node.id, 100_000, "test invoice")
val payment = client.createTestModePayment(node.id, invoice.data.encodedPaymentRequest)
var payment: IncomingPayment? = client.createTestModePayment(node.id, invoice.data.encodedPaymentRequest)
payment.shouldNotBeNull()
payment.status.shouldBeIn(TransactionStatus.PENDING, TransactionStatus.SUCCESS)
while (payment?.status == TransactionStatus.PENDING) {
delay(500)
payment = IncomingPayment.getIncomingPaymentQuery(payment.id).execute(client)
println("Payment status: ${payment?.status}")
}
payment?.status.shouldBe(TransactionStatus.SUCCESS)
}

// TODO: Add tests for withdrawals and deposits.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class LightsparkFuturesWalletClient constructor(config: ClientConfig) {
fun createTestModePayment(
encodedInvoice: String,
amountMsats: Long? = null,
): CompletableFuture<OutgoingPayment> = coroutineScope.future {
): CompletableFuture<IncomingPayment> = coroutineScope.future {
coroutinesClient.createTestModePayment(
encodedInvoice,
amountMsats,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ class LightsparkCoroutinesWalletClient private constructor(
suspend fun createTestModePayment(
encodedInvoice: String,
amountMsats: Long? = null,
): OutgoingPayment {
): IncomingPayment {
requireValidAuth()
return executeQuery(
Query(
Expand All @@ -755,7 +755,7 @@ class LightsparkCoroutinesWalletClient private constructor(
val outputJson =
requireNotNull(it["create_test_mode_payment"]) { "No payment output found in response" }
val paymentJson =
requireNotNull(outputJson.jsonObject["payment"]) { "No payment found in response" }
requireNotNull(outputJson.jsonObject["incoming_payment"]) { "No payment found in response" }
serializerFormat.decodeFromJsonElement(paymentJson)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class LightsparkSyncWalletClient constructor(config: ClientConfig) {
fun createTestModePayment(
encodedInvoice: String,
amountMsats: Long? = null,
): OutgoingPayment = runBlocking {
): IncomingPayment = runBlocking {
asyncClient.createTestModePayment(
encodedInvoice,
amountMsats,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.lightspark.sdk.wallet.graphql

import com.lightspark.sdk.wallet.model.OutgoingPayment
import com.lightspark.sdk.wallet.model.IncomingPayment

const val CreateTestModePayment = """
mutation CreateTestModePayment(
Expand All @@ -11,11 +11,11 @@ mutation CreateTestModePayment(
encoded_invoice: ${'$'}encoded_invoice
amount_msats: ${'$'}amount_msats
}) {
payment {
...OutgoingPaymentFragment
incoming_payment {
...IncomingPaymentFragment
}
}
}

${OutgoingPayment.FRAGMENT}
${IncomingPayment.FRAGMENT}
"""