import java.io.IOException;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import net.pterodactylus.fcp.GetNode;
private final ListeningExecutorService threadPool;
private final ConnectionSupplier connectionSupplier;
+ private final AtomicBoolean giveOpennetRef = new AtomicBoolean(false);
public GetNodeCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
this.threadPool = MoreExecutors.listeningDecorator(threadPool);
}
@Override
+ public GetNodeCommand opennetRef() {
+ giveOpennetRef.set(true);
+ return this;
+ }
+
+ @Override
public ListenableFuture<NodeData> execute() {
- GetNode getNode = new GetNode(new RandomIdentifierGenerator().generate(), false, false, false);
+ GetNode getNode = new GetNode(new RandomIdentifierGenerator().generate(), giveOpennetRef.get(), false, false);
return threadPool.submit(() -> new GetNodeReplySequence().send(getNode).get());
}
assertThat(nodeData.get(), notNullValue());
}
+ @Test
+ public void defaultFcpClientCanGetNodeInformationWithOpennetRef()
+ throws InterruptedException, ExecutionException, IOException {
+ Future<NodeData> nodeData = fcpClient.getNode().opennetRef().execute();
+ connectNode();
+ List<String> lines = fcpServer.collectUntil(is("EndMessage"));
+ String identifier = extractIdentifier(lines);
+ assertThat(lines, matchesFcpMessage(
+ "GetNode",
+ "Identifier=" + identifier,
+ "GiveOpennetRef=true",
+ "WithPrivate=false",
+ "WithVolatile=false",
+ "EndMessage"
+ ));
+ fcpServer.writeLine(
+ "NodeData",
+ "Identifier=" + identifier,
+ "opennet=true",
+ "ark.pubURI=SSK@3YEf.../ark",
+ "ark.number=78",
+ "auth.negTypes=2",
+ "version=Fred,0.7,1.0,1466",
+ "lastGoodVersion=Fred,0.7,1.0,1466",
+ "EndMessage"
+ );
+ assertThat(nodeData.get().getVersion().toString(), is("Fred,0.7,1.0,1466"));
+ }
+
}