Skip to content

Commit 27e25db

Browse files
committed
Transfer unit test approach to DirectBindingsApp
1 parent 374801c commit 27e25db

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

xcode/DirectBindingsApp/DirectBindingsAppTests/DirectBindingsAppTests.swift

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class DirectBindingsAppTests: XCTestCase {
1616

1717
override func setUpWithError() throws {
1818
// Put setup code here. This method is called before the invocation of each test method in the class.
19+
Bindings.setLogThreshold(severity: .DEBUG)
1920
}
2021

2122
override func tearDownWithError() throws {
@@ -25,11 +26,15 @@ class DirectBindingsAppTests: XCTestCase {
2526
func testExample() throws {
2627
// This is an example of a functional test case.
2728
// Use XCTAssert and related functions to verify your tests produce the correct results.
28-
29+
}
2930

31+
func testVersionSanity() throws {
32+
check_get_ldk_version()
33+
check_get_ldk_bindings_version()
34+
check_platform()
3035
}
31-
32-
func testMemoryLeaksIncrementally() throws {
36+
37+
private func incrementalMemoryLeakTest() throws {
3338
let filter = TestFilter()
3439
let broadcaster = TestBroadcasterInterface()
3540
let logger = TestLogger()
@@ -52,10 +57,6 @@ class DirectBindingsAppTests: XCTestCase {
5257
let serializedChannelMonitors: [[UInt8]] = LDKTestFixtures.serializedChannelMonitors
5358

5459
var monitors: [LDKChannelMonitor] = []
55-
// let secondConfig = config.clone()
56-
// let res = UtilMethods.constructor_BlockHashChannelManagerZ_read(ser: serialized_channel_manager, arg_keys_manager: keysInterface, arg_fee_estimator: feeEstimator, arg_chain_monitor: chainMonitor.as_Watch(), arg_tx_broadcaster: broadcaster, arg_logger: logger, arg_default_config: config, arg_channel_monitors: monitors)
57-
58-
print("last statement in memory leak test")
5960

6061
let channel_manager_constructor = try ChannelManagerConstructor(
6162
channel_manager_serialized: serialized_channel_manager,
@@ -68,14 +69,19 @@ class DirectBindingsAppTests: XCTestCase {
6869
tx_broadcaster: broadcaster,
6970
logger: logger
7071
)
71-
72-
var channel_manager = channel_manager_constructor.channelManager;
73-
var cmPersister = TestChannelManagerPersister(channelManager: channel_manager)
72+
73+
let channel_manager = channel_manager_constructor.channelManager;
74+
let cmPersister = TestChannelManagerPersister(channelManager: channel_manager)
75+
7476
channel_manager_constructor.chain_sync_completed(persister: cmPersister)
7577
channel_manager_constructor.interrupt()
7678
}
77-
78-
func testExtendedActivity() {
79+
80+
func testMemoryLeaksIncrementally() throws {
81+
try incrementalMemoryLeakTest()
82+
}
83+
84+
func testExtendedActivity() throws {
7985
// for i in 0...(1 << 7) {
8086
for i in 0..<1 { // only do one test run initially
8187
let nice_close = (i & (1 << 0)) != 0;
@@ -97,17 +103,9 @@ class DirectBindingsAppTests: XCTestCase {
97103
}
98104

99105
print("Running test with flags \(i)");
100-
try? SimulationRunner.do_test(nice_close: nice_close, use_km_wrapper: use_km_wrapper, use_manual_watch: use_manual_watch, reload_peers: reload_peers, break_cross_peer_refs: break_cross_refs, nio_peer_handler: nio_peer_handler, use_chan_manager_constructor: use_chan_manager_constructor)
106+
try SimulationRunner.do_test(nice_close: nice_close, use_km_wrapper: use_km_wrapper, use_manual_watch: use_manual_watch, reload_peers: reload_peers, break_cross_peer_refs: break_cross_refs, nio_peer_handler: nio_peer_handler, use_chan_manager_constructor: use_chan_manager_constructor)
101107
}
102108

103-
// avoid early termination
104-
105-
print("Press enter to stop running test.")
106-
// let keyboard = FileHandle.standardInput
107-
// let inputData = keyboard.availableData
108-
// let strData = String(data: inputData, encoding: String.Encoding.utf8)!
109-
110-
111109
}
112110

113111
fileprivate class SimulationRunner {
@@ -132,6 +130,7 @@ class DirectBindingsAppTests: XCTestCase {
132130
// This is an example of a performance test case.
133131
self.measure {
134132
// Put the code you want to measure the time of here.
133+
// try! incrementalMemoryLeakTest()
135134
}
136135
}
137136

0 commit comments

Comments
 (0)