Skip to content

Commit

Permalink
fixed PaxeNetworkTest
Browse files Browse the repository at this point in the history
  • Loading branch information
simbo1905 committed Jan 19, 2025
1 parent 4d6d7e9 commit 2635c00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public PaxeNetwork(SessionKeyManager keyManager, int port, NodeId local,

@Override
public <T> void send(Channel channel, NodeId to, T msg) {
LOGGER.finest(() -> String.format("Sending message on channel %s to %s", channel, to));
LOGGER.finest(() -> String.format("%s Sending message on channel %s to %s", localNode, channel, to));
DirectBuffer buffers = channelBuffers.get(channel);
ByteBuffer buffer = buffers.sendBuffer();
buffer.clear();
Expand Down Expand Up @@ -176,7 +176,6 @@ private void readFromChannel() throws IOException {
SocketAddress sender = channel.receive(buffer);
if (sender == null) continue;


buffer.flip();
if (buffer.remaining() < HEADER_SIZE) {
LOGGER.finest(() -> String.format("Received undersized packet from %s: %d bytes", sender, buffer.remaining()));
Expand Down Expand Up @@ -205,7 +204,7 @@ private void readFromChannel() throws IOException {
byte[] payload = new byte[length];
buffer.get(payload);

if (msgChannel == Channel.KEY_EXCHANGE) {
if (msgChannel.id() == Channel.KEY_EXCHANGE.id()) {
LOGGER.finest(() -> String.format("Processing key exchange from %d", fromId));
handleKeyExchange(fromId, payload);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import org.junit.jupiter.api.*;

import java.time.Duration;
import java.util.*;
import java.util.EmptyStackException;
import java.util.Optional;
import java.util.Stack;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
Expand All @@ -14,8 +16,9 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

@Disabled
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class PaxeStackClusterTest {
public class PaxeStackClusterTest {
private static final Duration TEST_TIMEOUT = Duration.ofSeconds(5);

private NetworkTestHarness harness;
Expand Down Expand Up @@ -46,8 +49,8 @@ static void setupLogging() {
void setup() throws Exception {
harness = new NetworkTestHarness();

PaxeNetwork network1 = harness.createNetwork((short)1);
PaxeNetwork network2 = harness.createNetwork((short)2);
PaxeNetwork network1 = harness.createNetwork((short) 1);
PaxeNetwork network2 = harness.createNetwork((short) 2);

harness.waitForNetworkEstablishment();

Expand Down Expand Up @@ -91,13 +94,16 @@ private TrexNode createNode(short nodeId) {
private TrexEngine createEngine(TrexNode node, boolean isLeader) {
return new TrexEngine(node) {
@Override
protected void setRandomTimeout() {}
protected void setRandomTimeout() {
}

@Override
protected void clearTimeout() {}
protected void clearTimeout() {
}

@Override
protected void setNextHeartbeat() {}
protected void setNextHeartbeat() {
}

{
if (isLeader) {
Expand Down

0 comments on commit 2635c00

Please sign in to comment.