Skip to content

Commit

Permalink
Kotlin unit tests update for LDK v0.0.121
Browse files Browse the repository at this point in the history
  • Loading branch information
ovitrif committed Mar 25, 2024
1 parent 2e4e77d commit 27e3744
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Binary file modified lib/android/libs/ldk-java.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod

val output = TxOut(outputValue.toLong(), outputScriptPubKey.hexa())
val outpoint = OutPoint.of(outpointTxId.hexa().reversedArray(), outpointIndex.toInt().toShort())
val descriptor = SpendableOutputDescriptor.static_output(outpoint, output, byteArrayOf())
val descriptor = SpendableOutputDescriptor.static_output(outpoint, output, ByteArray(32))

val ldkDescriptors: MutableList<SpendableOutputDescriptor> = arrayListOf()
ldkDescriptors.add(descriptor)
Expand Down
17 changes: 5 additions & 12 deletions lib/android/src/test/java/com/reactnativeldk/LdkModuleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ import org.mockito.kotlin.any
import org.mockito.kotlin.check
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.eq
import org.mockito.kotlin.isA
import org.mockito.kotlin.isNull
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import java.io.File
import kotlin.test.assertEquals
import kotlin.test.assertTrue

private const val FS_ROOT = "build/test-files"
Expand Down Expand Up @@ -188,7 +186,6 @@ class LdkModuleTest {
4.0,
5.0,
5.0,
6.0,
promise
)

Expand Down Expand Up @@ -357,18 +354,14 @@ class LdkModuleTest {
@Test
fun test_pay_expiredInvoice() {
// TODO: Add test for happy flow + other error cases
val promise = mock<Promise>()
setupChannelManager()

ldkModule.pay(INVOICE_EXPIRED, 0.0, 2.5, _promise)
ldkModule.pay(INVOICE_EXPIRED, 0.0, 2.5, promise)

verify(_promise).reject(
eq(LdkErrors.invoice_payment_fail_sending.name),
check<Throwable> {
assertEquals(
"PaymentError.Sending: LDKRetryableSendFailure_PaymentExpired",
it.message
)
}
verify(promise).reject(
eq(LdkErrors.invoice_payment_fail_payment_expired.name),
eq(LdkErrors.invoice_payment_fail_payment_expired.name),
)
}

Expand Down

0 comments on commit 27e3744

Please sign in to comment.