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

Fix uniffi-bindgen and Kotlin full cycle test #185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ categories = ["cryptography::cryptocurrencies"]
crate-type = ["lib", "staticlib", "cdylib"]
name = "ldk_node"

[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[profile.release-smaller]
inherits = "release"
opt-level = 'z' # Optimize for size.
Expand Down Expand Up @@ -83,7 +79,7 @@ proptest = "1.0.0"
regex = "1.5.6"

[build-dependencies]
uniffi = { version = "0.23.0", features = ["build", "cli"], optional = true }
uniffi = { version = "0.23.0", features = ["build"], optional = true }

[profile.release]
panic = "abort"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class LibraryTest {
else -> return
}

val invoice = node2.receivePayment(1000000u, "asdf", 9217u)
val invoice = node2.receivePayment(2500000u, "asdf", 9217u)

node1.sendPayment(invoice)

Expand Down Expand Up @@ -245,7 +245,7 @@ class LibraryTest {
println("Spendable balance 2 after close: $spendableBalance2AfterClose")
assert(spendableBalance1AfterClose > 95000u)
assert(spendableBalance1AfterClose < 100000u)
assertEquals(101000uL, spendableBalance2AfterClose)
assertEquals(102500uL, spendableBalance2AfterClose)

node1.stop()
node2.stop()
Expand Down
9 changes: 9 additions & 0 deletions bindings/uniffi-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "uniffi-bindgen"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
uniffi = { version = "0.23.0", features = ["cli"] }
1 change: 0 additions & 1 deletion uniffi-bindgen.rs → bindings/uniffi-bindgen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fn main() {
#[cfg(feature = "uniffi/cli")]
uniffi::uniffi_bindgen_main()
}
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_kotlin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BINDINGS_DIR="bindings/kotlin"
TARGET_DIR="target/bindings/kotlin"
PROJECT_DIR="ldk-node-jvm"
PACKAGE_DIR="org/lightningdevkit/ldknode"
UNIFFI_BINDGEN_BIN="cargo run --features=uniffi/cli --bin uniffi-bindgen"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
rustup target add x86_64-unknown-linux-gnu || exit 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_kotlin_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BINDINGS_DIR="bindings/kotlin"
TARGET_DIR="target"
PROJECT_DIR="ldk-node-android"
PACKAGE_DIR="org/lightningdevkit/ldknode"
UNIFFI_BINDGEN_BIN="cargo run --features=uniffi/cli --bin uniffi-bindgen"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"
ANDROID_NDK_ROOT="/opt/homebrew/share/android-ndk"
LLVM_ARCH_PATH="darwin-x86_64"
PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/$LLVM_ARCH_PATH/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_python.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
BINDINGS_DIR="./bindings/python"
UNIFFI_BINDGEN_BIN="cargo run --features=uniffi/cli --bin uniffi-bindgen"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"

cargo build --release --features uniffi || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language python -o "$BINDINGS_DIR" || exit 1
Expand Down
2 changes: 1 addition & 1 deletion scripts/uniffi_bindgen_generate_swift.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
BINDINGS_DIR="./bindings/swift"
UNIFFI_BINDGEN_BIN="cargo run --features=uniffi/cli --bin uniffi-bindgen"
UNIFFI_BINDGEN_BIN="cargo run --manifest-path bindings/uniffi-bindgen/Cargo.toml"

cargo build --release || exit 1
$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR" || exit 1
Expand Down