Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare 0.0.121 #127

Merged
merged 6 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public struct ChannelManagerConstructionParameters {

fileprivate func router(networkGraph: NetworkGraph?) -> Router {
if let netGraph = networkGraph, let scorer = self.scorer, let scoreParams = self.scoreParams {
return DefaultRouter(networkGraph: netGraph, logger: self.logger, randomSeedBytes: self.entropySource.getSecureRandomBytes(), scorer: scorer.asLockableScore(), scoreParams: scoreParams).asRouter()
return DefaultRouter(networkGraph: netGraph, logger: self.logger, entropySource: self.entropySource, scorer: scorer.asLockableScore(), scoreParams: scoreParams).asRouter()
}
return CMCRouter()
return CMCRouter(messageRouter: MessageRouter())
}
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {
public private(set) var channel_monitors: [(ChannelMonitor, [UInt8])]


public init(channelManagerSerialized: [UInt8], channelMonitorsSerialized: [[UInt8]], networkGraph: NetworkGraphArgument, filter: Filter?, params: ChannelManagerConstructionParameters) throws {
public init(channelManagerSerialized: [UInt8], channelMonitorsSerialized: [[UInt8]], networkGraph: NetworkGraphArgument, filter: Filter?, params: ChannelManagerConstructionParameters, logger: Logger) throws {

self.constructionParameters = params

Expand Down Expand Up @@ -204,7 +204,7 @@ public class ChannelManagerConstructor: NativeTypeWrapper {

if let filter = filter {
for (currentMonitor, _) in self.channel_monitors {
currentMonitor.loadOutputsToWatch(filter: filter)
currentMonitor.loadOutputsToWatch(filter: filter, logger: logger)
}
}

Expand Down
27 changes: 18 additions & 9 deletions ci/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public class HumanObjectPeerTestInstance {
let config = UserConfig.initWithDefault()
let theirNodeId = peerB.channelManager.getOurNodeId()
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
let channelOpenResult = peerA.channelManager.createChannel(theirNetworkKey: theirNodeId, channelValueSatoshis: fundingAmount, pushMsat: 1000, userChannelId: userChannelId, overrideConfig: config)
let channelOpenResult = peerA.channelManager.createChannel(theirNetworkKey: theirNodeId, channelValueSatoshis: fundingAmount, pushMsat: 1000, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)

XCTAssertTrue(channelOpenResult.isOk())
let channels = peerA.channelManager.listChannels()
Expand Down Expand Up @@ -757,7 +757,13 @@ public class HumanObjectPeerTestInstance {
}

let channelManagerConstructor = peer1.constructor!
let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: Bindings.Retry.initWithAttempts(a: 3), channelmanager: channelManagerConstructor.channelManager)

let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromInvoice(invoice: invoice).getValue()!
let paymentId = invoice.paymentHash()!


let invoicePaymentResult = channelManagerConstructor.channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: Bindings.Retry.initWithAttempts(a: 3))
// let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: Bindings.Retry.initWithAttempts(a: 3), channelmanager: channelManagerConstructor.channelManager)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove commented-out line.

XCTAssertTrue(invoicePaymentResult.isOk())

do {
Expand Down Expand Up @@ -853,7 +859,9 @@ public class HumanObjectPeerTestInstance {
try! await Task.sleep(nanoseconds: 0_100_000_000)
}

let invoicePayment = invoicePaymentResult.getValue()!

// let invoicePayment = invoicePaymentResult.getValue()!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove commented-out line.

XCTAssert(invoicePaymentResult.isOk())
XCTAssertEqual(currentChannelABalance, secondChannelBalanceAToB - SEND_MSAT_AMOUNT_A_TO_B)
XCTAssertEqual(currentChannelBBalance, secondChannelBalanceBToA + SEND_MSAT_AMOUNT_A_TO_B)
}
Expand All @@ -874,12 +882,12 @@ public class HumanObjectPeerTestInstance {
let recreatedInvoice = Bolt11Invoice.fromStr(s: invoiceString)
XCTAssertTrue(recreatedInvoice.isOk())

let invoicePaymentResult = Bindings.payZeroValueInvoice(invoice: invoice, amountMsats: SEND_MSAT_AMOUNT_B_TO_A, retryStrategy: Retry.initWithAttempts(a: 3), channelmanager: peer2.channelManager)

let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromZeroAmountInvoice(invoice: invoice, amountMsat: SEND_MSAT_AMOUNT_B_TO_A).getValue()!
let paymentId = invoice.paymentHash()!
let invoicePaymentResult = peer2.channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: Retry.initWithAttempts(a: 3))
if let error = invoicePaymentResult.getError() {
print("value type: \(error.getValueType())")
if let routingError = error.getValueAsSending() {
print("sending error: \(routingError)")
}
print("sending error: \(error)")
}
XCTAssertTrue(invoicePaymentResult.isOk())

Expand Down Expand Up @@ -951,7 +959,8 @@ public class HumanObjectPeerTestInstance {
try! await Task.sleep(nanoseconds: 0_100_000_000)
}

let invoicePayment = invoicePaymentResult.getValue()!
// let invoicePayment = invoicePaymentResult.getValue()!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove commented-out line.

XCTAssert(invoicePaymentResult.isOk())
XCTAssertEqual(currentChannelABalance, prePaymentBalanceAToB + SEND_MSAT_AMOUNT_B_TO_A)
XCTAssertEqual(currentChannelBBalance, prePaymentBalanceBToA - SEND_MSAT_AMOUNT_B_TO_A)
XCTAssertEqual(currentChannelABalance, secondChannelBalanceAToB - SEND_MSAT_AMOUNT_A_TO_B + SEND_MSAT_AMOUNT_B_TO_A)
Expand Down
8 changes: 4 additions & 4 deletions ci/LDKSwift/Tests/LDKSwiftTests/LDKSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class LDKSwiftTests: XCTestCase {
)

let networkGraph = NetworkGraph(network: .Regtest, logger: logger)
let channelManagerConstructor = try ChannelManagerConstructor(channelManagerSerialized: serialized_channel_manager, channelMonitorsSerialized: serializedChannelMonitors, networkGraph: NetworkGraphArgument.instance(networkGraph), filter: filter, params: constructionParameters)
let channelManagerConstructor = try ChannelManagerConstructor(channelManagerSerialized: serialized_channel_manager, channelMonitorsSerialized: serializedChannelMonitors, networkGraph: NetworkGraphArgument.instance(networkGraph), filter: filter, params: constructionParameters, logger: logger)

let channelManager = channelManagerConstructor.channelManager;
let cmPersister = TestChannelManagerPersister(channelManager: channelManager)
Expand Down Expand Up @@ -143,10 +143,10 @@ class LDKSwiftTests: XCTestCase {
let rawInvoice = signedRawInvoice.rawInvoice()
let description = rawInvoice.description()
let descriptionString = description?.intoInner()
XCTAssertEqual(descriptionString, "Invoice description")
XCTAssertEqual(descriptionString!.getA(), "Invoice description")

let singleLineDescriptionString = invoice.intoSignedRaw().rawInvoice().description()?.intoInner()
XCTAssertEqual(singleLineDescriptionString, "Invoice description")
XCTAssertEqual(singleLineDescriptionString!.getA(), "Invoice description")
}

func testWeirdChannelManagerMemoryLeak() async throws {
Expand Down Expand Up @@ -241,7 +241,7 @@ class LDKSwiftTests: XCTestCase {
let reserveAmount: UInt64 = 1000 // a thousand satoshis rserve
let peerPubkey = Self.hexStringToBytes(hexString: "02deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef")!
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
let channelOpenResult = channelManager.createChannel(theirNetworkKey: peerPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, overrideConfig: config)
let channelOpenResult = channelManager.createChannel(theirNetworkKey: peerPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)

let channelOpenError = channelOpenResult.getError()!
print("error type: \(channelOpenError.getValueType())")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,18 @@ class WrappedSignerProviderTests: XCTestCase {
print("entering wrapper: readChanSigner()")
return myKeysManager!.keysManager.asSignerProvider().readChanSigner(reader: reader)
}

override func getDestinationScript() -> Bindings.Result_CVec_u8ZNoneZ {
override func getDestinationScript(channelKeysId: [UInt8]) -> Bindings.Result_CVec_u8ZNoneZ {
print("entering wrapper: getDestinationScript()")
return myKeysManager!.keysManager.asSignerProvider().getDestinationScript()
return myKeysManager!.keysManager.asSignerProvider().getDestinationScript(channelKeysId: channelKeysId)
}

override func getShutdownScriptpubkey() -> Bindings.Result_ShutdownScriptNoneZ {
print("entering wrapper: getShutdownScriptpubkey()")

let randomHex = "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000"
let randomHexBytes = LDKSwiftTests.hexStringToBytes(hexString: randomHex)!
let witnessProgram = ShutdownScript.newWitnessProgram(version: 1, program: randomHexBytes)
let witnessProgram = ShutdownScript.newWitnessProgram(witnessProgram: WitnessProgram(version: 1, program: randomHexBytes))
let witnessBasedScript = witnessProgram.getValue()!

return Result_ShutdownScriptNoneZ.initWithOk(o: witnessBasedScript)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class PolarIntegrationSample {
let channelValueBtcString = "0.013"
let reserveAmount: UInt64 = 1000 // a thousand satoshis rserve
let userChannelId: [UInt8] = [UInt8](repeating: 42, count: 16);
let channelOpenResult = channelManager.createChannel(theirNetworkKey: lndPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, overrideConfig: config)
let channelOpenResult = channelManager.createChannel(theirNetworkKey: lndPubkey, channelValueSatoshis: channelValue, pushMsat: reserveAmount, userChannelId: userChannelId, temporaryChannelId: nil, overrideConfig: config)

if let channelOpenError = channelOpenResult.getError() {
print("error type: \(channelOpenError.getValueType())")
Expand Down Expand Up @@ -204,8 +204,9 @@ public class PolarIntegrationSample {
// let's not pay any invoices
// channelManagerConstructor.interrupt(tcpPeerHandler: tcpPeerHandler)
// return

let invoicePaymentResult = Bindings.payInvoice(invoice: invoice, retryStrategy: constructionParameters.payerRetries, channelmanager: channelManager)
let (paymentHash, recipientOnion, routeParameters) = Bindings.paymentParametersFromInvoice(invoice: invoice).getValue()!
let paymentId = invoice.paymentHash()!
let invoicePaymentResult = channelManager.sendPayment(paymentHash: paymentHash, recipientOnion: recipientOnion, paymentId: paymentId, routeParams: routeParameters, retryStrategy: constructionParameters.payerRetries)

do {
// process payment
Expand Down