Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicates in BtcNode list #7304

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}
Loading