Build a test jar which we can run to test the built jar is runnable
authorMatt Corallo <git@bluematt.me>
Tue, 15 Jun 2021 22:02:19 +0000 (22:02 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 16 Jun 2021 17:55:44 +0000 (17:55 +0000)
.github/workflows/build.yml
javatester/pom.xml [new file with mode: 0644]
javatester/src/main/java/org/ldk/HumanObjectPeerTest.java [new symlink]
src/test/java/org/ldk/HumanObjectPeerTest.java

index 66c49dea14076b8e1e5cf5097b493ab2e1b810f1..24eb674cbcf5d15431b172c1f5e7ab711be04173 100644 (file)
@@ -53,10 +53,8 @@ jobs:
         run: |
           rm liblightningjni.so
           ln -s liblightningjni_debug_Linux-amd64.so liblightningjni.so
-          export LD_LIBRARY_PATH=.
-          export LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so
           export ASAN_OPTIONS=detect_leaks=0
-          mvn test
+          LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
           git checkout liblightningjni.so
       - name: Build Java/TS Release Bindings
         run: |
@@ -76,3 +74,11 @@ jobs:
       - name: Check latest headers and release lib are in git
         run: |
           git diff --exit-code
+      - name: Run Java Tests against built release jar
+        run: |
+          mvn -DskipTests=true package
+          mvn install:install-file -Dfile=target/ldk-java-1.0-SNAPSHOT.jar -DgroupId=org.ldk -DartifactId=ldk-java -Dversion=1.0-SNAPSHOT -Dpackaging=jar
+          cd javatester
+          mvn package
+          java -ea -jar target/ldk-java-tests-1.0-SNAPSHOT-jar-with-dependencies.jar
+          cd ..
diff --git a/javatester/pom.xml b/javatester/pom.xml
new file mode 100644 (file)
index 0000000..02137e3
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.ldk</groupId>
+    <artifactId>ldk-java-tests</artifactId>
+    <version>1.0-SNAPSHOT</version>
+       <dependencies>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <version>RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.bitcoinj</groupId>
+            <artifactId>bitcoinj-core</artifactId>
+            <version>0.15.10</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <version>RELEASE</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ldk</groupId>
+            <artifactId>ldk-java</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.2.0</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <archive>
+                                <manifest>
+                                    <mainClass>org.ldk.HumanObjectPeerTest</mainClass>
+                                </manifest>
+                            </archive>
+                            <descriptorRefs>
+                                <descriptorRef>jar-with-dependencies</descriptorRef>
+                            </descriptorRefs>
+                        </configuration>
+                    </execution>
+                 </executions>
+             </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/javatester/src/main/java/org/ldk/HumanObjectPeerTest.java b/javatester/src/main/java/org/ldk/HumanObjectPeerTest.java
new file mode 120000 (symlink)
index 0000000..59d3673
--- /dev/null
@@ -0,0 +1 @@
+../../../../../../src/test/java/org/ldk/HumanObjectPeerTest.java
\ No newline at end of file
index bb3859d26582a2bdb105f0b082e800a6d4d91f3f..c6a6f475fbf969fbcb174e0e7f479f7de8d08f76 100644 (file)
@@ -897,4 +897,15 @@ public class HumanObjectPeerTest {
             do_test(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_refs, nio_peer_handler, use_chan_manager_constructor);
         }
     }
+
+    // This is used in the test jar to test the built jar is runnable
+    public static void main(String[] args) {
+        try {
+            new HumanObjectPeerTest().test_message_handler();
+        } catch (Exception e) {
+            System.err.println("Caught exception:");
+            System.err.println(e);
+            System.exit(1);
+        }
+    }
 }