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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ The build config supports building 3 different apps for the 3 bitcoin networks (
- `mainnet` flavour = mainnet
- `tnet` flavour = testnet

### Build for E2E Testing
Simply pass `E2E=true` as environment variable and build any flavor.

```sh
E2E=true ./gradlew assembleDevRelease
```

### Build for Release

**Prerequisites**
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ android {
vectorDrawables {
useSupportLibrary = true
}
buildConfigField("boolean", "E2E", System.getenv("E2E")?.toBoolean()?.toString() ?: "false")
}

flavorDimensions += "network"
Expand Down
22 changes: 16 additions & 6 deletions app/src/main/java/to/bitkit/env/Env.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import to.bitkit.utils.Logger
import java.io.File
import kotlin.io.path.Path

@Suppress("ConstPropertyName")
@Suppress("ConstPropertyName", "KotlinConstantConditions")
internal object Env {
val isDebug = BuildConfig.DEBUG
const val isE2eTest = BuildConfig.E2E
val network = Network.valueOf(BuildConfig.NETWORK)
val walletSyncIntervalSecs = 10_uL // TODO review
val platform = "Android ${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})"
Expand Down Expand Up @@ -162,14 +163,23 @@ internal object Env {
ssl = 18484,
protocol = ElectrumProtocol.TCP,
)
val E2E = ElectrumServer(
host = "127.0.0.1",
tcp = 60001,
ssl = 60002,
protocol = ElectrumProtocol.TCP,
)
}

val defaultElectrumServer: ElectrumServer
get() = when (network) {
Network.REGTEST -> ElectrumServers.REGTEST
Network.TESTNET -> ElectrumServers.TESTNET
Network.BITCOIN -> ElectrumServers.BITCOIN
else -> TODO("${network.name} network not implemented")
get() {
if (isE2eTest) return ElectrumServers.E2E
return when (network) {
Network.REGTEST -> ElectrumServers.REGTEST
Network.TESTNET -> ElectrumServers.TESTNET
Network.BITCOIN -> ElectrumServers.BITCOIN
else -> TODO("${network.name} network not implemented")
}
}

const val PIN_LENGTH = 4
Expand Down