]> git.bitcoin.ninja Git - ldk-swift-linux/commitdiff
Fix minor build issues, resulting in the tests now running
authorMatt Corallo <git@bluematt.me>
Tue, 27 Jul 2021 23:30:18 +0000 (23:30 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 27 Jul 2021 23:30:18 +0000 (23:30 +0000)
LDKSwift/Package.swift
LDKSwift/Sources/LDKSwift/batteries/TCPPeerHandler.swift
LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift
LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift [deleted file]
LDKSwift/Tests/LDKSwiftTests/MyFeeEstimator.swift [new file with mode: 0644]
LDKSwift/Tests/LDKSwiftTests/MyLogger.swift [new file with mode: 0644]

index 4954c025b03fc92bd48468f08744582c0c0a5bf0..018bf23ccad3848e9bedcc8d4583857beb1a343a 100644 (file)
@@ -18,7 +18,11 @@ let package = Package(
         // Targets can depend on other targets in this package, and on products in packages this package depends on.
         .target(
             name: "LDKSwift",
-            dependencies: ["LDKCHeaders"]),
+            dependencies: ["LDKCHeaders"],
+            linkerSettings: [
+                .linkedLibrary("/root/ldk-c-bindings/lightning-c-bindings/target/debug/libldk.a"),
+                .linkedLibrary("/root/ldk-c-bindings/lightning-c-bindings/ldk_net.o")
+            ]),
         .testTarget(
             name: "LDKSwiftTests",
             dependencies: ["LDKSwift"]),
index fd3b022e6f6bb548ca52cc5eb2c5c89d530b38b3..6fcc7314ed1c266b71b7d8fb0666acf4841cb299 100644 (file)
@@ -31,13 +31,12 @@ public class TCPPeerHandler {
         }
         self.isBound = true
         var addressObject = sockaddr_in()
-        addressObject.sin_len = UInt8(MemoryLayout.size(ofValue: addressObject))
         addressObject.sin_family = sa_family_t(AF_INET)
-        addressObject.sin_port = CFSwapInt16HostToBig(port)
+        addressObject.sin_port = port.bigEndian
 
         addressObject.sin_addr.s_addr = inet_addr(address)
         
-        let sin_length = addressObject.sin_len
+        let sin_length = UInt8(MemoryLayout.size(ofValue: addressObject))
 
         let result = withUnsafePointer(to: &addressObject, { addressPointer in
             
@@ -59,13 +58,12 @@ public class TCPPeerHandler {
     public func connect(address: String, port: UInt16, theirNodeId: [UInt8]) -> Bool {
         
         var addressObject = sockaddr_in()
-        addressObject.sin_len = UInt8(MemoryLayout.size(ofValue: addressObject))
         addressObject.sin_family = sa_family_t(AF_INET)
-        addressObject.sin_port = CFSwapInt16HostToBig(port)
+        addressObject.sin_port = port.bigEndian
 
         addressObject.sin_addr.s_addr = inet_addr(address)
         
-        let sin_length = addressObject.sin_len
+        let sin_length = UInt8(MemoryLayout.size(ofValue: addressObject))
         let publicKey = Bindings.new_LDKPublicKey(array: theirNodeId)
 
         let result = withUnsafePointer(to: &addressObject, { addressPointer in
index ac800306a5f81cd11f3e2b329deadb6684fbff35..ce2b8030c7d180cf843fd803e6647f2b26e8a8ba 100644 (file)
@@ -7,6 +7,7 @@
 
 import Foundation
 import LDKSwift
+import LDKCHeaders
 
 public class HumanObjectPeerTestInstance {
     
@@ -118,14 +119,10 @@ public class HumanObjectPeerTestInstance {
         
         fileprivate class TestPersister: Persist {
             override func persist_new_channel(id: OutPoint, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ {
-                var result = Result_NoneChannelMonitorUpdateErrZ()
-                result.cOpaqueStruct!.result_ok = true
-                return result
+                return Result_NoneChannelMonitorUpdateErrZ()
             }
             override func update_persisted_channel(id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ {
-                var result = Result_NoneChannelMonitorUpdateErrZ()
-                result.cOpaqueStruct!.result_ok = true
-                return result
+                return Result_NoneChannelMonitorUpdateErrZ()
             }
         }
         
diff --git a/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift b/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift
deleted file mode 100644 (file)
index 9d934ab..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-import XCTest
-@testable import LDKSwift
-@testable import LDKCHeaders
-
-final class LDKSwiftTests: XCTestCase {
-       func testExample() {
-               // This is an example of a functional test case.
-               // Use XCTAssert and related functions to verify your tests produce the correct
-               // results.
-               XCTAssertEqual(check_get_ldk_version(), "Hello, World!")
-       }
-}
diff --git a/LDKSwift/Tests/LDKSwiftTests/MyFeeEstimator.swift b/LDKSwift/Tests/LDKSwiftTests/MyFeeEstimator.swift
new file mode 100644 (file)
index 0000000..8f26094
--- /dev/null
@@ -0,0 +1,18 @@
+//
+//  MyFeeEstimator.swift
+//  LDKSwiftARC
+//
+//  Created by Arik Sosman on 5/17/21.
+//
+
+import Foundation
+import LDKSwift
+import LDKCHeaders
+
+class MyFeeEstimator: FeeEstimator {
+    
+    override func get_est_sat_per_1000_weight(confirmation_target: LDKConfirmationTarget) -> UInt32 {
+        return 253
+    }
+    
+}
diff --git a/LDKSwift/Tests/LDKSwiftTests/MyLogger.swift b/LDKSwift/Tests/LDKSwiftTests/MyLogger.swift
new file mode 100644 (file)
index 0000000..253cd15
--- /dev/null
@@ -0,0 +1,17 @@
+//
+//  MyLogger.swift
+//  LDKSwiftARC
+//
+//  Created by Arik Sosman on 5/17/21.
+//
+
+import Foundation
+import LDKSwift
+
+class MyLogger: Logger {
+    
+    override func log(record: String?) {
+        print("record: \(record)")
+    }
+    
+}