Skip to content

Commit 88b220f

Browse files
committed
Build a test jar which we can run to test the built jar is runnable
1 parent a40eeed commit 88b220f

File tree

4 files changed

+89
-3
lines changed

4 files changed

+89
-3
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ jobs:
5353
run: |
5454
rm liblightningjni.so
5555
ln -s liblightningjni_debug_Linux-amd64.so liblightningjni.so
56-
export LD_LIBRARY_PATH=.
57-
export LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so
5856
export ASAN_OPTIONS=detect_leaks=0
59-
mvn test
57+
LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
6058
git checkout liblightningjni.so
6159
- name: Build Java/TS Release Bindings
6260
run: |
@@ -76,3 +74,11 @@ jobs:
7674
- name: Check latest headers and release lib are in git
7775
run: |
7876
git diff --exit-code
77+
- name: Run Java Tests against built release jar
78+
run: |
79+
mvn -DskipTests=true package
80+
mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
81+
cd javatester
82+
mvn package
83+
java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
84+
cd ..

javatester/pom.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>org.ldk</groupId>
8+
<artifactId>ldk-java-tests</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<dependencies>
11+
<dependency>
12+
<groupId>org.junit.jupiter</groupId>
13+
<artifactId>junit-jupiter-api</artifactId>
14+
<version>RELEASE</version>
15+
<scope>compile</scope>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.bitcoinj</groupId>
19+
<artifactId>bitcoinj-core</artifactId>
20+
<version>0.15.10</version>
21+
<scope>compile</scope>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.jetbrains</groupId>
25+
<artifactId>annotations</artifactId>
26+
<version>RELEASE</version>
27+
<scope>compile</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.ldk</groupId>
31+
<artifactId>ldk-java</artifactId>
32+
<version>1.0-SNAPSHOT</version>
33+
<scope>compile</scope>
34+
</dependency>
35+
</dependencies>
36+
<properties>
37+
<maven.compiler.source>1.8</maven.compiler.source>
38+
<maven.compiler.target>1.8</maven.compiler.target>
39+
</properties>
40+
41+
<build>
42+
<plugins>
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-assembly-plugin</artifactId>
46+
<version>3.2.0</version>
47+
<executions>
48+
<execution>
49+
<phase>package</phase>
50+
<goals>
51+
<goal>single</goal>
52+
</goals>
53+
<configuration>
54+
<archive>
55+
<manifest>
56+
<mainClass>org.ldk.HumanObjectPeerTest</mainClass>
57+
</manifest>
58+
</archive>
59+
<descriptorRefs>
60+
<descriptorRef>jar-with-dependencies</descriptorRef>
61+
</descriptorRefs>
62+
</configuration>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../../src/test/java/org/ldk/HumanObjectPeerTest.java

src/test/java/org/ldk/HumanObjectPeerTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,4 +897,15 @@ public void test_message_handler() throws InterruptedException {
897897
do_test(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_refs, nio_peer_handler, use_chan_manager_constructor);
898898
}
899899
}
900+
901+
// This is used in the test jar to test the built jar is runnable
902+
public static void main(String[] args) {
903+
try {
904+
new HumanObjectPeerTest().test_message_handler();
905+
} catch (Exception e) {
906+
System.err.println("Caught exception:");
907+
System.err.println(e);
908+
System.exit(1);
909+
}
910+
}
900911
}

0 commit comments

Comments
 (0)