diff --git a/.github/scripts/run_balances_test.sh b/.github/scripts/run_balances_test.sh index b7b82651..a3d3e7ef 100644 --- a/.github/scripts/run_balances_test.sh +++ b/.github/scripts/run_balances_test.sh @@ -8,8 +8,14 @@ adb -s emulator-5554 install app/debug/app-debug.apk adb -s emulator-5554 install app/androidTest/debug/app-debug-androidTest.apk # Run tests -adb logcat -c && -python - </dev/null adb logcat -d '*:E' # Export results -adb exec-out run-as io.novafoundation.nova.debug sh -c 'cd /data/data/io.novafoundation.nova.debug/files && tar cf - allure-results' > allure-results.tar +adb exec-out run-as io.pezkuwichain.wallet.debug sh -c 'cd /data/data/io.pezkuwichain.wallet.debug/files && tar cf - allure-results' > allure-results.tar exit $EXIT_CODE diff --git a/.github/scripts/run_instrumental_tests.sh b/.github/scripts/run_instrumental_tests.sh index f72a82e2..ef4c20d2 100644 --- a/.github/scripts/run_instrumental_tests.sh +++ b/.github/scripts/run_instrumental_tests.sh @@ -28,7 +28,7 @@ t.dameon = True t.start() def run(): os.system('adb wait-for-device') - p = sp.Popen('adb shell am instrument -w -m -e notClass io.novafoundation.nova.balances.BalancesIntegrationTest -e package io.novafoundation.nova.debug io.novafoundation.nova.debug.test/io.qameta.allure.android.runners.AllureAndroidJUnitRunner', + p = sp.Popen('adb shell am instrument -w -m -e notClass io.novafoundation.nova.balances.BalancesIntegrationTest -e package io.pezkuwichain.wallet.debug io.pezkuwichain.wallet.debug.test/io.qameta.allure.android.runners.AllureAndroidJUnitRunner', shell=True, stdout=sp.PIPE, stderr=sp.PIPE, stdin=sp.PIPE) return p.communicate() success = re.compile(r'OK \(\d+ tests\)') @@ -47,6 +47,6 @@ EXIT_CODE=$? adb logcat -d '*:E' # Export results -adb exec-out run-as io.novafoundation.nova.debug sh -c 'cd /data/data/io.novafoundation.nova.debug/files && tar cf - allure-results' > allure-results.tar +adb exec-out run-as io.pezkuwichain.wallet.debug sh -c 'cd /data/data/io.pezkuwichain.wallet.debug/files && tar cf - allure-results' > allure-results.tar exit $EXIT_CODE diff --git a/.github/workflows/balances_test.yml b/.github/workflows/balances_test.yml index a1832c80..6c74a8fa 100644 --- a/.github/workflows/balances_test.yml +++ b/.github/workflows/balances_test.yml @@ -19,7 +19,8 @@ jobs: run-tests: needs: [build-app] - runs-on: macos-14 + runs-on: ubuntu-latest + timeout-minutes: 90 steps: - uses: actions/checkout@v4 @@ -36,12 +37,19 @@ jobs: - name: Add permissions run: chmod +x .github/scripts/run_balances_test.sh + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Run tests uses: reactivecircus/android-emulator-runner@v2 with: disable-animations: true profile: Nexus 6 api-level: 29 + arch: x86_64 script: .github/scripts/run_balances_test.sh - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c6bcba0d..1e9a1a8c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -2,13 +2,20 @@ name: Pull request on: pull_request: + workflow_dispatch: + inputs: + branch: + description: 'Branch to build and test (manual escape hatch for when pull_request-triggered CI does not fire)' + required: true + default: 'main' + type: string jobs: test: uses: pezkuwichain/pezkuwi-wallet-android/.github/workflows/android_build.yml@main with: - branch: ${{github.head_ref}} + branch: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.head_ref }} gradlew-command: assembleDevelop keystore-file-name: develop_key.jks # develop variant is signed with signingConfigs.dev (develop_key.jks) build-debug-tests: false # TODO: Enable this, when debug build will be fixed for tests diff --git a/app/build.gradle b/app/build.gradle index 2065a25b..f0eaa8b3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,6 +36,11 @@ android { debug { applicationIdSuffix '.debug' versionNameSuffix '-debug' + // androidTest is only ever compiled against this build type (AGP's testBuildType + // defaults to "debug" and is not overridden anywhere in this project), so this is the + // only place a testInstrumentationRunner override actually takes effect - the identical + // override on the instrumentialTest build type below is unreachable dead config. + defaultConfig.testInstrumentationRunner "io.qameta.allure.android.runners.AllureAndroidJUnitRunner" buildConfigField "String", "BuildType", "\"debug\"" } @@ -94,7 +99,6 @@ android { instrumentialTest { initWith buildTypes.debug matchingFallbacks = ['debug'] - defaultConfig.testInstrumentationRunner "io.qameta.allure.android.runners.AllureAndroidJUnitRunner" buildConfigField "String", "BuildType", "\"instrumentalTest\"" } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt index 57da123a..1ae735b7 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt @@ -215,12 +215,18 @@ class ChainRegistry( if (chain.hasSubstrateRuntime) { runtimeProviderPool.setupRuntimeProvider(chain) - runtimeSyncService.registerChain(chain, connection) - runtimeSubscriptionPool.setupRuntimeSubscription(chain, connection) + runtimeSyncService.registerChain(chain, requireNotNull(connection)) + runtimeSubscriptionPool.setupRuntimeSubscription(chain, requireNotNull(connection)) } } - private suspend fun registerConnection(chain: Chain): ChainConnection { + private suspend fun registerConnection(chain: Chain): ChainConnection? { + // Tron nodes are plain REST APIs (TronGrid), not WSS JSON-RPC endpoints - ChainConnection's + // SocketService can only speak the latter, so attempting to set one up here would hang + // indefinitely instead of failing fast. Tron balance/transfer operations already go through + // their own dedicated TronGridApi client, independent of this connection pool. + if (chain.isTronBased) return null + val connection = connectionPool.setupConnection(chain) if (chain.isEthereumBased) {