Skip to content

Commit 384aad9

Browse files
authored
Merge pull request #297 from synonymdev/feat/e2e-beyond-local
Ability to run e2e build beyond local
2 parents 1e3cbe7 + 1f4d815 commit 384aad9

File tree

4 files changed

+72
-5
lines changed

4 files changed

+72
-5
lines changed

AGENTS.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ This app integrates with:
2121
```bash
2222
# Standard build - Open Bitkit.xcodeproj in Xcode and build
2323

24-
# E2E test build (uses local Electrum backend)
24+
# E2E test build (uses local Electrum backend by default)
2525
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
2626
-scheme Bitkit \
2727
-configuration Debug \
2828
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
2929
build
30+
31+
# E2E test build with network Electrum and regtest (Info.plist build setting)
32+
E2E_BACKEND=network E2E_NETWORK=regtest \
33+
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
34+
-scheme Bitkit \
35+
-configuration Debug \
36+
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
37+
build
3038
```
3139

3240
### Code Formatting
@@ -197,7 +205,7 @@ New feature (`TransferTrackingManager`) tracks pending transfers to handle edge
197205
- The app currently runs on **regtest only** (see `LightningService.swift:92` guard)
198206
- VSS (Versioned Storage Service) authentication is not yet implemented
199207
- Electrum/Esplora server URLs are configurable via `Env`
200-
- E2E builds use local Electrum backend via `E2E_BUILD` compilation flag
208+
- E2E builds use local Electrum backend via `E2E_BUILD` compilation flag (override with `E2E_BACKEND`/`E2E_NETWORK` build settings)
201209

202210
### Error Handling
203211

Bitkit/Constants/Env.swift

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ enum Env {
2424
#endif
2525
}
2626

27+
private static func infoPlistValue(_ key: String) -> String? {
28+
let value = Bundle.main.object(forInfoDictionaryKey: key) as? String
29+
let trimmed = value?.trimmingCharacters(in: .whitespacesAndNewlines)
30+
return trimmed?.isEmpty == false ? trimmed : nil
31+
}
32+
33+
private static var e2eBackend: String {
34+
(infoPlistValue("E2E_BACKEND") ?? "local").lowercased()
35+
}
36+
37+
private static var e2eNetwork: LDKNode.Network {
38+
switch (infoPlistValue("E2E_NETWORK") ?? "regtest").lowercased() {
39+
case "bitcoin", "mainnet":
40+
return .bitcoin
41+
case "testnet":
42+
return .testnet
43+
case "signet":
44+
return .signet
45+
default:
46+
return .regtest
47+
}
48+
}
49+
2750
static var isGeoblockingEnabled: Bool {
2851
#if CHECK_GEOBLOCK
2952
return true
@@ -48,7 +71,19 @@ enum Env {
4871

4972
// MARK: wallet services
5073

51-
static let network: LDKNode.Network = (isDebug || isUnitTest || isE2E) ? .regtest : .bitcoin
74+
static let network: LDKNode.Network = {
75+
if isUnitTest {
76+
return .regtest
77+
}
78+
if isE2E {
79+
return e2eNetwork
80+
}
81+
if isDebug {
82+
return .regtest
83+
}
84+
return .bitcoin
85+
}()
86+
5287
static let ldkLogLevel = LDKNode.LogLevel.trace
5388

5489
static let walletSyncIntervalSecs: UInt64 = 10 // TODO: play around with this
@@ -80,7 +115,7 @@ enum Env {
80115
// MARK: Server URLs
81116

82117
static var electrumServerUrl: String {
83-
if isE2E {
118+
if isE2E, e2eBackend == "local" {
84119
return "tcp://127.0.0.1:60001"
85120
}
86121

Bitkit/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
</array>
2020
</dict>
2121
</array>
22+
<key>E2E_BACKEND</key>
23+
<string>$(E2E_BACKEND)</string>
24+
<key>E2E_NETWORK</key>
25+
<string>$(E2E_NETWORK)</string>
2226
<key>NSFaceIDUsageDescription</key>
2327
<string>Bitkit uses Face ID to securely authenticate access to your wallet and protect your Bitcoin.</string>
2428
<key>UIAppFonts</key>

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The app automatically selects the network based on the build configuration:
2626

2727
### Building for E2E tests
2828

29-
To produce an E2E build (uses the local Electrum backend), pass the `E2E_BUILD` compilation flag:
29+
To produce an E2E build (uses the local Electrum backend by default), pass the `E2E_BUILD` compilation flag:
3030

3131
```bash
3232
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
@@ -36,6 +36,26 @@ xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
3636
build
3737
```
3838

39+
You can also set the backend/network at build time via Info.plist substitutions:
40+
41+
```bash
42+
# Use network Electrum with regtest
43+
E2E_BACKEND=network E2E_NETWORK=regtest \
44+
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
45+
-scheme Bitkit \
46+
-configuration Debug \
47+
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
48+
build
49+
50+
# Use network Electrum with mainnet
51+
E2E_BACKEND=network E2E_NETWORK=bitcoin \
52+
xcodebuild -workspace Bitkit.xcodeproj/project.xcworkspace \
53+
-scheme Bitkit \
54+
-configuration Debug \
55+
SWIFT_ACTIVE_COMPILATION_CONDITIONS='$(inherited) E2E_BUILD' \
56+
build
57+
```
58+
3959
## Localization
4060

4161
### Pulling Translations

0 commit comments

Comments
 (0)