Skip to content

Commit

Permalink
Merge pull request #47 from LtbLightning/post-testing-changes-v3
Browse files Browse the repository at this point in the history
Post testing changes v3
  • Loading branch information
BitcoinZavior authored Jul 4, 2024
2 parents b101cd7 + e951bde commit e36e23e
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/precompile_binaries.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [main, upgrade-v0.3.0]
branches: [main, v0.3.0, upgrade-v0.3.0]

name: Precompile Binaries

Expand Down
75 changes: 75 additions & 0 deletions example/integration_test/bolt11_and_12_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:ldk_node/ldk_node.dart' as ldk;
import 'package:path_provider/path_provider.dart';

void main() {
BigInt satsToMsats(int sats) => BigInt.from(sats * 1000);
String mSatsToSats(BigInt mSats) => '${mSats.toInt() ~/ 1000}sats';
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('bolt11_&_bolt12', () {
setUp(() async {});
testWidgets('bolt11_full_cycle', (WidgetTester tester) async {
final directory = await getApplicationDocumentsDirectory();
final ldkCache = "${directory.path}/ldk_cache";
final aliceStoragePath = "$ldkCache/integration/alice";
debugPrint('Alice Storage Path: $aliceStoragePath');
final alice_builder = ldk.Builder.mutinynet()
.setEntropyBip39Mnemonic(
mnemonic: ldk.Mnemonic(
seedPhrase:
"replace force spring cruise nothing select glass erupt medal raise consider pull"))
.setStorageDirPath(aliceStoragePath);
final aliceNode = await alice_builder.build();
await aliceNode.start();
final bobStoragePath = "$ldkCache/integration/bob";
final bob_builder = ldk.Builder.mutinynet()
.setEntropyBip39Mnemonic(
mnemonic: ldk.Mnemonic(
seedPhrase:
"skin hospital fee risk health theory actor kiwi solution desert unhappy hello"))
.setStorageDirPath(bobStoragePath);
debugPrint('Bob Storage Path: $bobStoragePath');
final bobNode = await bob_builder.build();
await bobNode.start();
debugPrint("Manually syncing Alice's node");
await aliceNode.syncWallets();
debugPrint("Manually syncing Bob's node");
final aliceBalance =
(await aliceNode.listBalances()).spendableOnchainBalanceSats;
await bobNode.syncWallets();
expect(aliceBalance, 0);
debugPrint("Alice's onChain balance ${aliceBalance.toString()}");
final bobBalance =
(await bobNode.listBalances()).spendableOnchainBalanceSats;
debugPrint("Bob's onChain balance ${bobBalance.toString()}");

final bobBolt11PaymentHandler = await bobNode.bolt11Payment();
final bobJitInvoice = await bobBolt11PaymentHandler.receiveViaJitChannel(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000,
);
debugPrint("Bob's onChain balance ${bobBalance.toString()}");
final aliceBolt11PaymentHandler = await aliceNode.bolt11Payment();
final aliceJitInvoice =
await aliceBolt11PaymentHandler.receiveViaJitChannel(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000,
);
final aliceLBalance =
(await aliceNode.listBalances()).totalLightningBalanceSats;
debugPrint("Alice's Lightning balance ${aliceLBalance.toString()}");
final bobInvoice = await bobBolt11PaymentHandler.receive(
amountMsat: satsToMsats(10000),
description: 'test',
expirySecs: 9000);
final paymentId =
await aliceBolt11PaymentHandler.send(invoice: bobInvoice);
debugPrint("Alice's payment id ${paymentId.field0}");
});
});
}
55 changes: 51 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.2"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
fixnum:
dependency: transitive
description:
Expand All @@ -102,6 +110,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_driver:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
Expand All @@ -127,10 +140,15 @@ packages:
dependency: transitive
description:
name: freezed_annotation
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
sha256: f54946fdb1fa7b01f780841937b1a80783a20b393485f3f6cdf336fd6f4705f2
url: "https://pub.dev"
source: hosted
version: "2.4.1"
version: "2.4.2"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
google_fonts:
dependency: "direct main"
description:
Expand All @@ -155,6 +173,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
integration_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -286,10 +309,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.5"
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -298,6 +321,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
process:
dependency: transitive
description:
name: process
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -343,6 +374,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
sync_http:
dependency: transitive
description:
name: sync_http
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
term_glyph:
dependency: transitive
description:
Expand Down Expand Up @@ -399,6 +438,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
win32:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
flutter_driver:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
2 changes: 1 addition & 1 deletion lib/src/generated/api/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'types.freezed.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `default`, `default`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `hash`, `hash`, `hash`, `try_from`, `try_from`, `try_from`, `try_from`, `try_from`, `try_from`, `try_from`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `assert_receiver_is_total_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `default`, `default`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `hash`, `hash`, `hash`, `try_from`, `try_from`, `try_from`, `try_from`, `try_from`, `try_from`, `try_from`

/// A Bitcoin address.
///
Expand Down
12 changes: 11 additions & 1 deletion lib/src/root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class Node extends LdkNode {
}
}

///Returns a payment handler allowing to create and pay BOLT 11 invoices.
///Returns a payment handler allowing to create and pay BOLT 11 invoices.
Future<Bolt11Payment> bolt11Payment() async {
try {
final res = await LdkNode.bolt11Payment(ptr: this);
Expand All @@ -409,6 +409,16 @@ class Node extends LdkNode {
}
}

///Returns a payment handler allowing to create and pay BOLT 12 invoices.
Future<Bolt12Payment> bolt12Payment() async {
try {
final res = await LdkNode.bolt12Payment(ptr: this);
return Bolt12Payment._(ptr: res.ptr);
} on error.LdkNodeError catch (e) {
throw mapLdkNodeError(e);
}
}

///Returns a payment handler allowing to send and receive on-chain payments.
Future<OnChainPayment> onChainPayment() async {
try {
Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ldk-node = { version = "= 0.3.0" }


[profile.release]
opt-level = 'z' # Optimize for size.
opt-level = 3 # Optimize for size.
lto = true # Enable Link Time Optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
panic = 'abort'
Expand Down

0 comments on commit e36e23e

Please sign in to comment.