Skip to content

Commit b3c8109

Browse files
authored
Merge pull request #263 from synonymdev/feat/e2e-setup
E2E testing setup
2 parents 2fca6ab + 8ef6ff8 commit b3c8109

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ The build config supports building 3 different apps for the 3 bitcoin networks (
4646
- `mainnet` flavour = mainnet
4747
- `tnet` flavour = testnet
4848

49+
### Build for E2E Testing
50+
Simply pass `E2E=true` as environment variable and build any flavor.
51+
52+
```sh
53+
E2E=true ./gradlew assembleDevRelease
54+
```
55+
4956
### Build for Release
5057

5158
**Prerequisites**

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ android {
4646
vectorDrawables {
4747
useSupportLibrary = true
4848
}
49+
buildConfigField("boolean", "E2E", System.getenv("E2E")?.toBoolean()?.toString() ?: "false")
4950
}
5051

5152
flavorDimensions += "network"

app/src/main/java/to/bitkit/env/Env.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import to.bitkit.utils.Logger
1313
import java.io.File
1414
import kotlin.io.path.Path
1515

16-
@Suppress("ConstPropertyName")
16+
@Suppress("ConstPropertyName", "KotlinConstantConditions")
1717
internal object Env {
1818
val isDebug = BuildConfig.DEBUG
19+
const val isE2eTest = BuildConfig.E2E
1920
val network = Network.valueOf(BuildConfig.NETWORK)
2021
val walletSyncIntervalSecs = 10_uL // TODO review
2122
val platform = "Android ${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})"
@@ -162,14 +163,23 @@ internal object Env {
162163
ssl = 18484,
163164
protocol = ElectrumProtocol.TCP,
164165
)
166+
val E2E = ElectrumServer(
167+
host = "127.0.0.1",
168+
tcp = 60001,
169+
ssl = 60002,
170+
protocol = ElectrumProtocol.TCP,
171+
)
165172
}
166173

167174
val defaultElectrumServer: ElectrumServer
168-
get() = when (network) {
169-
Network.REGTEST -> ElectrumServers.REGTEST
170-
Network.TESTNET -> ElectrumServers.TESTNET
171-
Network.BITCOIN -> ElectrumServers.BITCOIN
172-
else -> TODO("${network.name} network not implemented")
175+
get() {
176+
if (isE2eTest) return ElectrumServers.E2E
177+
return when (network) {
178+
Network.REGTEST -> ElectrumServers.REGTEST
179+
Network.TESTNET -> ElectrumServers.TESTNET
180+
Network.BITCOIN -> ElectrumServers.BITCOIN
181+
else -> TODO("${network.name} network not implemented")
182+
}
173183
}
174184

175185
const val PIN_LENGTH = 4

0 commit comments

Comments
 (0)