Skip to content

Commit

Permalink
Merge pull request #7304 from alvasw/Fix_duplicates_in_BtcNode_list
Browse files Browse the repository at this point in the history
Fix duplicates in BtcNode list
  • Loading branch information
alejandrogarcia83 authored Nov 20, 2024
2 parents 42f757f + 840319a commit f3c986c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/java/bisq/core/btc/nodes/BtcNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,23 @@ public static List<BtcNodes.BtcNode> toBtcNodesList(Collection<String> nodes) {
.collect(Collectors.toList());
}

@EqualsAndHashCode
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Getter
public static class BtcNode {
private static final int DEFAULT_PORT = Config.baseCurrencyNetworkParameters().getPort(); //8333
static final int DEFAULT_PORT = Config.baseCurrencyNetworkParameters().getPort(); //8333

@EqualsAndHashCode.Include
@Nullable
private final String onionAddress;
@EqualsAndHashCode.Include
@Nullable
private final String hostName;
@Nullable
private final String operator; // null in case the user provides a list of custom btc nodes
@EqualsAndHashCode.Include
@Nullable
private final String address; // IPv4 address
@EqualsAndHashCode.Include
private int port = DEFAULT_PORT;

/**
Expand Down
21 changes: 21 additions & 0 deletions core/src/test/java/bisq/core/btc/nodes/BtcNodeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package bisq.core.btc.nodes;

import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

public class BtcNodeTest {
@Test
void hardcodedAndFilterProvidedNodeShouldBeEqual() {
var aliceHardcodedBtcNode = new BtcNodes.BtcNode(null,
"alice_btc_node.onion", null,
BtcNodes.BtcNode.DEFAULT_PORT, "@Alice");

var aliceNodeFromFilter = new BtcNodes.BtcNode(null,
"alice_btc_node.onion", null,
BtcNodes.BtcNode.DEFAULT_PORT, "Provided by filter");

assertThat(aliceHardcodedBtcNode, equalTo(aliceNodeFromFilter));
}
}

0 comments on commit f3c986c

Please sign in to comment.