From: Matt Corallo Date: Tue, 27 Jul 2021 23:30:18 +0000 (+0000) Subject: Fix minor build issues, resulting in the tests now running X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=679b87563488ea6e9ed28cc1a4d609f3e22777da;p=ldk-swift-linux Fix minor build issues, resulting in the tests now running --- diff --git a/LDKSwift/Package.swift b/LDKSwift/Package.swift index 4954c02..018bf23 100644 --- a/LDKSwift/Package.swift +++ b/LDKSwift/Package.swift @@ -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"]), diff --git a/LDKSwift/Sources/LDKSwift/batteries/TCPPeerHandler.swift b/LDKSwift/Sources/LDKSwift/batteries/TCPPeerHandler.swift index fd3b022..6fcc731 100644 --- a/LDKSwift/Sources/LDKSwift/batteries/TCPPeerHandler.swift +++ b/LDKSwift/Sources/LDKSwift/batteries/TCPPeerHandler.swift @@ -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 diff --git a/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift b/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift index ac80030..ce2b803 100644 --- a/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift +++ b/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift @@ -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 index 9d934ab..0000000 --- a/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift +++ /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 index 0000000..8f26094 --- /dev/null +++ b/LDKSwift/Tests/LDKSwiftTests/MyFeeEstimator.swift @@ -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 index 0000000..253cd15 --- /dev/null +++ b/LDKSwift/Tests/LDKSwiftTests/MyLogger.swift @@ -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)") + } + +}