Skip to content

Commit 13d5d2d

Browse files
committed
ability to run e2e build beyond local
1 parent 1e3cbe7 commit 13d5d2d

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-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: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ 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+
return value?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false ? value : nil
30+
}
31+
32+
private static var e2eBackend: String {
33+
(infoPlistValue("E2E_BACKEND") ?? "local").lowercased()
34+
}
35+
36+
private static var e2eNetwork: LDKNode.Network {
37+
switch (infoPlistValue("E2E_NETWORK") ?? "regtest").lowercased() {
38+
case "bitcoin", "mainnet":
39+
return .bitcoin
40+
case "testnet":
41+
return .testnet
42+
case "signet":
43+
return .signet
44+
default:
45+
return .regtest
46+
}
47+
}
48+
2749
static var isGeoblockingEnabled: Bool {
2850
#if CHECK_GEOBLOCK
2951
return true
@@ -48,7 +70,16 @@ enum Env {
4870

4971
// MARK: wallet services
5072

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

5485
static let walletSyncIntervalSecs: UInt64 = 10 // TODO: play around with this
@@ -80,7 +111,7 @@ enum Env {
80111
// MARK: Server URLs
81112

82113
static var electrumServerUrl: String {
83-
if isE2E {
114+
if isE2E, e2eBackend == "local" {
84115
return "tcp://127.0.0.1:60001"
85116
}
86117

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)