diff --git a/.github/workflows/unit-tests-android.yml b/.github/workflows/unit-tests-android.yml index d2b6a21e..b7e5dc84 100644 --- a/.github/workflows/unit-tests-android.yml +++ b/.github/workflows/unit-tests-android.yml @@ -11,8 +11,7 @@ on: jobs: tests-android: name: Android Unit Tests - runs-on: macos-14 # m1 mac - # runs-on: ubuntu-latest # Uncomment to run locally via act + runs-on: macos-12 steps: - uses: actions/checkout@v3 @@ -22,10 +21,6 @@ jobs: with: node-version: 18 - # Uncomment to run workflow locally via act - # - name: Install yarn - # run: npm install -g yarn - - name: Install node_modules working-directory: example run: yarn install && yarn rn-setup @@ -34,12 +29,11 @@ jobs: uses: actions/setup-java@v2 with: java-version: '17' - architecture: x64 distribution: 'zulu' - name: Use Android SDK uses: android-actions/setup-android@v2 - name: Run Android unit tests - run: ./gradlew testDebugUnitTest --stacktrace --no-daemon working-directory: lib/android + run: ./gradlew testDebugUnitTest --stacktrace --no-daemon diff --git a/lib/android/gradle.properties b/lib/android/gradle.properties index 06a5461a..5ca30574 100644 --- a/lib/android/gradle.properties +++ b/lib/android/gradle.properties @@ -1,4 +1,4 @@ -Ldk_kotlinVersion=1.8.20 +Ldk_kotlinVersion=1.6.10 Ldk_compileSdkVersion=29 Ldk_targetSdkVersion=29 android.useAndroidX=true \ No newline at end of file diff --git a/lib/android/libs/ldk-java.jar b/lib/android/libs/ldk-java.jar index 9fe99b1d..bc9bbefe 100644 Binary files a/lib/android/libs/ldk-java.jar and b/lib/android/libs/ldk-java.jar differ diff --git a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt index c0d1904e..2d76fac9 100644 --- a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt +++ b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt @@ -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 = arrayListOf() ldkDescriptors.add(descriptor) diff --git a/lib/android/src/test/java/com/reactnativeldk/LdkModuleTest.kt b/lib/android/src/test/java/com/reactnativeldk/LdkModuleTest.kt index 3a323ac8..cb44082a 100644 --- a/lib/android/src/test/java/com/reactnativeldk/LdkModuleTest.kt +++ b/lib/android/src/test/java/com/reactnativeldk/LdkModuleTest.kt @@ -16,7 +16,6 @@ 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 @@ -24,7 +23,6 @@ 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" @@ -32,7 +30,10 @@ private const val FS_ROOT = "build/test-files" private val INVOICE_EXPIRED = "lnbcrt120n1pjlrxz9pp599l2jlsrt4qeczdyh90rzhfsfrkxhu6dged8yhfyhw0kt3sfzsyqdqdw4hxjaz5v4ehgcqzzsxqyz5vqsp54ehunpcenrejgq4tfwr8a4s5tlyrchhk27e70a0vagwr60n8mwhq9qyyssq5t6dqjwu4r6rnjfz7uk9mx0p2h2rxlr00fqyzjtudglay6lzfqp370ml6y8hnwfz8eamhdt4nu7s6jwy64gd9gtl9t8zz5l67cq6j6qqkgmr5v" -@Config(shadows = [ShadowArguments::class], manifest = Config.NONE) +@Config( + manifest = Config.NONE, + shadows = [ShadowArguments::class], +) @RunWith(RobolectricTestRunner::class) class LdkModuleTest { private val eventEmitter = mock() @@ -56,12 +57,8 @@ class LdkModuleTest { @Before fun setUp() { - ldkModule = LdkModule(reactContext) _promise = mock() - // TODO remove after PR gets merged and LDK is updated: - // https://github.com/lightningdevkit/ldk-garbagecollected/issues/149 - get_ldk_version() // ← HACK to force load LDK bindings - // TODO clear tests file storage (maybe?) + ldkModule = LdkModule(reactContext) } // MARK: Startup methods @@ -188,7 +185,6 @@ class LdkModuleTest { 4.0, 5.0, 5.0, - 6.0, promise ) @@ -357,18 +353,14 @@ class LdkModuleTest { @Test fun test_pay_expiredInvoice() { // TODO: Add test for happy flow + other error cases + val promise = mock() 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 { - 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), ) } @@ -446,7 +438,6 @@ class LdkModuleTest { @Test fun test_nodeId() { val promise = mock() - setupChannelManager() ldkModule.nodeId(promise) @@ -627,7 +618,12 @@ class LdkModuleTest { val promise = mock() setupChannelManager() - ldkModule.spendRecoveredForceCloseOutputs("transaction", 1.0, "changeDestinationScript", promise) + ldkModule.spendRecoveredForceCloseOutputs( + "transaction", + 1.0, + "changeDestinationScript", + promise + ) verify(promise).resolve(check { assertTrue { it.size() == 0 }