From f4812bab9d9d316c7fe22285fb576a9d00bc7831 Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Sat, 15 Jun 2019 21:43:16 +0300
Subject: [PATCH 01/42] TransactionRequesterWorkerImpl refactoring
---
.../network/TransactionRequesterWorker.java | 2 +-
.../impl/TransactionRequesterWorkerImpl.java | 45 +++++++++++++------
2 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java b/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java
index a5aca7aa..67a809dc 100644
--- a/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java
+++ b/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java
@@ -11,7 +11,7 @@ public interface TransactionRequesterWorker {
/**
* Works through the request queue by sending a request alongside a random tip to each of our neighbors.
*/
- void processRequestQueue();
+ boolean processRequestQueue();
/**
* Starts the background worker that automatically calls {@link #processRequestQueue()} periodically to process the
diff --git a/src/main/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImpl.java b/src/main/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImpl.java
index 37f095d6..4eee5298 100644
--- a/src/main/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImpl.java
+++ b/src/main/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImpl.java
@@ -31,7 +31,7 @@ public class TransactionRequesterWorkerImpl implements TransactionRequesterWorke
/**
* The minimum amount of transactions in the request queue that are required for the worker to trigger.
*/
- private static final int REQUESTER_THREAD_ACTIVATION_THRESHOLD = 50;
+ public static final int REQUESTER_THREAD_ACTIVATION_THRESHOLD = 50;
/**
* The time (in milliseconds) that the worker waits between its iterations.
@@ -106,24 +106,42 @@ public TransactionRequesterWorkerImpl init(Tangle tangle, TransactionRequester t
* traffic like transactions that get relayed by our node.
*/
@Override
- public void processRequestQueue() {
+ public boolean processRequestQueue() {
try {
- if (transactionRequester.numberOfTransactionsToRequest() >= REQUESTER_THREAD_ACTIVATION_THRESHOLD) {
+ if (isActive()) {
TransactionViewModel transaction = getTransactionToSendWithRequest();
- if (transaction != null && transaction.getType() != TransactionViewModel.PREFILLED_SLOT) {
- for (Neighbor neighbor : node.getNeighbors()) {
- try {
- // automatically adds the hash of a requested transaction when sending a packet
- node.sendPacket(transaction, neighbor);
- } catch (Exception e) {
- log.error("unexpected error while sending request to neighbour", e);
- }
- }
+ if (isValidTransaction(transaction)) {
+ sendToNodes(transaction);
+ return true;
}
}
} catch (Exception e) {
log.error("unexpected error while processing the request queue", e);
}
+ return false;
+ }
+
+ private void sendToNodes(TransactionViewModel transaction) {
+ for (Neighbor neighbor : node.getNeighbors()) {
+ try {
+ // automatically adds the hash of a requested transaction when sending a packet
+ node.sendPacket(transaction, neighbor);
+ } catch (Exception e) {
+ log.error("unexpected error while sending request to neighbour", e);
+ }
+ }
+ }
+
+ //@VisibleForTesting
+ boolean isActive() {
+ return transactionRequester.numberOfTransactionsToRequest() >= REQUESTER_THREAD_ACTIVATION_THRESHOLD;
+ }
+
+ //@VisibleForTesting
+ boolean isValidTransaction(TransactionViewModel transaction) {
+ return transaction != null && (
+ transaction.getType() != TransactionViewModel.PREFILLED_SLOT
+ || transaction.getHash().equals(Hash.NULL_HASH));
}
@Override
@@ -146,7 +164,8 @@ public void shutdown() {
* @return a random tip
* @throws Exception if anything unexpected happens while trying to retrieve the random tip.
*/
- private TransactionViewModel getTransactionToSendWithRequest() throws Exception {
+ //@VisibleForTesting
+ TransactionViewModel getTransactionToSendWithRequest() throws Exception {
Hash tip = tipsViewModel.getRandomSolidTipHash();
if (tip == null) {
tip = tipsViewModel.getRandomNonSolidTipHash();
From c23ee53ee9d76889f25d19402022a895344417fe Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Sat, 15 Jun 2019 21:47:46 +0300
Subject: [PATCH 02/42] javadoc was updated
---
.../java/net/helix/hlx/network/TransactionRequesterWorker.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java b/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java
index 67a809dc..6462c353 100644
--- a/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java
+++ b/src/main/java/net/helix/hlx/network/TransactionRequesterWorker.java
@@ -10,6 +10,8 @@
public interface TransactionRequesterWorker {
/**
* Works through the request queue by sending a request alongside a random tip to each of our neighbors.
+ *
+ * @return true when we have send the request to our neighbors, otherwise false
*/
boolean processRequestQueue();
From 414e590eaa224846b724d0c577132f7ef6aa872a Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Sat, 15 Jun 2019 21:58:20 +0300
Subject: [PATCH 03/42] new util functions were added
---
.../net/helix/hlx/TransactionTestUtils.java | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/test/java/net/helix/hlx/TransactionTestUtils.java b/src/test/java/net/helix/hlx/TransactionTestUtils.java
index aa2c3bdf..f2542dff 100644
--- a/src/test/java/net/helix/hlx/TransactionTestUtils.java
+++ b/src/test/java/net/helix/hlx/TransactionTestUtils.java
@@ -2,16 +2,49 @@
import java.util.Random;
import net.helix.hlx.model.Hash;
+import net.helix.hlx.controllers.TransactionViewModel;
+import net.helix.hlx.model.persistables.Transaction;
public class TransactionTestUtils {
private static final Random RND = new Random();
+
+ /**
+ * Generates a transaction hash.
+ *
+ * @return The transaction hash
+ */
public static Hash getTransactionHash() {
byte[] bytes = new byte[Hash.SIZE_IN_BYTES];
RND.nextBytes(bytes);
return net.helix.hlx.model.HashFactory.TRANSACTION.create(bytes);
}
+ /**
+ * Generates a transaction.
+ *
+ * @return The transaction
+ */
+ public static Transaction getTransaction() {
+ byte[] bytes = new byte[TransactionViewModel.SIZE];
+ RND.nextBytes(bytes);
+ Transaction tx = new Transaction();
+ tx.read(bytes);
+ return tx;
+ }
+
+ /**
+ * Generates a transaction with only 0s.
+ *
+ * @return The transaction
+ */
+ public static Transaction get0Transaction() {
+ byte[] bytes = new byte[TransactionViewModel.SIZE];
+ Transaction tx = new Transaction();
+ tx.read(bytes);
+ return tx;
+ }
+
}
From 0789f073d22dea08cf6bbd5053330be3ccf9b0e6 Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Sat, 15 Jun 2019 22:50:07 +0300
Subject: [PATCH 04/42] building a transaction from bytes was added
---
.../net/helix/hlx/TransactionTestUtils.java | 22 ++++++++++++++-----
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/test/java/net/helix/hlx/TransactionTestUtils.java b/src/test/java/net/helix/hlx/TransactionTestUtils.java
index f2542dff..6e5b3351 100644
--- a/src/test/java/net/helix/hlx/TransactionTestUtils.java
+++ b/src/test/java/net/helix/hlx/TransactionTestUtils.java
@@ -30,9 +30,7 @@ public static Hash getTransactionHash() {
public static Transaction getTransaction() {
byte[] bytes = new byte[TransactionViewModel.SIZE];
RND.nextBytes(bytes);
- Transaction tx = new Transaction();
- tx.read(bytes);
- return tx;
+ return buildTransaction(bytes);
}
/**
@@ -42,9 +40,21 @@ public static Transaction getTransaction() {
*/
public static Transaction get0Transaction() {
byte[] bytes = new byte[TransactionViewModel.SIZE];
- Transaction tx = new Transaction();
- tx.read(bytes);
- return tx;
+ return buildTransaction(bytes);
+ }
+
+ /**
+ * Builds a transaction from the bytes.
+ * Make sure the bytes are in the correct order
+ *
+ * @param bytes The bytes to build the transaction
+ * @return The created transaction
+ */
+ public static Transaction buildTransaction(byte[] bytes) {
+ Transaction t = new Transaction();
+ t.read(bytes);
+ t.readMetadata(bytes);
+ return t;
}
}
From 2f8124729ef024529813dd00cb5167df06e15a65 Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Sun, 16 Jun 2019 13:27:39 +0300
Subject: [PATCH 05/42] TangleMockUtils was added
---
.../java/net/helix/hlx/TangleMockUtils.java | 50 +++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 src/test/java/net/helix/hlx/TangleMockUtils.java
diff --git a/src/test/java/net/helix/hlx/TangleMockUtils.java b/src/test/java/net/helix/hlx/TangleMockUtils.java
new file mode 100644
index 00000000..fe6d5855
--- /dev/null
+++ b/src/test/java/net/helix/hlx/TangleMockUtils.java
@@ -0,0 +1,50 @@
+package net.helix.hlx;
+
+import net.helix.hlx.controllers.TransactionViewModel;
+import net.helix.hlx.model.Hash;
+import net.helix.hlx.model.persistables.Transaction;
+import net.helix.hlx.storage.Tangle;
+import net.helix.hlx.utils.Pair;
+
+import org.mockito.Mockito;
+
+
+public class TangleMockUtils {
+
+ /**
+ * Creates an empty transaction, which is marked filled and parsed.
+ * This transaction is returned when the hash is asked to load in the tangle object
+ *
+ * @param tangle mocked tangle object that shall retrieve a milestone object when being queried for it
+ * @param hash transaction hash
+ * @return The newly created (empty) transaction
+ */
+ public static Transaction mockTransaction(Tangle tangle, Hash hash) {
+ Transaction transaction = new Transaction();
+ transaction.bytes = new byte[0];
+ transaction.type = TransactionViewModel.FILLED_SLOT;
+ transaction.parsed = true;
+
+ return mockTransaction(tangle, hash, transaction);
+ }
+
+ /**
+ * Mocks the tangle object by checking for the hash and returning the transaction.
+ *
+ * @param tangle mocked tangle object that shall retrieve a milestone object when being queried for it
+ * @param hash transaction hash
+ * @param transaction the transaction we send back
+ * @return The transaction
+ */
+ public static Transaction mockTransaction(Tangle tangle, Hash hash, Transaction transaction) {
+ try {
+ Mockito.when(tangle.load(Transaction.class, hash)).thenReturn(transaction);
+ Mockito.when(tangle.getLatest(Transaction.class, Hash.class)).thenReturn(new Pair<>(hash, transaction));
+ } catch (Exception e) {
+ // the exception can not be raised since we mock
+ }
+
+ return transaction;
+ }
+
+}
From 1a76844e97ef9c369ee37eb0220dd08f86656ef1 Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Sun, 16 Jun 2019 13:29:06 +0300
Subject: [PATCH 06/42] test for TransactionRequesterWorkerImpl
---
.../TransactionRequesterWorkerImplTest.java | 148 ++++++++++++++++++
1 file changed, 148 insertions(+)
create mode 100644 src/test/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImplTest.java
diff --git a/src/test/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImplTest.java b/src/test/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImplTest.java
new file mode 100644
index 00000000..b2b70082
--- /dev/null
+++ b/src/test/java/net/helix/hlx/network/impl/TransactionRequesterWorkerImplTest.java
@@ -0,0 +1,148 @@
+package net.helix.hlx.network.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import static org.mockito.Mockito.when;
+
+import net.helix.hlx.controllers.TipsViewModel;
+import net.helix.hlx.controllers.TransactionViewModel;
+import net.helix.hlx.model.Hash;
+import net.helix.hlx.model.persistables.Transaction;
+import net.helix.hlx.network.Node;
+import net.helix.hlx.network.TransactionRequester;
+import net.helix.hlx.service.snapshot.SnapshotProvider;
+import net.helix.hlx.storage.Tangle;
+
+import net.helix.hlx.TangleMockUtils;
+import static net.helix.hlx.TransactionTestUtils.getTransaction;
+import static net.helix.hlx.TransactionTestUtils.get0Transaction;
+import static net.helix.hlx.TransactionTestUtils.buildTransaction;
+import static net.helix.hlx.TransactionTestUtils.getTransactionHash;
+
+
+public class TransactionRequesterWorkerImplTest {
+
+ //Good
+ private static final TransactionViewModel TVMRandomNull = new TransactionViewModel(
+ getTransaction(), Hash.NULL_HASH);
+ private static final TransactionViewModel TVMRandomNotNull = new TransactionViewModel(
+ getTransaction(), getTransactionHash());
+ private static final TransactionViewModel TVMAll0Null = new TransactionViewModel(
+ get0Transaction(), Hash.NULL_HASH);
+ private static final TransactionViewModel TVMAll0NotNull = new TransactionViewModel(
+ get0Transaction(), getTransactionHash());
+
+ //Bad
+ private static final TransactionViewModel TVMNullNull = new TransactionViewModel((Transaction)null, Hash.NULL_HASH);
+
+ @Rule
+ public MockitoRule mockitoRule = MockitoJUnit.rule();
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private static SnapshotProvider snapshotProvider;
+
+ private static TransactionRequester requester;
+ private static TransactionRequesterWorkerImpl worker;
+
+ @Mock
+ private Tangle tangle;
+
+ @Mock
+ private Node node;
+
+ @Mock
+ private TipsViewModel tipsVM;
+
+ @Before
+ public void before() {
+ requester = new TransactionRequester(tangle, snapshotProvider);
+
+ worker = new TransactionRequesterWorkerImpl();
+ worker.init(tangle, requester, tipsVM, node);
+ }
+
+ @After
+ public void tearDown() {
+ worker.shutdown();
+ }
+
+ @Test
+ public void workerActive() throws Exception {
+ assertFalse("Empty worker should not be active", worker.isActive());
+
+ fillRequester();
+
+ assertTrue("Worker should be active when it requester is over threshold", worker.isActive());
+ }
+
+ @Test
+ public void processRequestQueueTest() throws Exception {
+ //getTransactionToSendWithRequest starts reading from solid tips, so mock data from that call
+ when(tipsVM.getRandomSolidTipHash()).thenReturn(
+ TVMRandomNull.getHash(),
+ TVMRandomNotNull.getHash(),
+ TVMAll0Null.getHash(),
+ TVMAll0NotNull.getHash(),
+ TVMNullNull.getHash(),
+ null);
+
+ assertFalse("Unfilled queue shouldnt process", worker.processRequestQueue());
+
+ //Requester never goes down since nodes don't really request
+ fillRequester();
+
+ TangleMockUtils.mockTransaction(tangle, TVMRandomNull.getHash(), buildTransaction(TVMRandomNull.getBytes()));
+ assertTrue("Null transaction hash should be processed", worker.processRequestQueue());
+
+ TangleMockUtils.mockTransaction(tangle, TVMRandomNotNull.getHash(), buildTransaction(TVMRandomNotNull.getBytes()));
+ assertTrue("Not null transaction hash should be processed", worker.processRequestQueue());
+
+ TangleMockUtils.mockTransaction(tangle, TVMAll0Null.getHash(), buildTransaction(TVMAll0Null.getBytes()));
+ assertTrue("Null transaction hash should be processed", worker.processRequestQueue());
+
+ TangleMockUtils.mockTransaction(tangle, TVMAll0NotNull.getHash(), buildTransaction(TVMAll0NotNull.getBytes()));
+ assertTrue("All 9s transaction should be processed", worker.processRequestQueue());
+
+ // Null gets loaded as all 0, so type is 0 -> Filled
+ TangleMockUtils.mockTransaction(tangle, TVMNullNull.getHash(), null);
+ assertTrue("0 transaction should be processed", worker.processRequestQueue());
+
+ // null -> NULL_HASH -> gets loaded as all 0 -> filled
+ assertTrue("Null transaction should be processed", worker.processRequestQueue());
+ }
+
+ @Test
+ public void validTipToAddTest() throws Exception {
+ assertTrue("Null transaction hash should always be accepted", worker.isValidTransaction(TVMRandomNull));
+ assertTrue("Not null transaction hash should always be accepted", worker.isValidTransaction(TVMRandomNotNull));
+ assertTrue("Null transaction hash should always be accepted", worker.isValidTransaction(TVMAll0Null));
+ assertTrue("All 9s transaction should be accepted", worker.isValidTransaction(TVMAll0NotNull));
+
+ // Null gets loaded as all 0, so type is 0 -> Filled
+ assertTrue("0 transaction should be accepted", worker.isValidTransaction(TVMNullNull));
+
+ assertFalse("Null transaction should not be accepted", worker.isValidTransaction(null));
+ }
+
+ private void fillRequester() throws Exception {
+ for (int i=0; i< TransactionRequesterWorkerImpl.REQUESTER_THREAD_ACTIVATION_THRESHOLD; i++) {
+ addRequest();
+ }
+ }
+
+ private void addRequest() throws Exception {
+ Hash randomHash = getTransactionHash();
+ TangleMockUtils.mockTransaction(tangle, randomHash);
+ requester.requestTransaction(randomHash, false);
+ }
+
+}
From f6d62e3ae733e72e6cf60a6e7e5e1a22d1935ecf Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 16 Jun 2019 14:05:33 +0200
Subject: [PATCH 07/42] Update changelog
---
changelog.md => CHANGELOG.md | 7 +++++++
1 file changed, 7 insertions(+)
rename changelog.md => CHANGELOG.md (96%)
diff --git a/changelog.md b/CHANGELOG.md
similarity index 96%
rename from changelog.md
rename to CHANGELOG.md
index 62ea9728..42075764 100644
--- a/changelog.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+# 0.5.6
+ - TransactionRequesterWorkerImpl refactoring
+ - Added New util functions
+ - Added build tx from bytes
+ - Added TangleMockUtils
+ - Added Test for TransactionRequesterWorkerImpl
+
# 0.5.5
- Added Unit Tests:
- NodeTest
From 60ed4e1eaa43a973847eb9329e9c346c4df795f4 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 16 Jun 2019 15:17:28 +0200
Subject: [PATCH 08/42] update README.md
---
README.md | 362 ++++++------------------------------------------------
1 file changed, 38 insertions(+), 324 deletions(-)
diff --git a/README.md b/README.md
index 250fbde8..0c61300b 100644
--- a/README.md
+++ b/README.md
@@ -2,19 +2,16 @@

[](https://www.gnu.org/licenses/gpl-3.0)
-# Helix Protocol
+# Helix-1.0
This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://github.com/iotaledger/iri/).
-* **Latest release:** 0.5.5 pre-release
+* **Latest release:** 0.5.6 pre-release
* **License:** GPLv3
## Developers
- Please see the [CONTRIBUTING.md](https://github.com/HelixNetwork/testnet-1.0/blob/dev/CONTRIBUTING.md) and [STYLEGUIDE.md](https://github.com/HelixNetwork/testnet-1.0/blob/dev/STYLEGUIDE.md) if you wish to contribute to this repository!
- Please read and update the [testnet-1.0-specifications](https://github.com/HelixNetwork/helix-specs/blob/master/specs/testnet-1.0.md).
-- You may enable auto-submission of milestones by passing the `-m`-flag and an integer for the delay.
-- You may enable auto-submission of spam by passing: `--spam ` and `--pow-disabled`
-
-These addresses hold value, you may use the corresponding seeds to issue value-transfers.
+- You may want to disable proof of work in the course of testing, to do so just pass the `--pow-disabled` flag.
## Installing
Make sure you have [**Maven**](https://maven.apache.org/) and [**Java 8**](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) installed on your computer.
@@ -24,351 +21,68 @@ Make sure you have [**Maven**](https://maven.apache.org/) and [**Java 8**](https
$ git clone https://github.com/HelixNetwork/testnet-1.0.git
```
### Compile
+Build an executable jar at the `target` directory using maven.
```
$ cd testnet-1.0
-$ mvn clean compile
-$ mvn package
+$ mvn clean package
```
-This will create a `target` directory in which you will find the executable jar file that you can use for the
-
### Launch
-
-```
-java -jar target/helix-.jar -p 14700
-```
-
-With auto-milestone submission:
-```
-java -jar target/helix-.jar -p 14700 -m 30
```
+java -jar target/helix-.jar -p 8085
+```
-## CLI
-
+## Configuration
Option | Shortened version | Description | Example Input
--- | --- | --- | ---
-`--port` | `-p` | This is a *mandatory* option that defines the port to be used to send API commands to your node | `-p 14800`
-`--neighbors` | `-n` | Neighbors that you are connected with will be added via this option. | `-n "udp://148.148.148.148:14700 udp://[2001:db8:a0b:12f0::1]:14700"`
-`--config` | `-c` | Config INI file that can be used instead of CLI options. See more below | `-c sbx.ini`
-`--udp-receiver-port` | `-u` | UDP receiver port | `-u 14800`
-`--tcp-receiver-port` | `-t` | TCP receiver port | `-t 14800`
+`--port` | `-p` | This is a *mandatory* option that defines the port to be used to send API commands to your node | `-p 8085`
+`--neighbors` | `-n` | Neighbors that you are connected with will be added via this option. | `-n "udp://148.148.148.148:4100 udp://[2001:db8:a0b:12f0::1]:4100"`
+`--config` | `-c` | Config INI file that can be used instead of CLI options. See more below | `-c x.ini`
+`--udp-receiver-port` | `-u` | UDP receiver port | `-u 4100`
+`--tcp-receiver-port` | `-t` | TCP receiver port | `-t 5100`
`--ms-delay`| `-m` | Sets delay for auto-milestones. | `-m 60`
`--testnet` | | Testnet flag, bypasses milestone signature validation and overly high mwm. | `--testnet`
`--remote` | | Remotely access your node and send API commands | `--remote`
-`--remote-auth` | | Require authentication password for accessing remotely. Requires a correct `username:hashedpassword` combination | `--remote-auth helixtoken:LL9EZFNCHZCMLJLVUBCKJSWKFEXNYRHHMYS9XQLUZRDEKUUDOCMBMRBWJEMEDDXSDPHIGQULENCRVEYMO`
+`--remote-auth` | | Require authentication password for accessing remotely. Requires a correct `username:hashedpassword` combination passed to the Auth Header. | `--remote-auth helixtoken:a3fcb75bbfc68db05a5207c2afc97fc496ec86e7ecdd6a933be4d1bad8f74c34`
`--remote-limit-api` | | Exclude certain API calls from being able to be accessed remotely | `--remote-limit-api "attachToTangle, addNeighbors"`
`--send-limit`| | Limit the outbound bandwidth consumption. Limit is set to mbit/s | `--send-limit 1.0`
`--max-peers` | | Limit the number of max accepted peers. Default is set to 0 (mutual tethering) | `--max-peers 8`
`--dns-resolution-false` | | Ignores DNS resolution refreshing | `--dns-resolution-false`
`--savelog-enabled` | | Writes the log to file system | `--savelog-enabled`
`--pow-disabled` | | Disables searching and validation of nonce. A feature for simnet. | `--pow-disabled`
-## INI
+### INI
You can also provide an ini file to store all of your command line options and easily update (especially neighbors) if needed. You can enable it via the `--config` flag. Here is an example INI file:
```
-[SBX]
-PORT = 14700
-UDP_RECEIVER_PORT = 14700
-NEIGHBORS = udp://my.favorite.com:15600
+[HLX]
+PORT = 8085
+UDP_RECEIVER_PORT = 4100
+NEIGHBORS = udp://my.favorite.com:5100
HXI_DIR = hxi
HEADLESS = true
DEBUG = true
DB_PATH = db
ZMQ_ENABLED = true
-MS_DELAY = 30
```
## MessageQ
-This is a **work in progress**. Things will change.
-
-MessageQ is a small wrapper for ZeroMQ inside HCP to allow streaming
-of topics from within a running full node. The goal of this is to allow
-for targeted event streams from subscribing clients to the node process.
-
-A client may want to be notified of a change in status of a transaction,
-or may want to see incoming transactions, or any number of data points.
-These can be filtered by topic, and the aim is for machine-readability
-over human readability.
-
-For instance, a light wallet connected to a remote node may want to know
-when a transaction is confirmed. It would, perhaps, after querying the API,
-subscribe to a topic which publishes on the update of a state.
-
-#### Topics
-
-A client interested in tip selection metrics may subscribe to `mctn`, short for
-"monte carlo transaction number", a metric that indicates how many transactions
-were traversed in a random walk simulation. It may subscribe to `rts`, for
-"reason to stop", to see information about walk terminations.
-
-Other topics currently found in the latest code are
-* `dns` for information related to neighbors
-* `hmr` for the hit to miss ratio
-* `antn` for added non-tethered neighbors ( testnet only )
-* `rntn` for refused non-tethered neighbors
-* `rtl` for transactions randomly removed from the request list
-* `lmi` for the latest milestoneTracker index
-* `lmsi` for the latest solid milestoneTracker index
-* `lmhs` for the latest solid milestoneTracker hash
-* `sn` for newly confirmed transactions ( by solid milestoneTracker children measurement )
-* `tx` for newly seen transactions
-* `ct5m2h` confirmed transactions older than 5m and younger than 2h
-* `t5m2h` total transactions older than 5m and younger than 2h
-* `` to watch for an address to be confirmed
-
-All topic must be lowercase (to not clash with `` containing the topic title - like `f89ec2...` & `TX`)
-All of these topics are subject to change, and more may be added; this is experimental code.
-
-## API
-The [**Helix Library**](https://github.com/helixnetwork/helix.api) wraps the primitive api commands, whilst providing the mandatory cryptography to locally sign a transaction and typically do proof of work.
-As the latest build is still being tested, you can preliminarily send http requests using [cURL]().
-### getNodeInfo
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getNodeInfo"}'
-```
-
-**Response**
-```
-{
- "appName":"SBX",
- "appVersion":"0.3.4",
- "jreAvailableProcessors":8,
- "jreFreeMemory":231182400,
- "jreVersion":"1.8.0_171",
- "jreMaxMemory":3817865216,
- "jreTotalMemory":257425408,
- "latestMilestone":"0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343",
- "latestMilestoneIndex":6,
- "latestSolidSubtangleMilestone":"0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343",
- "latestSolidSubtangleMilestoneIndex":6,
- "milestoneStartIndex":0,
- "neighbors":0,
- "packetsQueueSize":0,
- "time":1543586964422,
- "tips":0,
- "transactionsToRequest":0,
- "features":["snapshotPruning","dnsRefresher"],
- "coordinatorAddress":"a3fcb75bbfc68db05a5207c2afc97fc496ec86e7ecdd6a933be4d1bad8f74c34",
- "duration":9
-}
-```
-
-### getNeighbors
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getNeighbors"}'
-```
-**Response**
-```
-{
- "neighbors":[],
- "duration":0
-}
-```
-### addNeighbors
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "addNeighbors", "uris": ["udp://8.8.8.8:14700", "udp://8.8.8.5:14700"]}'
-```
-**Response**
-```
-{
- "addedNeighbors": 0,
- "duration": 2
-}
-```
-### removeNeighbors
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "removeNeighbors", "uris": ["udp://8.8.8.8:14700", "udp://8.8.8.5:14700"]}'
-```
-**Response**
-```
-{
- "removedNeighbors": 0,
- "duration": 2
-}
-```
-### getTips
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getTips"}'
-```
-**Response**
-```
-{
- "hashes":["0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343", "000006ce531ddf7d7bea39274dac4ba7ee1402ffad754cc68471fc59f9a114aab91174116de83fe0919382c1e587284028da9d7774246cf728de44284c65a6b3"],
- "duration":2
-}
-```
-### findTransactions
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "findTransactions", "addresses": ["a3fcb75bbfc68db05a5207c2afc97fc496ec86e7ecdd6a933be4d1bad8f74c34"]}'
-```
-**Response**
-```
-{
- "hashes":["00006c409915cfd8c16b5f9be2f9108966716f7bf5ea64794f92e7ad9d4b0ac8",
- "0000850174174f28682c09835bd2ae5f18157340a6740c35203361c21eaf81b0",
- "00001a8e1d781318c196df2843d32d5ea2674806c92a26faabe6d1e277fdb143",
- "0000883463bdfba5795ece73d200fa95a7617ff61e43f058297380f8e373dbaa",
- "0000809b36c217e3d00ceffe97302157a885ed28b1a4bc66edd28fdce13004c8",
- "0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343"],
- "duration":13
-}
-```
-### getHBytes
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getHBytes", "hashes": ["0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343"]}'
-```
-**Response**
-```
-{
- "hbytes":["0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a3fcb75bbfc68db05a5207c2afc97fc496ec86e7ecdd6a933be4d1bad8f74c34000000000000000000000000000000000000000000000000000000000000000000000000000000000000016764f23c2900000000000000000000000000000000051323892969e8e6d9ee971a79133e3691e1fcee6e133e07e3a87508755f44d30000883463bdfba5795ece73d200fa95a7617ff61e43f058297380f8e373dbaa0000883463bdfba5795ece73d200fa95a7617ff61e43f058297380f8e373dbaa00000000000000060000016764f23c2a0000000000000000000000000000007f94a99460b908004d000000000000000000000000000000000000000000000000"],
- "duration":0
-}
-
-```
-### getInclusionStates
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getInclusionStates", "transactions": ["00001a8e1d781318c196df2843d32d5ea2674806c92a26faabe6d1e277fdb143"], "tips": ["00006c409915cfd8c16b5f9be2f9108966716f7bf5ea64794f92e7ad9d4b0ac8"]}'
-```
-**Response**
-```
-{
- "states":[false],"duration":2
-}
-```
-### getBalances
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getBalances", "addresses": ["d0e7e549a4ffe5b4f8343973f0237db9ede3597baced22715c22dcd8c76ae738"], "threshold": 100}'
-```
-**Response**
-```
-{
- "balances":["536561674354688"],
- "references":["0000cfddd53dc766df017ebbf6691c4b618e86832f2a97e9c59cf1176ffaeef0"],
- "milestoneIndex":2,
- "duration":20
-}
-```
-### getTransactionsToApprove
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "getTransactionsToApprove", "depth": 15, "reference": "0000850174174f28682c09835bd2ae5f18157340a6740c35203361c21eaf81b0"}'
-```
-**Response**
-```
-{
- "trunkTransaction":"0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343",
- "branchTransaction":"0000cfddd53dc766df017ebbf6691c4b618e86832f2a97e9c59cf1176ffaeef0",
- "duration":5
-}
-```
-### attachToTangle
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "attachToTangle", "trunkTransaction": "0000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad343", "branchTransaction": "0000850174174f28682c09835bd2ae5f18157340a6740c35203361c21eaf81b0", "minWeightMagnitude": 2, "hbytes": ["0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005bdd83fd000000000000000100000000000000027aeb69d7e585744a473e82a61fe6fab06b130757ccd329409f56aff1449e1f8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000feff0036003600360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"]}'
-```
-**Response**
-```
-{
- "hbytes":["0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005bdd83fd000000000000000100000000000000027aeb69d7e585744a473e82a61fe6fab06b130757ccd329409f56aff1449e1f840000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad3430000850174174f28682c09835bd2ae5f18157340a6740c35203361c21eaf81b0feff0036003600360000016765232f7f0000000000000000000000000000007faad370633bb3186e000000000000000000000000000000000000000000000000"],
- "duration":1388
-}
-```
-### interruptAttachingToTangle
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "interruptAttachingToTangle"}'
-```
-**Response**
-```
-{
- "duration":1
-}
-```
-### broadcastTransactions
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "broadcastTransactions", "hbytes": ["0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005bdd83fd000000000000000100000000000000027aeb69d7e585744a473e82a61fe6fab06b130757ccd329409f56aff1449e1f840000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad3430000850174174f28682c09835bd2ae5f18157340a6740c35203361c21eaf81b0feff0036003600360000016765232f7f0000000000000000000000000000007faad370633bb3186e000000000000000000000000000000000000000000000000"]}'
-```
-**Response**
-```
-{
- "duration":1005
-}
-```
-### storeTransactions
-**Command**
-```
-curl http://localhost:14700 \
- -X POST \
- -H 'Content-Type: application/json' \
- -H 'X-HELIX-API-Version: 1' \
- -d '{"command": "storeTransactions", "hbytes": ["0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005bdd83fd000000000000000100000000000000027aeb69d7e585744a473e82a61fe6fab06b130757ccd329409f56aff1449e1f840000f13be306d278fae139dc4a54deb40389a8d1c3677a872a9a198f57aad3430000850174174f28682c09835bd2ae5f18157340a6740c35203361c21eaf81b0feff0036003600360000016765232f7f0000000000000000000000000000007faad370633bb3186e000000000000000000000000000000000000000000000000"]}'
-```
-**Response**
-```
-{
- "duration":1017
- }
-```
+MessageQ is a small zmq wrapper for streaming gathered metrics and statistics of topics, enabling targeted event streams from subscribing clients to processes of the node.
+A client interested in real time state updates and notifications could use any desired [zmq-client](https://github.com/zeromq/zeromq.js/) to start listening to topics.
+
+Currently the following topics are covered:
+
+| Topic | Description | Tested?|
+| ---------- | ------------------------------- | ------ |
+| `dns` | Neighbor related info |✓|
+| `hmr` | Hit/miss ration |✖|
+| `antn` | Added non-tethered neighbors (testnet only) |✖|
+| `rntn` | Refused non-tethered neighbors |✖|
+| `rtl` | for transactions randomly removed from the request list|✖|
+| `lmi` | Latest solid milestone index |✓|
+| `lmhs` | Latest solid milestone hash |✓|
+| `sn` | Uses solid milestone's child measurement to publish newly confirmed tx.|✓|
+| `tx` | Newly seen transactions |✓|
+| `ct5s2m` | Confirmed transactions older than 5s and younger than 2m|✓|
+| `t5s2m` | total transactions older than 5s and younger than 2m|✓|
+| ``| Watching all traffic on a specified address|✓|
From 8a324fdde5d4469009e4701359f44fd8bb039cf8 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 16 Jun 2019 15:17:59 +0200
Subject: [PATCH 09/42] bump version
---
pom.xml | 2 +-
src/main/java/net/helix/hlx/HLX.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 591af82e..622291a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
net.helix
helix
- 0.5.5
+ 0.5.6
Helix
Helix-1.0
diff --git a/src/main/java/net/helix/hlx/HLX.java b/src/main/java/net/helix/hlx/HLX.java
index d4410ff2..66017e96 100644
--- a/src/main/java/net/helix/hlx/HLX.java
+++ b/src/main/java/net/helix/hlx/HLX.java
@@ -44,7 +44,7 @@ public class HLX {
public static final String MAINNET_NAME = "HLX";
public static final String TESTNET_NAME = "HLX Testnet";
- public static final String VERSION = "0.5.5";
+ public static final String VERSION = "0.5.6";
/**
* The entry point of the helix sandbox.
From a2e4352beb5a746b06db7fdbb66c9a8828b05164 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 16 Jun 2019 16:08:43 +0200
Subject: [PATCH 10/42] Added missing import
---
src/test/java/net/helix/hlx/TransactionTestUtils.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/test/java/net/helix/hlx/TransactionTestUtils.java b/src/test/java/net/helix/hlx/TransactionTestUtils.java
index 1f3e9161..8ea30974 100644
--- a/src/test/java/net/helix/hlx/TransactionTestUtils.java
+++ b/src/test/java/net/helix/hlx/TransactionTestUtils.java
@@ -7,6 +7,7 @@
import net.helix.hlx.model.Hash;
import net.helix.hlx.model.TransactionHash;
+import net.helix.hlx.model.persistables.Transaction;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.encoders.Hex;
From 076530e09e4d1c9eb127ca692e4919396fb7d052 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 16 Jun 2019 16:09:45 +0200
Subject: [PATCH 11/42] Check that remoteAuth isn't null (#74)
---
.../hlx/service/restserver/resteasy/RestEasy.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/main/java/net/helix/hlx/service/restserver/resteasy/RestEasy.java b/src/main/java/net/helix/hlx/service/restserver/resteasy/RestEasy.java
index f728ec19..9a43e88d 100644
--- a/src/main/java/net/helix/hlx/service/restserver/resteasy/RestEasy.java
+++ b/src/main/java/net/helix/hlx/service/restserver/resteasy/RestEasy.java
@@ -84,7 +84,7 @@ public RestEasy(APIConfig configuration) {
}
/**
- * Prepares the IOTA API for usage. Until this method is called, no HTTP requests can be made.
+ * Prepares the API for usage. Until this method is called, no HTTP requests can be made.
* The order of loading is as follows
*
* -
@@ -259,7 +259,8 @@ private void sendResponse(HttpServerExchange exchange, AbstractResponse res, lon
*
*
* The request process duration is recorded.
- * During this the request gets verified. If it is incorrect, an {@link ErrorResponse} is made.
+ * During this the request gets verified. If it is incorrect, an {@link ErrorResponse}
+ * or in the case of bad authorization {@link AccessLimitedResponse} is thrown.
* Otherwise it is processed in {@link #process(String, InetSocketAddress)}.
* The result is sent back to the requester.
*
@@ -276,11 +277,10 @@ private void processRequest(final HttpServerExchange exchange) throws IOExceptio
AbstractResponse response;
String rcvdToken = (exchange.getRequestHeaders().get("Authorization") == null) ? "" : RemoteAuth.getToken(exchange.getRequestHeaders().get("Authorization").get(0));
-
if (!exchange.getRequestHeaders().contains("X-HELIX-API-Version")) {
response = ErrorResponse.create("Invalid API Version");
- } else if(!this.remoteAuth.equals("") && !rcvdToken.equals(this.remoteAuth)) { // TODO: review and improve the authentication mechanism
- response = ErrorResponse.create("Authorization failed");
+ } else if(this.remoteAuth != null && !this.remoteAuth.equals("") && !rcvdToken.equals(this.remoteAuth)) { // TODO: review and improve the authentication mechanism
+ response = AccessLimitedResponse.create("Authorization failed");
} else if (body.length() > maxBodyLength) {
response = ErrorResponse.create("Request too long");
} else {
From dc41f7bacaea776d59b5591abbee65d53591a4e7 Mon Sep 17 00:00:00 2001
From: spangin <>
Date: Mon, 17 Jun 2019 12:37:42 +0300
Subject: [PATCH 12/42] test for RestEasy server
---
.../hlx/service/restserver/RestEasyTest.java | 132 ++++++++++++++++++
1 file changed, 132 insertions(+)
create mode 100644 src/test/java/net/helix/hlx/service/restserver/RestEasyTest.java
diff --git a/src/test/java/net/helix/hlx/service/restserver/RestEasyTest.java b/src/test/java/net/helix/hlx/service/restserver/RestEasyTest.java
new file mode 100644
index 00000000..02c9dd70
--- /dev/null
+++ b/src/test/java/net/helix/hlx/service/restserver/RestEasyTest.java
@@ -0,0 +1,132 @@
+package net.helix.hlx.service.restserver;
+
+import java.net.InetAddress;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.test.TestPortProvider;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import net.helix.hlx.conf.APIConfig;
+import net.helix.hlx.service.dto.ErrorResponse;
+import net.helix.hlx.service.dto.GetNodeInfoResponse;
+import net.helix.hlx.service.restserver.resteasy.RestEasy;
+
+
+public class RestEasyTest {
+
+ private static final String USER_PASS = "user:pass";
+
+ @Rule
+ public MockitoRule mockitoRule = MockitoJUnit.rule();
+
+ @Mock
+ private APIConfig apiconfig;
+
+ private RestEasy server;
+
+ @Before
+ public void setup() {
+ Mockito.when(apiconfig.getPort()).thenReturn(TestPortProvider.getPort());
+ Mockito.when(apiconfig.getApiHost()).thenReturn(TestPortProvider.getHost());
+ Mockito.when(apiconfig.getMaxBodyLength()).thenReturn(Integer.MAX_VALUE);
+ }
+
+ @After
+ public void shutdown() {
+ this.server.stop();
+ }
+
+ @Test
+ public void nodeInfoMissingApiVersion() {
+ this.server = new RestEasy(apiconfig);
+ this.server.init((String param, InetAddress address) -> {
+ return GetNodeInfoResponse.createEmptyResponse();
+ });
+ this.server.start();
+
+ Client client = ClientBuilder.newClient();
+ String jsonString = "{\"command\": \"getNodeInfo\"}";
+ Response val = client.target(TestPortProvider.generateURL("/"))
+ .request()
+ .post(Entity.entity(jsonString, MediaType.APPLICATION_JSON));
+ ErrorResponse response = val.readEntity(ErrorResponse.class);
+ assertEquals("API version should be required in the header", "Invalid API Version", response.getError());
+ }
+
+ @Test
+ public void nodeInfoValid() {
+ this.server = new RestEasy(apiconfig);
+ this.server.init((String param, InetAddress address) -> {
+ return GetNodeInfoResponse.createEmptyResponse();
+ });
+ this.server.start();
+
+ Client client = ClientBuilder.newClient();
+ String jsonString = "{\"command\": \"getNodeInfo\"}";
+ Response val = client.target(TestPortProvider.generateURL("/"))
+ .request()
+ .header("X-HELIX-API-Version", "1")
+ .post(Entity.entity(jsonString, MediaType.APPLICATION_JSON));
+
+ GetNodeInfoResponse response = val.readEntity(GetNodeInfoResponse.class);
+ assertNotNull("Response should not be parseable as a GetNodeInfoResponse", response);
+ }
+
+ @Test
+ public void notAllowed() {
+ Mockito.when(apiconfig.getRemoteAuth()).thenReturn(USER_PASS);
+
+ this.server = new RestEasy(apiconfig);
+ this.server.init((String param, InetAddress address) -> {
+ return GetNodeInfoResponse.createEmptyResponse();
+ });
+ this.server.start();
+
+ Client client = ClientBuilder.newClient();
+ String jsonString = "{\"command\": \"getNodeInfo\"}";
+ Response val = client.target(TestPortProvider.generateURL("/"))
+ .request()
+ .header("X-HELIX-API-Version", "1")
+ .post(Entity.entity(jsonString, MediaType.APPLICATION_JSON));
+
+ assertEquals("Request should be denied due to lack of authentication",
+ Response.Status.UNAUTHORIZED, val.getStatusInfo());
+ }
+
+ @Test
+ public void allowed() {
+ Mockito.when(apiconfig.getRemoteAuth()).thenReturn(USER_PASS);
+
+ this.server = new RestEasy(apiconfig);
+ this.server.init((String param, InetAddress address) -> {
+ return GetNodeInfoResponse.createEmptyResponse();
+ });
+ this.server.start();
+
+ Client client = ClientBuilder.newClient();
+ String jsonString = "{\"command\": \"getNodeInfo\"}";
+
+ Response val = client.target(TestPortProvider.generateURL("/"))
+ .request()
+ .header("X-HELIX-API-Version", "1")
+ .header("Authorization", USER_PASS)
+ .post(Entity.entity(jsonString, MediaType.APPLICATION_JSON));
+
+ assertEquals("Request should be accepted as we authenticated", Response.Status.OK, val.getStatusInfo());
+ }
+
+}
From 9ace650cbd0b7182c7dc3bc5f9f6006f7480a611 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Mon, 17 Jun 2019 23:25:28 +0200
Subject: [PATCH 13/42] Change defaults for base config
---
src/main/java/net/helix/hlx/conf/BaseHelixConfig.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java b/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java
index 31319862..73afed2d 100644
--- a/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java
+++ b/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java
@@ -816,7 +816,7 @@ public int getSpamDelay() {
public interface Defaults {
//API
- int API_PORT = 14700;
+ int API_PORT = 8085;
String API_HOST = "localhost";
List REMOTE_LIMIT_API = HelixUtils.createImmutableList(); // "addNeighbors", "getNeighbors", "removeNeighbors", "attachToTangle", "interruptAttachingToTangle" <- TODO: limit these in production!
InetAddress REMOTE_LIMIT_API_DEFAULT_HOST = InetAddress.getLoopbackAddress();
@@ -829,8 +829,8 @@ public interface Defaults {
boolean IS_POW_DISABLED = false;
//Network
- int UDP_RECEIVER_PORT = 14600;
- int TCP_RECEIVER_PORT = 15600;
+ int UDP_RECEIVER_PORT = 4100;
+ int TCP_RECEIVER_PORT = 5100;
double P_REMOVE_REQUEST = 0.01d;
int SEND_LIMIT = -1;
int MAX_PEERS = 0;
From 0cb33482ef2c27a9fe69c2e731b37f4987cb3a12 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Mon, 17 Jun 2019 23:25:52 +0200
Subject: [PATCH 14/42] Change defaults for testnet config
---
src/main/java/net/helix/hlx/conf/TestnetConfig.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/net/helix/hlx/conf/TestnetConfig.java b/src/main/java/net/helix/hlx/conf/TestnetConfig.java
index c77f5d3f..c0c010de 100644
--- a/src/main/java/net/helix/hlx/conf/TestnetConfig.java
+++ b/src/main/java/net/helix/hlx/conf/TestnetConfig.java
@@ -170,7 +170,7 @@ public interface Defaults {
int MWM = 1;
int MILESTONE_START_INDEX = 0;
int KEYS_IN_MILESTONE = 10;
- int PACKET_SIZE = 1200;
+ int PACKET_SIZE = 800;
String DB_PATH = "testnetdb";
String DB_LOG_PATH = "testnetdb.log";
}
From 487f5ab10556060ccf70714dff665f7691694f03 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Mon, 17 Jun 2019 23:26:33 +0200
Subject: [PATCH 15/42] Change values in test config
---
.../java/net/helix/hlx/conf/ConfigTest.java | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/test/java/net/helix/hlx/conf/ConfigTest.java b/src/test/java/net/helix/hlx/conf/ConfigTest.java
index e629eece..d9953013 100644
--- a/src/test/java/net/helix/hlx/conf/ConfigTest.java
+++ b/src/test/java/net/helix/hlx/conf/ConfigTest.java
@@ -51,9 +51,9 @@ Test that iterates over common configs. It also attempts to check different type
@Test
public void testArgsParsingMainnet() {
String[] args = {
- "-p", "14000",
- "-u", "13000",
- "-t", "27000",
+ "-p", "8089",
+ "-u", "4200",
+ "-t", "5200",
"-n", "udp://neighbor1 neighbor, tcp://neighbor2",
"--api-host", "1.1.1.1",
"--remote-limit-api", "call1 call2, call3",
@@ -82,9 +82,9 @@ public void testArgsParsingMainnet() {
Assert.assertThat("wrong config class created", helixConfig, CoreMatchers.instanceOf(MainnetConfig.class));
helixConfig.parseConfigFromArgs(args);
- Assert.assertEquals("port value", 14000, helixConfig.getPort());
- Assert.assertEquals("udp port", 13000, helixConfig.getUdpReceiverPort());
- Assert.assertEquals("tcp port", 27000, helixConfig.getTcpReceiverPort());
+ Assert.assertEquals("port value", 8089, helixConfig.getPort());
+ Assert.assertEquals("udp port", 4200, helixConfig.getUdpReceiverPort());
+ Assert.assertEquals("tcp port", 5200, helixConfig.getTcpReceiverPort());
Assert.assertEquals("neighbors", Arrays.asList("udp://neighbor1", "neighbor", "tcp://neighbor2"),
helixConfig.getNeighbors());
Assert.assertEquals("api host", "1.1.1.1", helixConfig.getApiHost());
@@ -119,9 +119,9 @@ public void testRemoteFlag() {
@Test
public void testArgsParsingTestnet() {
String[] args = {
- "-p", "14000",
- "-u", "13000",
- "-t", "27000",
+ "-p", "8089",
+ "-u", "4200",
+ "-t", "5200",
"-n", "udp://neighbor1 neighbor, tcp://neighbor2",
"--api-host", "1.1.1.1",
"--remote-limit-api", "call1 call2, call3",
@@ -150,9 +150,9 @@ public void testArgsParsingTestnet() {
Assert.assertThat("wrong config class created", helixConfig, CoreMatchers.instanceOf(TestnetConfig.class));
helixConfig.parseConfigFromArgs(args);
- Assert.assertEquals("port value", 14000, helixConfig.getPort());
- Assert.assertEquals("udp port", 13000, helixConfig.getUdpReceiverPort());
- Assert.assertEquals("tcp port", 27000, helixConfig.getTcpReceiverPort());
+ Assert.assertEquals("port value", 8089, helixConfig.getPort());
+ Assert.assertEquals("udp port", 4200, helixConfig.getUdpReceiverPort());
+ Assert.assertEquals("tcp port", 5200, helixConfig.getTcpReceiverPort());
Assert.assertEquals("neighbors", Arrays.asList("udp://neighbor1", "neighbor", "tcp://neighbor2"),
helixConfig.getNeighbors());
Assert.assertEquals("api host", "1.1.1.1", helixConfig.getApiHost());
@@ -180,8 +180,8 @@ public void testArgsParsingTestnet() {
@Test
public void testIniParsingMainnet() throws Exception {
String iniContent = new StringBuilder()
- .append("[SBX]").append(System.lineSeparator())
- .append("PORT = 17000").append(System.lineSeparator())
+ .append("[HLX]").append(System.lineSeparator())
+ .append("PORT = 8088").append(System.lineSeparator())
.append("NEIGHBORS = udp://neighbor1 neighbor, tcp://neighbor2").append(System.lineSeparator())
.append("ZMQ_ENABLED = true").append(System.lineSeparator())
.append("P_REMOVE_REQUEST = 0.4").append(System.lineSeparator())
@@ -196,7 +196,7 @@ public void testIniParsingMainnet() throws Exception {
HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, false);
Assert.assertThat("Wrong config class created", helixConfig, CoreMatchers.instanceOf(MainnetConfig.class));
- Assert.assertEquals("PORT", 17000, helixConfig.getPort());
+ Assert.assertEquals("PORT", 8088, helixConfig.getPort());
Assert.assertEquals("NEIGHBORS", Arrays.asList("udp://neighbor1", "neighbor", "tcp://neighbor2"),
helixConfig.getNeighbors());
Assert.assertEquals("ZMQ_ENABLED", true, helixConfig.isZmqEnabled());
@@ -207,8 +207,8 @@ public void testIniParsingMainnet() throws Exception {
@Test
public void testIniParsingTestnet() throws Exception {
String iniContent = new StringBuilder()
- .append("[SBX]").append(System.lineSeparator())
- .append("PORT = 17000").append(System.lineSeparator())
+ .append("[HLX]").append(System.lineSeparator())
+ .append("PORT = 8088").append(System.lineSeparator())
.append("NEIGHBORS = udp://neighbor1 neighbor, tcp://neighbor2").append(System.lineSeparator())
.append("ZMQ_ENABLED = true").append(System.lineSeparator())
.append("DNS_RESOLUTION_ENABLED = true").append(System.lineSeparator())
@@ -229,7 +229,7 @@ public void testIniParsingTestnet() throws Exception {
HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, true);
Assert.assertThat("Wrong config class created", helixConfig, CoreMatchers.instanceOf(TestnetConfig.class));
- Assert.assertEquals("PORT", 17000, helixConfig.getPort());
+ Assert.assertEquals("PORT", 8088, helixConfig.getPort());
Assert.assertEquals("NEIGHBORS", Arrays.asList("udp://neighbor1", "neighbor", "tcp://neighbor2"),
helixConfig.getNeighbors());
Assert.assertEquals("ZMQ_ENABLED", true, helixConfig.isZmqEnabled());
@@ -253,7 +253,7 @@ public void testIniParsingTestnet() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void testInvalidIni() throws IOException {
String iniContent = new StringBuilder()
- .append("[SBX]").append(System.lineSeparator())
+ .append("[HLX]").append(System.lineSeparator())
.append("REVALIDATE")
.toString();
try (Writer writer = new FileWriter(configFile)) {
From 049c4f5f5143a0460e5d32a153b3904e67f6dc1a Mon Sep 17 00:00:00 2001
From: ofo42
Date: Mon, 17 Jun 2019 23:26:52 +0200
Subject: [PATCH 16/42] cleanup
---
src/main/java/net/helix/hlx/Converter.java | 18 ++-------
.../hlx/controllers/ApproveeViewModel.java | 1 -
.../hlx/controllers/BundleViewModel.java | 1 -
.../hlx/controllers/MilestoneViewModel.java | 1 -
.../helix/hlx/controllers/TipsViewModel.java | 37 ++++++++++---------
.../hlx/controllers/TransactionViewModel.java | 28 --------------
6 files changed, 22 insertions(+), 64 deletions(-)
diff --git a/src/main/java/net/helix/hlx/Converter.java b/src/main/java/net/helix/hlx/Converter.java
index 1c5bd070..e0217796 100644
--- a/src/main/java/net/helix/hlx/Converter.java
+++ b/src/main/java/net/helix/hlx/Converter.java
@@ -10,12 +10,12 @@ public static void main(String[] args) {
}
public static String[] bytesToBitStrings(byte[] bytes) {
- String[] bytestring = new String[bytes.length];
+ String[] byteString = new String[bytes.length];
for (int i = 0; i < bytes.length; i++) {
String bits = String.format("%8s", Integer.toBinaryString(bytes[i] & 0xFF)).replace(' ', '0');
- bytestring[i] = bits;
+ byteString[i] = bits;
}
- return bytestring;
+ return byteString;
}
public static byte[] bitsToBytes(String[] bits){
@@ -26,16 +26,4 @@ public static byte[] bitsToBytes(String[] bits){
}
return bytes;
}
-
- public static long bytesToLong(byte[] array, int offset) {
- return
- ((long)(array[offset] & 0xff) << 56) |
- ((long)(array[offset+1] & 0xff) << 48) |
- ((long)(array[offset+2] & 0xff) << 40) |
- ((long)(array[offset+3] & 0xff) << 32) |
- ((long)(array[offset+4] & 0xff) << 24) |
- ((long)(array[offset+5] & 0xff) << 16) |
- ((long)(array[offset+6] & 0xff) << 8) |
- ((long)(array[offset+7] & 0xff));
- }
}
diff --git a/src/main/java/net/helix/hlx/controllers/ApproveeViewModel.java b/src/main/java/net/helix/hlx/controllers/ApproveeViewModel.java
index a07d23ff..ae8de482 100644
--- a/src/main/java/net/helix/hlx/controllers/ApproveeViewModel.java
+++ b/src/main/java/net/helix/hlx/controllers/ApproveeViewModel.java
@@ -15,7 +15,6 @@
* Created by paul on 5/15/17.
*/
-
/**
* The ApproveeViewModel class is an implementation of the HashesViewModel interface.
* It consists of an Indexable transaction hash and the Approvee model,
diff --git a/src/main/java/net/helix/hlx/controllers/BundleViewModel.java b/src/main/java/net/helix/hlx/controllers/BundleViewModel.java
index 0eee8c66..501c50f3 100644
--- a/src/main/java/net/helix/hlx/controllers/BundleViewModel.java
+++ b/src/main/java/net/helix/hlx/controllers/BundleViewModel.java
@@ -15,7 +15,6 @@
* Created by paul on 5/15/17.
*/
-
/**
* The BundleViewModel class is an implementation of the HashesViewModel interface.
* It consists of an Indexable bundle hash and the Bundle model,
diff --git a/src/main/java/net/helix/hlx/controllers/MilestoneViewModel.java b/src/main/java/net/helix/hlx/controllers/MilestoneViewModel.java
index 3fc6a252..f1ef191a 100644
--- a/src/main/java/net/helix/hlx/controllers/MilestoneViewModel.java
+++ b/src/main/java/net/helix/hlx/controllers/MilestoneViewModel.java
@@ -127,7 +127,6 @@ public static MilestoneViewModel latest(Tangle tangle) throws Exception {
return null;
}
-
/**
* Fetches the previously indexed persistable {@link Milestone} object from the database and generates a new
* {@link MilestoneViewModel} from it. If no {@link Milestone} objects exist in the database, it will return null.
diff --git a/src/main/java/net/helix/hlx/controllers/TipsViewModel.java b/src/main/java/net/helix/hlx/controllers/TipsViewModel.java
index 4f9f7f0a..def2160a 100644
--- a/src/main/java/net/helix/hlx/controllers/TipsViewModel.java
+++ b/src/main/java/net/helix/hlx/controllers/TipsViewModel.java
@@ -102,15 +102,8 @@ public Hash getRandomSolidTipHash() {
if (size == 0) {
return getRandomNonSolidTipHash();
}
- int index = seed.nextInt(size);
- Iterator hashIterator;
- hashIterator = solidTips.iterator();
- Hash hash = null;
- while (index-- >= 0 && hashIterator.hasNext()) {
- hash = hashIterator.next();
- }
- return hash;
- //return solidTips.size() != 0 ? solidTips.get(seed.nextInt(solidTips.size())) : getRandomNonSolidTipHash();
+ return getRandomTipHash(size);
+ //return solidTips.size() != 0 ? solidTips.get(seed.nextInt(solidTips.size())) : getRandomNonSolidTipHash(); <- For later stage
}
}
@@ -126,16 +119,24 @@ public Hash getRandomNonSolidTipHash() {
if (size == 0) {
return null;
}
- int index = seed.nextInt(size);
- Iterator hashIterator;
- hashIterator = tips.iterator();
- Hash hash = null;
- while (index-- >= 0 && hashIterator.hasNext()) {
- hash = hashIterator.next();
- }
- return hash;
- //return tips.size() != 0 ? tips.get(seed.nextInt(tips.size())) : null;
+ return getRandomTipHash(size);
+ //return tips.size() != 0 ? tips.get(seed.nextInt(tips.size())) : null; <- For later stage
+ }
+ }
+
+ /**
+ * Helper method for getting a random tip
+ * @return A random tip hash or null
+ */
+ private Hash getRandomTipHash(int size) {
+ int index = seed.nextInt(size);
+ Iterator hashIterator;
+ hashIterator = tips.iterator();
+ Hash hash = null;
+ while (index-- >= 0 && hashIterator.hasNext()) {
+ hash = hashIterator.next();
}
+ return hash;
}
/**
diff --git a/src/main/java/net/helix/hlx/controllers/TransactionViewModel.java b/src/main/java/net/helix/hlx/controllers/TransactionViewModel.java
index 0de1f8fc..2f9fb8bf 100644
--- a/src/main/java/net/helix/hlx/controllers/TransactionViewModel.java
+++ b/src/main/java/net/helix/hlx/controllers/TransactionViewModel.java
@@ -43,10 +43,8 @@ public class TransactionViewModel {
public static final int ATTACHMENT_TIMESTAMP_UPPER_BOUND_OFFSET = ATTACHMENT_TIMESTAMP_LOWER_BOUND_OFFSET + ATTACHMENT_TIMESTAMP_LOWER_BOUND_SIZE, ATTACHMENT_TIMESTAMP_UPPER_BOUND_SIZE = 8;
public static final int NONCE_OFFSET = ATTACHMENT_TIMESTAMP_UPPER_BOUND_OFFSET + ATTACHMENT_TIMESTAMP_UPPER_BOUND_SIZE, NONCE_SIZE = 8;
-
public static final int ESSENCE_OFFSET = ADDRESS_OFFSET, ESSENCE_SIZE = ADDRESS_SIZE + VALUE_SIZE + BUNDLE_NONCE_SIZE + TIMESTAMP_SIZE + CURRENT_INDEX_SIZE + LAST_INDEX_SIZE;
-
private AddressViewModel address;
private ApproveeViewModel approovers;
private TransactionViewModel trunk;
@@ -736,30 +734,4 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(getHash());
}
-
- //TODO: just for testing
- public void print() {
- System.out.println("Signature: " + Hex.toHexString(getSignature()));
- System.out.println("Address: " + Hex.toHexString(getAddressHash().bytes()));
- System.out.println("Value: " + transaction.value);
- System.out.println("Bundle Nonce: " + Hex.toHexString(getBundleNonceHash().bytes()));
- System.out.println("Timestamp: " + getTimestamp());
- System.out.println("Current Index: " + getCurrentIndex());
- System.out.println("Last Index: " + lastIndex());
- System.out.println("Bundle: " + Hex.toHexString(getBundleHash().bytes()));
- System.out.println("Trunk: " + Hex.toHexString(getTrunkTransactionHash().bytes()));
- System.out.println("Branch: " + Hex.toHexString(getBranchTransactionHash().bytes()));
- System.out.println("Tag: " + Hex.toHexString(getTagValue().bytes()));
- System.out.println("Attachment Timestamp: " + getAttachmentTimestamp());
- System.out.println("Attachment Timestamp Lower Bound: " + getAttachmentTimestampLowerBound());
- System.out.println("Attachment Timestamp Upper Bound: " + getAttachmentTimestampUpperBound());
- System.out.println("Nonce: " + Hex.toHexString(getNonce()));
- System.out.println("Solidity: " + isSolid());
- System.out.println("Validity: " + getValidity());
- System.out.println("Type: " + transaction.type);
- System.out.println("Snapshot: " + transaction.snapshot);
- System.out.println("Milestone: " + transaction.milestone);
- System.out.println("Height: " + transaction.height);
-
- }
}
From f6f2d1d85f66f17346be178a231390e319d78110 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 01:52:38 +0200
Subject: [PATCH 17/42] Added code coverage plugin
---
pom.xml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/pom.xml b/pom.xml
index 622291a7..db692a77 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,6 +240,18 @@
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ 2.7
+
+
+ html
+ xml
+
+
+
+
org.apache.maven.plugins
maven-compiler-plugin
From 4d98d2e0b057108088d121adad09d43919aee534 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 01:53:20 +0200
Subject: [PATCH 18/42] Added codecov to ci
---
.travis.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 45f630ec..10778c0c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,6 +38,9 @@ script:
- VERSION=$(mvn help:evaluate -Dexpression=project.version | grep -E '^[0-9.]+')
- echo $VERSION
+after_success:
+ - bash <(curl -s https://codecov.io/bash) -t 5a632b3d-8a56-4705-bb61-be96cd70b0c1
+
notifications:
webhooks:
urls:
From 010610796e04a86a38fbb12af1100cc5777e2e08 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 01:53:58 +0200
Subject: [PATCH 19/42] Added badges
---
README.md | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 0c61300b..fc6a3a1f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,15 @@
-[](https://travis-ci.com/HelixNetwork/sbx)
-
-[](https://www.gnu.org/licenses/gpl-3.0)
+[![doc][1]][2] [![license][3]][4] [![build][5]][6] [![coverage][7]][8] [![chat][9]][10]
+
+[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
+[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
+[3]: https://img.shields.io/badge/License-GPLv3-blue.svg
+[4]: LICENSE
+[5]: https://travis-ci.com/HelixNetwork/testnet-1.0.svg?token=iyim5S8NXU1bnHDx8VMr&branch=master
+[6]: https://travis-ci.com/HelixNetwork/testnet-1.0
+[7]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg
+[8]: https://codecov.io/gh/helixnetwork/testnet-1.0
+[9]: https://img.shields.io/discord/410771391600656395.svg
+[10]: https://discord.gg/PjAKR8q
# Helix-1.0
This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://github.com/iotaledger/iri/).
@@ -10,8 +19,8 @@ This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://
## Developers
- Please see the [CONTRIBUTING.md](https://github.com/HelixNetwork/testnet-1.0/blob/dev/CONTRIBUTING.md) and [STYLEGUIDE.md](https://github.com/HelixNetwork/testnet-1.0/blob/dev/STYLEGUIDE.md) if you wish to contribute to this repository!
-- Please read and update the [testnet-1.0-specifications](https://github.com/HelixNetwork/helix-specs/blob/master/specs/testnet-1.0.md).
-- You may want to disable proof of work in the course of testing, to do so just pass the `--pow-disabled` flag.
+- Please read the [testnet-1.0-specifications](https://github.com/HelixNetwork/helix-specs/blob/master/specs/testnet-1.0.md) before contributing.
+- Disable proof of work in the course of testing by passing `--pow-disabled` flag.
## Installing
Make sure you have [**Maven**](https://maven.apache.org/) and [**Java 8**](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) installed on your computer.
@@ -20,7 +29,7 @@ Make sure you have [**Maven**](https://maven.apache.org/) and [**Java 8**](https
```
$ git clone https://github.com/HelixNetwork/testnet-1.0.git
```
-### Compile
+### Build
Build an executable jar at the `target` directory using maven.
```
$ cd testnet-1.0
From f614c542d3ebe10c5b82d0fd62f84d1f43251e46 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 02:07:22 +0200
Subject: [PATCH 20/42] use jacoco as report for codecov
---
.travis.yml | 6 +++++-
pom.xml | 16 ++--------------
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 10778c0c..3892e127 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,10 @@ jdk:
- openjdk8
- oraclejdk9
+env:
+ global:
+ - CODECOV_TOKEN=:5a632b3d-8a56-4705-bb61-be96cd70b0c1
+
cache:
apt: true
directories:
@@ -39,7 +43,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash) -t 5a632b3d-8a56-4705-bb61-be96cd70b0c1
+ - bash <(curl -s https://codecov.io/bash)
notifications:
webhooks:
diff --git a/pom.xml b/pom.xml
index db692a77..c9d1f293 100644
--- a/pom.xml
+++ b/pom.xml
@@ -240,18 +240,6 @@
-
- org.codehaus.mojo
- cobertura-maven-plugin
- 2.7
-
-
- html
- xml
-
-
-
-
org.apache.maven.plugins
maven-compiler-plugin
@@ -351,7 +339,7 @@
org.jacoco
jacoco-maven-plugin
- 0.7.9
+ 0.8.4
@@ -360,7 +348,7 @@
report
- integration-test
+ test
report
From 97b79c8af26574defd1a68739f2b9a810f65ff1b Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 02:14:45 +0200
Subject: [PATCH 21/42] Fix badge link
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fc6a3a1f..8a63c945 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
[4]: LICENSE
[5]: https://travis-ci.com/HelixNetwork/testnet-1.0.svg?token=iyim5S8NXU1bnHDx8VMr&branch=master
[6]: https://travis-ci.com/HelixNetwork/testnet-1.0
-[7]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg
+[7]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
[8]: https://codecov.io/gh/helixnetwork/testnet-1.0
[9]: https://img.shields.io/discord/410771391600656395.svg
[10]: https://discord.gg/PjAKR8q
From f6b56f7ef307aff05737269e43eab40251cc3b7f Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 03:00:29 +0200
Subject: [PATCH 22/42] Added matrix chat badge
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 8a63c945..ac3804a3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![doc][1]][2] [![license][3]][4] [![build][5]][6] [![coverage][7]][8] [![chat][9]][10]
+[![doc][1]][2] [![license][3]][4] [![build][5]][6] [![coverage][7]][8] [![discord][9]][10] ![matrix][11]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
@@ -8,8 +8,9 @@
[6]: https://travis-ci.com/HelixNetwork/testnet-1.0
[7]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
[8]: https://codecov.io/gh/helixnetwork/testnet-1.0
-[9]: https://img.shields.io/discord/410771391600656395.svg
+[9]: https://img.shields.io/discord/410771391600656395.svg?label=discord
[10]: https://discord.gg/PjAKR8q
+[11]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
# Helix-1.0
This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://github.com/iotaledger/iri/).
From f1ce5b88db9935b32d3e9a8443ef822739d9bee7 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 03:32:45 +0200
Subject: [PATCH 23/42] Added code quality badge and fixes to readme
---
README.md | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index ac3804a3..c85a9210 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,20 @@
-[![doc][1]][2] [![license][3]][4] [![build][5]][6] [![coverage][7]][8] [![discord][9]][10] ![matrix][11]
+
+[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] ![matrix][12]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
-[3]: https://img.shields.io/badge/License-GPLv3-blue.svg
-[4]: LICENSE
-[5]: https://travis-ci.com/HelixNetwork/testnet-1.0.svg?token=iyim5S8NXU1bnHDx8VMr&branch=master
-[6]: https://travis-ci.com/HelixNetwork/testnet-1.0
-[7]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
-[8]: https://codecov.io/gh/helixnetwork/testnet-1.0
-[9]: https://img.shields.io/discord/410771391600656395.svg?label=discord
-[10]: https://discord.gg/PjAKR8q
-[11]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
+[3]: https://img.shields.io/github/release/helixnetwork/testnet-1.0.svg
+[4]: https://img.shields.io/badge/License-GPLv3-blue.svg
+[5]: LICENSE
+[6]: https://travis-ci.com/HelixNetwork/testnet-1.0.svg?token=iyim5S8NXU1bnHDx8VMr&branch=master
+[7]: https://travis-ci.com/HelixNetwork/testnet-1.0
+[8]: https://api.codacy.com/project/badge/Grade/0756a1f4690c453e99da9e242695634d
+[9]: https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=HelixNetwork/testnet-1.0&utm_campaign=Badge_Grade
+[10]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
+[11]: https://codecov.io/gh/helixnetwork/testnet-1.0
+[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
+[13]: https://discord.gg/PjAKR8q
+[14]: https://img.shields.io/discord/410771391600656395.svg?label=discord
# Helix-1.0
This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://github.com/iotaledger/iri/).
From 3a65b03eade6a2ccdacf1c920f275d0d220a60c4 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 03:48:34 +0200
Subject: [PATCH 24/42] Added custom deserializers to ConfigFactory
---
.../net/helix/hlx/conf/ConfigFactory.java | 28 +++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/helix/hlx/conf/ConfigFactory.java b/src/main/java/net/helix/hlx/conf/ConfigFactory.java
index cc00ebab..7eb60ab8 100644
--- a/src/main/java/net/helix/hlx/conf/ConfigFactory.java
+++ b/src/main/java/net/helix/hlx/conf/ConfigFactory.java
@@ -4,6 +4,9 @@
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import net.helix.hlx.conf.deserializers.CustomBoolDeserializer;
+import net.helix.hlx.conf.deserializers.CustomStringDeserializer;
import java.io.File;
import java.io.FileInputStream;
@@ -21,9 +24,20 @@ public static HelixConfig createHelixConfig(boolean isTestnet) {
}
return helixConfig;
}
- public static HelixConfig createFromFile(File configFile, boolean testnet) throws IOException,
- IllegalArgumentException {
+ /**
+ * Creates the {@link HelixConfig} object for {@link TestnetConfig} or {@link MainnetConfig} from config file. Parse
+ * the config file for TESTNET=true. If TESTNET=true is found we creates the
+ * {@link TestnetConfig} object, else creates the {@link MainnetConfig}.
+ *
+ * @param configFile A property file with configuration options.
+ * @param testnet When true a {@link TestnetConfig} is created.
+ * @return the {@link HelixConfig} configuration.
+ *
+ * @throws IOException When config file could not be found.
+ */
+ public static HelixConfig createFromFile(File configFile, boolean testnet) throws IOException {
HelixConfig helixConfig;
+
try (FileInputStream confStream = new FileInputStream(configFile)) {
Properties props = new Properties();
props.load(confStream);
@@ -33,7 +47,17 @@ public static HelixConfig createFromFile(File configFile, boolean testnet) throw
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true);
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
+
+ SimpleModule booleanParser = new SimpleModule("BooleanParser");
+ booleanParser.addDeserializer(Boolean.TYPE, new CustomBoolDeserializer());
+ objectMapper.registerModule(booleanParser);
+
+ SimpleModule stringParser = new SimpleModule("StringParser");
+ stringParser.addDeserializer(String.class, new CustomStringDeserializer());
+ objectMapper.registerModule(stringParser);
+
helixConfig = objectMapper.convertValue(props, helixConfigClass);
}
return helixConfig;
From 73b108394511b7f861b36e32f16af6bec32880c8 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 03:59:02 +0200
Subject: [PATCH 25/42] Added ipc/tcp getters to ZMQConfig
---
.../java/net/helix/hlx/conf/ZMQConfig.java | 30 ++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/helix/hlx/conf/ZMQConfig.java b/src/main/java/net/helix/hlx/conf/ZMQConfig.java
index 535eba45..e5222001 100644
--- a/src/main/java/net/helix/hlx/conf/ZMQConfig.java
+++ b/src/main/java/net/helix/hlx/conf/ZMQConfig.java
@@ -1,14 +1,42 @@
package net.helix.hlx.conf;
public interface ZMQConfig extends Config {
+ /**
+ * @return Descriptions#ZMQ_ENABLED
+ */
boolean isZmqEnabled();
+
+ /**
+ * @return Descriptions#ZMQ_ENABLE_TCP
+ */
+ boolean isZmqEnableTcp();
+
+ /**
+ * @return Descriptions#ZMQ_ENABLE_IPC
+ */
+ boolean isZmqEnableIpc();
+
+ /**
+ * @return Descriptions#ZMQ_PORT
+ */
int getZmqPort();
+
+ /**
+ * @return Descriptions#ZMQ_THREADS
+ */
int getZmqThreads();
+
+ /**
+ * @return Descriptions#ZMQ_IPC
+ */
String getZmqIpc();
interface Descriptions {
- String ZMQ_ENABLED = "Enabling zmq channels.";
String ZMQ_PORT = "The port used to connect to the ZMQ feed";
String ZMQ_IPC = "The path that is used to communicate with ZMQ in IPC";
+ String ZMQ_ENABLED = "Enable zmq channels (deprecated). Use --zmq-enable-tcp or --zmq-enable-ipc instead";
+ String ZMQ_ENABLE_TCP = "Enable zmq channels on tcp port 5556. Use --zmq-port=[PORT] to override.";
+ String ZMQ_ENABLE_IPC = "Enable zmq channels on ipc://iri. Use --zmq-ipc=[SOCKET] to override.";
+ String ZMQ_THREADS = "The threads used by ZMQ publisher";
}
}
From b7a119305218bdf7aa239212d3b20737e16661a9 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 04:00:49 +0200
Subject: [PATCH 26/42] Added parameters for zmq ipc/tcp
---
.../net/helix/hlx/conf/BaseHelixConfig.java | 55 +++++++++++++++++--
1 file changed, 49 insertions(+), 6 deletions(-)
diff --git a/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java b/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java
index 73afed2d..bc21c257 100644
--- a/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java
+++ b/src/main/java/net/helix/hlx/conf/BaseHelixConfig.java
@@ -71,12 +71,19 @@ public abstract class BaseHelixConfig implements HelixConfig {
protected double pPropagateRequest = Defaults.P_PROPAGATE_REQUEST;
//ZMQ
- protected boolean zmqEnabled = Defaults.ZMQ_ENABLED;
+ protected boolean zmqEnableTcp = Defaults.ZMQ_ENABLE_TCP;
+ protected boolean zmqEnableIpc = Defaults.ZMQ_ENABLE_IPC;
protected int zmqPort = Defaults.ZMQ_PORT;
protected int zmqThreads = Defaults.ZMQ_THREADS;
protected String zmqIpc = Defaults.ZMQ_IPC;
protected int qSizeNode = Defaults.QUEUE_SIZE;
protected int cacheSizeBytes = Defaults.CACHE_SIZE_BYTES;
+ /**
+ * @deprecated This field was replaced by {@link #zmqEnableTcp} and {@link #zmqEnableIpc}. It is only needed
+ * for backward compatibility to --zmq-enabled parameter with JCommander.
+ */
+ @Deprecated
+ private boolean zmqEnabled;
//Graphstream
protected boolean graphEnabled = Defaults.GRAPH_ENABLED;
@@ -611,15 +618,48 @@ public int getNumberOfKeysInMilestone() {
return Defaults.NUM_KEYS_IN_MILESTONE;
}
+ /**
+ * Checks if ZMQ is enabled.
+ * @return true if zmqEnableTcp or zmqEnableIpc is set.
+ */
@Override
public boolean isZmqEnabled() {
- return zmqEnabled;
+ return zmqEnableTcp || zmqEnableIpc;
}
+ /**
+ * Activates ZMQ to listen on TCP and IPC.
+ * @deprecated Use {@link #setZmqEnableTcp(boolean) and/or {@link #setZmqEnableIpc(boolean)}} instead.
+ * @param zmqEnabled true if ZMQ should listen in TCP and IPC.
+ */
+ @Deprecated
@JsonProperty
- @Parameter(names = "--zmq-enabled", description = ZMQConfig.Descriptions.ZMQ_ENABLED)
+ @Parameter(names = "--zmq-enabled", description = ZMQConfig.Descriptions.ZMQ_ENABLED, arity = 1)
protected void setZmqEnabled(boolean zmqEnabled) {
- this.zmqEnabled = zmqEnabled;
+ this.zmqEnableTcp = zmqEnabled;
+ this.zmqEnableIpc = zmqEnabled;
+ }
+
+ @Override
+ public boolean isZmqEnableTcp() {
+ return zmqEnableTcp;
+ }
+
+ @JsonProperty
+ @Parameter(names = "--zmq-enable-tcp", description = ZMQConfig.Descriptions.ZMQ_ENABLE_TCP, arity = 1)
+ public void setZmqEnableTcp(boolean zmqEnableTcp) {
+ this.zmqEnableTcp = zmqEnableTcp;
+ }
+
+ @Override
+ public boolean isZmqEnableIpc() {
+ return zmqEnableIpc;
+ }
+
+ @JsonProperty
+ @Parameter(names = "--zmq-enable-ipc", description = ZMQConfig.Descriptions.ZMQ_ENABLE_IPC, arity = 1)
+ public void setZmqEnableIpc(boolean zmqEnableIpc) {
+ this.zmqEnableIpc = zmqEnableIpc;
}
@Override
@@ -631,6 +671,7 @@ public int getZmqPort() {
@Parameter(names = "--zmq-port", description = ZMQConfig.Descriptions.ZMQ_PORT)
protected void setZmqPort(int zmqPort) {
this.zmqPort = zmqPort;
+ this.zmqEnableTcp = true;
}
@Override
@@ -639,7 +680,7 @@ public int getZmqThreads() {
}
@JsonProperty
- @Parameter(names = "--zmq-threads", description = ZMQConfig.Descriptions.ZMQ_PORT)
+ @Parameter(names = "--zmq-threads", description = ZMQConfig.Descriptions.ZMQ_THREADS)
protected void setZmqThreads(int zmqThreads) {
this.zmqThreads = zmqThreads;
}
@@ -653,6 +694,7 @@ public String getZmqIpc() {
@Parameter(names = "--zmq-ipc", description = ZMQConfig.Descriptions.ZMQ_IPC)
protected void setZmqIpc(String zmqIpc) {
this.zmqIpc = zmqIpc;
+ this.zmqEnableIpc = true;
}
@Override
@@ -863,8 +905,9 @@ public interface Defaults {
//Zmq
int ZMQ_THREADS = 1;
+ boolean ZMQ_ENABLE_IPC = false;
String ZMQ_IPC = "ipc://hlx";
- boolean ZMQ_ENABLED = false;
+ boolean ZMQ_ENABLE_TCP = false;
int ZMQ_PORT = 5556;
//Graphstream
From 3a592d7feff8003ed63229473b2f1db18f667360 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 04:01:43 +0200
Subject: [PATCH 27/42] Unit test for ConfigFactory
---
.../net/helix/hlx/conf/ConfigFactoryTest.java | 176 ++++++++++++++++++
1 file changed, 176 insertions(+)
create mode 100644 src/test/java/net/helix/hlx/conf/ConfigFactoryTest.java
diff --git a/src/test/java/net/helix/hlx/conf/ConfigFactoryTest.java b/src/test/java/net/helix/hlx/conf/ConfigFactoryTest.java
new file mode 100644
index 00000000..bef0e31f
--- /dev/null
+++ b/src/test/java/net/helix/hlx/conf/ConfigFactoryTest.java
@@ -0,0 +1,176 @@
+package net.helix.hlx.conf;
+
+import net.helix.hlx.model.Hash;
+import net.helix.hlx.model.HashFactory;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+/**
+ * Tests for the {@link ConfigFactory}
+ */
+public class ConfigFactoryTest {
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+ /**
+ * Creates and validates a Testnet {@link HelixConfig}.
+ */
+ @Test
+ public void createHelixConfigTestnet() {
+ HelixConfig helixConfig = ConfigFactory.createHelixConfig(true);
+ assertTrue("Expected helixConfig as instance of TestnetConfig.", helixConfig instanceof TestnetConfig);
+ assertTrue("Expected helixConfig as Testnet.", helixConfig.isTestnet());
+ }
+
+ /**
+ * Creates and validates a Mainnet {@link HelixConfig}.
+ */
+ @Test
+ public void createHelixConfigMainnet() {
+ HelixConfig helixConfig = ConfigFactory.createHelixConfig(false);
+ assertTrue("Expected helixConfig as instance of MainnetConfig.", helixConfig instanceof MainnetConfig);
+ assertFalse("Expected helixConfig as Mainnet.", helixConfig.isTestnet());
+ }
+
+ /**
+ * Creates and validates a Testnet {@link HelixConfig} with TESTNET=true in config file and
+ * testnet: false as method parameter for {@link ConfigFactory#createFromFile(File, boolean)}.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithTestnetTrueAndFalse() throws IOException {
+ // lets assume in our configFile is TESTNET=true
+ File configFile = createTestnetConfigFile("true");
+
+ // but the parameter is set to testnet=false
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, false);
+ assertTrue("Expected helixConfig as instance of TestnetConfig.", helixConfig instanceof TestnetConfig);
+ assertTrue("Expected helixConfig as Testnet.", helixConfig.isTestnet());
+ }
+
+ /**
+ * Creates and validates a Testnet {@link HelixConfig} with TESTNET=true in config file and
+ * testnet: true as method parameter for {@link ConfigFactory#createFromFile(File, boolean)}.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithTestnetTrueAndTrue() throws IOException {
+ // lets assume in our configFile is TESTNET=true
+ File configFile = createTestnetConfigFile("true");
+
+ // but the parameter is set to testnet=true
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, true);
+ assertTrue("Expected helixConfig as instance of TestnetConfig.", helixConfig instanceof TestnetConfig);
+ assertTrue("Expected helixConfig as Testnet.", helixConfig.isTestnet());
+ }
+
+ /**
+ * Creates and validates a Testnet {@link HelixConfig} with TESTNET=false in config file and
+ * testnet: true as method parameter for {@link ConfigFactory#createFromFile(File, boolean)}.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithTestnetFalseAndTrue() throws IOException {
+ // lets assume in our configFile is TESTNET=false
+ File configFile = createTestnetConfigFile("false");
+
+ // but the parameter is set to testnet=true
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, true);
+ assertTrue("Expected helixConfig as instance of TestnetConfig.", helixConfig instanceof TestnetConfig);
+ assertTrue("Expected helixConfig as Testnet.", helixConfig.isTestnet());
+ }
+
+ /**
+ * Creates and validates a Mainnet {@link HelixConfig} with TESTNET=false in config file and
+ * testnet: false as method parameter for {@link ConfigFactory#createFromFile(File, boolean)}.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithTestnetFalseAndFalse() throws IOException {
+ // lets assume in our configFile is TESTNET=false
+ File configFile = createTestnetConfigFile("false");
+
+ // but the parameter is set to testnet=true
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, false);
+ assertTrue("Expected helixConfig as instance of MainnetConfig.", helixConfig instanceof MainnetConfig);
+ assertFalse("Expected helixConfig as Mainnet.", helixConfig.isTestnet());
+ }
+
+ /**
+ * Test if leading and trailing spaces are trimmed from string in properties file.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithTrailingSpaces() throws IOException {
+ File configFile = createTestnetConfigFile("true");
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, true);
+ Hash expected = HashFactory.ADDRESS.create(
+ "2bebfaee978c03e3263c3e5480b602fb040a120768c41d8bfae6c0c124b8e82a");
+ assertEquals("Expected that leading and trailing spaces were trimmed.", expected, HashFactory.ADDRESS.create(helixConfig.getCoordinator())); // TODO: getCoordinator will return Hash after refactoring
+ }
+
+ /**
+ * Test if trailing spaces are correctly trimmed from integer.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithInteger() throws IOException {
+ File configFile = createTestnetConfigFile("true");
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, true);
+ assertEquals("Expected that trailing spaces are trimmed.", 2, helixConfig.getMilestoneStartIndex());
+ }
+
+ /**
+ * Test if trailing spaces are correctly trimmed from boolean.
+ * @throws IOException when config file not found.
+ */
+ @Test
+ public void createFromFileTestnetWithBoolean() throws IOException {
+ File configFile = createTestnetConfigFile("true");
+ HelixConfig helixConfig = ConfigFactory.createFromFile(configFile, true);
+ assertTrue("Expected that ZMQ is enabled.", helixConfig.isZmqEnabled());
+ }
+
+ /**
+ * Try to create an {@link HelixConfig} from a not existing configFile.
+ * @throws IOException when config file not found.
+ */
+ @Test(expected = FileNotFoundException.class)
+ public void createFromFileTestnetWithFileNotFound() throws IOException {
+ File configFile = new File("doesNotExist.ini");
+ ConfigFactory.createFromFile(configFile, false);
+ }
+
+ private File createTestnetConfigFile(String testnet) throws IOException {
+ Properties properties = new Properties();
+
+ // properties include leading and trailing spaces to test against.
+ properties.setProperty("TESTNET", testnet);
+ properties.setProperty("ZMQ_ENABLED", " TRUE ");
+ properties.setProperty("MWM", "4");
+ properties.setProperty("SNAPSHOT_FILE", "conf/snapshot.txt");
+ properties.setProperty("COORDINATOR", " 2bebfaee978c03e3263c3e5480b602fb040a120768c41d8bfae6c0c124b8e82a ");
+ properties.setProperty("MILESTONE_START_INDEX", "2 ");
+ properties.setProperty("KEYS_IN_MILESTONE", "10");
+ properties.setProperty("MAX_DEPTH", "1000");
+
+ File configFile = folder.newFile("myCustomHelixConfig.ini");
+ FileOutputStream fileOutputStream = new FileOutputStream(configFile);
+ properties.store(fileOutputStream, "Test config file created by Unit test!");
+ fileOutputStream.close();
+
+ return configFile;
+ }
+}
From 3418caf33e7714d376052eed21fd265c7ccc048d Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 04:02:08 +0200
Subject: [PATCH 28/42] Unit test for ZMQConfig
---
.../net/helix/hlx/conf/ZMQConfigTest.java | 88 +++++++++++++++++++
1 file changed, 88 insertions(+)
create mode 100644 src/test/java/net/helix/hlx/conf/ZMQConfigTest.java
diff --git a/src/test/java/net/helix/hlx/conf/ZMQConfigTest.java b/src/test/java/net/helix/hlx/conf/ZMQConfigTest.java
new file mode 100644
index 00000000..100982dd
--- /dev/null
+++ b/src/test/java/net/helix/hlx/conf/ZMQConfigTest.java
@@ -0,0 +1,88 @@
+package net.helix.hlx.conf;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class ZMQConfigTest {
+
+ @Test
+ public void isZmqEnabledLegacy() {
+ String[] args = {
+ "--zmq-enabled", "true",
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertTrue("ZMQ must be globally enabled", config.isZmqEnabled());
+ assertTrue("ZMQ TCP must be enabled", config.isZmqEnableTcp());
+ assertTrue("ZMQ IPC must be enabled", config.isZmqEnableIpc());
+ }
+
+ @Test
+ public void isZmqEnabled() {
+ String[] args = {
+ "--zmq-enable-tcp", "true",
+ "--zmq-enable-ipc", "true",
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertTrue("ZMQ must be globally enabled", config.isZmqEnabled());
+ assertTrue("ZMQ TCP must be enabled", config.isZmqEnableTcp());
+ assertTrue("ZMQ IPC must be enabled", config.isZmqEnableIpc());
+ }
+
+ @Test
+ public void isZmqEnableTcp() {
+ String[] args = {
+ "--zmq-enable-tcp", "true"
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertEquals("ZMQ port must be the default port", 5556, config.getZmqPort());
+ assertTrue("ZMQ TCP must be enabled", config.isZmqEnableTcp());
+ }
+
+ @Test
+ public void isZmqEnableIpc() {
+ String[] args = {
+ "--zmq-enable-ipc", "true"
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertEquals("ZMQ ipc must be the default ipc", "ipc://hlx", config.getZmqIpc());
+ assertTrue("ZMQ IPC must be enabled", config.isZmqEnableIpc());
+ }
+
+ @Test
+ public void getZmqPort() {
+ String[] args = {
+ "--zmq-port", "8899"
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertTrue("ZMQ TCP must be enabled", config.isZmqEnableTcp());
+ assertEquals("ZMQ port must be overridden", 8899, config.getZmqPort());
+ }
+
+ @Test
+ public void getZmqThreads() {
+ String[] args = {
+ "--zmq-threads", "5"
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertEquals("ZMQ threads must be overridden", 5, config.getZmqThreads());
+ }
+
+ @Test
+ public void getZmqIpc() {
+ String[] args = {
+ "--zmq-ipc", "ipc://test"
+ };
+ HelixConfig config = ConfigFactory.createHelixConfig(false);
+ config.parseConfigFromArgs(args);
+ assertTrue("ZMQ IPC must be enabled", config.isZmqEnableIpc());
+ assertEquals("ZMQ ipc must be overridden", "ipc://test", config.getZmqIpc());
+ }
+}
From b5e12b2df1817eda3f9491073eb2d5f588e3be57 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 04:02:34 +0200
Subject: [PATCH 29/42] Update changelog
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 42075764..83382546 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- Added build tx from bytes
- Added TangleMockUtils
- Added Test for TransactionRequesterWorkerImpl
+ - Updated ConfigFactory and added corresponding unit tests
# 0.5.5
- Added Unit Tests:
From ae0200caf33fa7c0ced41be3d0ff4876cfb08032 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 04:23:26 +0200
Subject: [PATCH 30/42] Fix and cleanup ConfigTest
---
.../java/net/helix/hlx/conf/ConfigTest.java | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/test/java/net/helix/hlx/conf/ConfigTest.java b/src/test/java/net/helix/hlx/conf/ConfigTest.java
index d9953013..5db79746 100644
--- a/src/test/java/net/helix/hlx/conf/ConfigTest.java
+++ b/src/test/java/net/helix/hlx/conf/ConfigTest.java
@@ -49,7 +49,7 @@ public static void tearDownAfterClass() throws IOException {
Test that iterates over common configs. It also attempts to check different types of types (double, boolean, string)
*/
@Test
- public void testArgsParsingMainnet() {
+ public void argsParsingMainnetTest() {
String[] args = {
"-p", "8089",
"-u", "4200",
@@ -70,7 +70,7 @@ public void testArgsParsingMainnet() {
"--hxi-dir", "/hxi",
"--db-path", "/db",
"--db-log-path", "/dblog",
- "--zmq-enabled",
+ "--zmq-enabled", "true",
//we ignore this on mainnet
"--mwm", "4",
"--testnet-coordinator", "TTTTTTTTT",
@@ -109,7 +109,7 @@ public void testArgsParsingMainnet() {
}
@Test
- public void testRemoteFlag() {
+ public void remoteFlagTest() {
String[] args = {"--remote"};
HelixConfig helixConfig = ConfigFactory.createHelixConfig(false);
helixConfig.parseConfigFromArgs(args);
@@ -117,7 +117,7 @@ public void testRemoteFlag() {
}
@Test
- public void testArgsParsingTestnet() {
+ public void argsParsingTestnetTest() {
String[] args = {
"-p", "8089",
"-u", "4200",
@@ -138,7 +138,7 @@ public void testArgsParsingTestnet() {
"--hxi-dir", "/hxi",
"--db-path", "/db",
"--db-log-path", "/dblog",
- "--zmq-enabled",
+ "--zmq-enabled", "true",
//we ignore this on mainnet
"--mwm", "4",
"--testnet-coordinator", "TTTTTTTTT",
@@ -178,7 +178,7 @@ public void testArgsParsingTestnet() {
}
@Test
- public void testIniParsingMainnet() throws Exception {
+ public void iniParsingMainnetTest() throws Exception {
String iniContent = new StringBuilder()
.append("[HLX]").append(System.lineSeparator())
.append("PORT = 8088").append(System.lineSeparator())
@@ -205,7 +205,7 @@ public void testIniParsingMainnet() throws Exception {
}
@Test
- public void testIniParsingTestnet() throws Exception {
+ public void iniParsingTestnetTest() throws Exception {
String iniContent = new StringBuilder()
.append("[HLX]").append(System.lineSeparator())
.append("PORT = 8088").append(System.lineSeparator())
@@ -249,7 +249,7 @@ public void testIniParsingTestnet() throws Exception {
//prove that REMOTE did nothing
Assert.assertEquals("API_HOST", helixConfig.getApiHost(), "localhost");
}
- /* TODO should return IllegalArgumentException
+
@Test(expected = IllegalArgumentException.class)
public void testInvalidIni() throws IOException {
String iniContent = new StringBuilder()
@@ -260,7 +260,7 @@ public void testInvalidIni() throws IOException {
writer.write(iniContent);
}
ConfigFactory.createFromFile(configFile, false);
- }*/
+ }
@Test
public void backwardsIniCompatibilityTest() {
@@ -278,7 +278,7 @@ public void backwardsIniCompatibilityTest() {
}
@Test
- public void testDontValidateMIlestoneSigDefaultValue() {
+ public void dontValidateMilestoneSigDefaultValueTest() {
HelixConfig helixConfig = ConfigFactory.createHelixConfig(true);
Assert.assertFalse("By default testnet should be validating milestones",
helixConfig.isDontValidateTestnetMilestoneSig());
From f56aaef85a6f41c0ed0328f41b4b97fba70bd826 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 15:23:33 +0200
Subject: [PATCH 31/42] Add discord badge
---
README.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index c85a9210..f1770fcd 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
-[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] ![matrix][12]
+
+[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] ![matrix][12] [![discord][13]][14]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
@@ -13,8 +13,8 @@
[10]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
[11]: https://codecov.io/gh/helixnetwork/testnet-1.0
[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
-[13]: https://discord.gg/PjAKR8q
-[14]: https://img.shields.io/discord/410771391600656395.svg?label=discord
+[13]: https://img.shields.io/discord/410771391600656395.svg?label=discord
+[14]: https://discord.gg/PjAKR8q
# Helix-1.0
This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://github.com/iotaledger/iri/).
From 63ec72f31e05966ea34e92456d8e856c8f3be53a Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 15:35:50 +0200
Subject: [PATCH 32/42] Fix matrix badge
---
README.md | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index f1770fcd..c3dd26bf 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] ![matrix][12] [![discord][13]][14]
+[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] ![matrix][12] [![discord][14]][15]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
@@ -13,8 +13,9 @@
[10]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
[11]: https://codecov.io/gh/helixnetwork/testnet-1.0
[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
-[13]: https://img.shields.io/discord/410771391600656395.svg?label=discord
-[14]: https://discord.gg/PjAKR8q
+[13]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg
+[14]: https://img.shields.io/discord/410771391600656395.svg?label=discord
+[15]: https://discord.gg/PjAKR8q
# Helix-1.0
This is the 1.0 implementation of the Helix Protocol based on [**IRI**](https://github.com/iotaledger/iri/).
From 4a172e79770030837817147ffac25d4ab4146b81 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 15:39:20 +0200
Subject: [PATCH 33/42] Fix matrix badge2
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index c3dd26bf..70ced24c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] ![matrix][12] [![discord][14]][15]
+[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] [![matrix][12]][13] [![discord][14]][15]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
@@ -12,8 +12,8 @@
[9]: https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=HelixNetwork/testnet-1.0&utm_campaign=Badge_Grade
[10]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
[11]: https://codecov.io/gh/helixnetwork/testnet-1.0
-[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
-[13]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg
+[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
+[13]: https://img.shields.io/matrix/helixnetwork
[14]: https://img.shields.io/discord/410771391600656395.svg?label=discord
[15]: https://discord.gg/PjAKR8q
From d845876fa6dc1314d8f7c1ef386cb1ad0db3e521 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 15:47:40 +0200
Subject: [PATCH 34/42] Properly link to riot.im
---
README.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 70ced24c..0b1201e1 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
-[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] [![matrix][12]][13] [![discord][14]][15]
+
+[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] [![discord][14]][15] [![matrix][12]][13]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
@@ -12,8 +12,8 @@
[9]: https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=HelixNetwork/testnet-1.0&utm_campaign=Badge_Grade
[10]: https://codecov.io/gh/helixnetwork/testnet-1.0/branch/dev/graph/badge.svg?token=0IRQbGplCg
[11]: https://codecov.io/gh/helixnetwork/testnet-1.0
-[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
-[13]: https://img.shields.io/matrix/helixnetwork
+[12]: https://img.shields.io/matrix/helixnetwork:matrix.org.svg?label=matrix
+[13]: https://riot.im/app/#/room/#helixnetwork:matrix.org
[14]: https://img.shields.io/discord/410771391600656395.svg?label=discord
[15]: https://discord.gg/PjAKR8q
@@ -45,7 +45,7 @@ $ mvn clean package
### Launch
```
java -jar target/helix-.jar -p 8085
-```
+```
## Configuration
Option | Shortened version | Description | Example Input
@@ -82,7 +82,7 @@ ZMQ_ENABLED = true
## MessageQ
-MessageQ is a small zmq wrapper for streaming gathered metrics and statistics of topics, enabling targeted event streams from subscribing clients to processes of the node.
+MessageQ is a small zmq wrapper for streaming gathered metrics and statistics of topics, enabling targeted event streams from subscribing clients to processes of the node.
A client interested in real time state updates and notifications could use any desired [zmq-client](https://github.com/zeromq/zeromq.js/) to start listening to topics.
Currently the following topics are covered:
From 4ad683c1b57d58dffc5fcd8b6bb1c7fba8abbb45 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 15:51:11 +0200
Subject: [PATCH 35/42] Comment matrix badge, as unresponsiveness leads to long
loadup times on the readme
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 0b1201e1..16895f4f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-
-[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] [![discord][14]][15] [![matrix][12]][13]
+
+[![license][4]][5] [![build][6]][7] [![grade][8]][9] [![coverage][10]][11] [![discord][14]][15]
[1]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0.svg?label=javadocs
[2]: https://javadoc-badge.appspot.com/helixnetwork/testnet-1.0
From 9256712d757b5608d378ac1a7403ddd88d4a7969 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 15:55:53 +0200
Subject: [PATCH 36/42] Pass token using flag - Test
---
.travis.yml | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 3892e127..10778c0c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,6 @@ jdk:
- openjdk8
- oraclejdk9
-env:
- global:
- - CODECOV_TOKEN=:5a632b3d-8a56-4705-bb61-be96cd70b0c1
-
cache:
apt: true
directories:
@@ -43,7 +39,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash)
+ - bash <(curl -s https://codecov.io/bash) -t 5a632b3d-8a56-4705-bb61-be96cd70b0c1
notifications:
webhooks:
From 6b2f35e690be72b7c156507a40e7827cdffc7d1f Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 16:17:34 +0200
Subject: [PATCH 37/42] Pass token using yml - Test2
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 10778c0c..a3d9b2be 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,7 +39,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash) -t 5a632b3d-8a56-4705-bb61-be96cd70b0c1
+ - bash <(curl -s https://codecov.io/bash)
notifications:
webhooks:
From d407276f39a849bc8e75026425249e7e3ebb87fb Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 16:21:25 +0200
Subject: [PATCH 38/42] Pass token using yml - Test3
---
.travis.yml | 2 +-
codecov.yml | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 codecov.yml
diff --git a/.travis.yml b/.travis.yml
index a3d9b2be..fd6893a0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,7 +39,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash)
+ - bash <(curl -s https://codecov.io/bash)
notifications:
webhooks:
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 00000000..9c03bd5b
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,2 @@
+codecov:
+ token: 5a632b3d-8a56-4705-bb61-be96cd70b0c1
\ No newline at end of file
From ec9ef3116f4d16ef55485dca01b5993632ff2782 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 16:26:03 +0200
Subject: [PATCH 39/42] Pass token using -t diff syntax - Test4
---
.travis.yml | 2 +-
codecov.yml | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
delete mode 100644 codecov.yml
diff --git a/.travis.yml b/.travis.yml
index fd6893a0..9f62c318 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,7 +39,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash)
+ - bash <(curl -s https://codecov.io/bash) -t :5a632b3d-8a56-4705-bb61-be96cd70b0c1
notifications:
webhooks:
diff --git a/codecov.yml b/codecov.yml
deleted file mode 100644
index 9c03bd5b..00000000
--- a/codecov.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-codecov:
- token: 5a632b3d-8a56-4705-bb61-be96cd70b0c1
\ No newline at end of file
From 4b7ff9008549357734d921e0d08cee65ba3a6df5 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 16:31:01 +0200
Subject: [PATCH 40/42] Pass as env parameter Test5
---
.travis.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 9f62c318..1765cb78 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,10 @@ jdk:
- openjdk8
- oraclejdk9
+env:
+ global:
+ - CODECOV_TOKEN=:5a632b3d-8a56-4705-bb61-be96cd70b0c1
+
cache:
apt: true
directories:
@@ -39,7 +43,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash) -t :5a632b3d-8a56-4705-bb61-be96cd70b0c1
+ - bash <(curl -s https://codecov.io/bash)
notifications:
webhooks:
From 6dda9f4082ff98f1c30ecee4f1d6d41ca0a99630 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 16:32:55 +0200
Subject: [PATCH 41/42] generate new token
---
.travis.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 1765cb78..6fbf7baf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@ jdk:
env:
global:
- - CODECOV_TOKEN=:5a632b3d-8a56-4705-bb61-be96cd70b0c1
+ - CODECOV_TOKEN=:84b2530c-63d2-4e67-9aec-fabf6d7ccbde
cache:
apt: true
@@ -43,7 +43,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash)
+ - bash <(curl -s https://codecov.io/bash)
notifications:
webhooks:
From 98572fe6bb671828ee6e762210d3c3c1bd63557e Mon Sep 17 00:00:00 2001
From: ofo42
Date: Tue, 18 Jun 2019 16:53:55 +0200
Subject: [PATCH 42/42] Try flag again without colon Test6
---
.travis.yml | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 6fbf7baf..c864346b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,10 +5,6 @@ jdk:
- openjdk8
- oraclejdk9
-env:
- global:
- - CODECOV_TOKEN=:84b2530c-63d2-4e67-9aec-fabf6d7ccbde
-
cache:
apt: true
directories:
@@ -29,7 +25,7 @@ matrix:
fast_finish: true
script:
-# run tests and integration tests
+# run tests
# see https://stackoverflow.com/questions/34405047/how-do-you-merge-into-another-branch-using-travis-with-git-commands?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
- build_head=$(git rev-parse HEAD)
- git config --replace-all remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
@@ -43,7 +39,7 @@ script:
- echo $VERSION
after_success:
- - bash <(curl -s https://codecov.io/bash)
+ - bash <(curl -s https://codecov.io/bash) -t 84b2530c-63d2-4e67-9aec-fabf6d7ccbde
notifications:
webhooks: