This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/master by this push:
new 915f458 Add a delay to client, and more assertions to catch issue
new 0a80370 Merge pull request #229 from atoulme/pxy_test_failure
915f458 is described below
commit 915f458f50876be402ea8928a38b9b00b57dde74
Author: Antoine Toulme <[email protected]>
AuthorDate: Sat May 1 21:12:55 2021 -0700
Add a delay to client, and more assertions to catch issue
---
.../apache/tuweni/devp2p/proxy/SendDataToAnotherNodeTest.kt | 10 ++++++++--
.../main/kotlin/org/apache/tuweni/devp2p/proxy/ProxyClient.kt | 5 +++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git
a/devp2p-proxy/src/integrationTest/kotlin/org/apache/tuweni/devp2p/proxy/SendDataToAnotherNodeTest.kt
b/devp2p-proxy/src/integrationTest/kotlin/org/apache/tuweni/devp2p/proxy/SendDataToAnotherNodeTest.kt
index 0522264..55f4f7f 100644
---
a/devp2p-proxy/src/integrationTest/kotlin/org/apache/tuweni/devp2p/proxy/SendDataToAnotherNodeTest.kt
+++
b/devp2p-proxy/src/integrationTest/kotlin/org/apache/tuweni/devp2p/proxy/SendDataToAnotherNodeTest.kt
@@ -17,6 +17,7 @@
package org.apache.tuweni.devp2p.proxy
import io.vertx.core.Vertx
+import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.apache.tuweni.bytes.Bytes
import org.apache.tuweni.concurrent.AsyncCompletion
@@ -27,6 +28,8 @@ import org.apache.tuweni.junit.VertxExtension
import org.apache.tuweni.junit.VertxInstance
import org.apache.tuweni.rlpx.vertx.VertxRLPxService
import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.assertNotNull
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import java.net.InetSocketAddress
@@ -62,9 +65,12 @@ class SendDataToAnotherNodeTest {
AsyncCompletion.allOf(service.start(), service2.start()).await()
val client = service.getClient(ProxySubprotocol.ID) as ProxyClient
client.registeredSites["datasink"] = recorder
- service.connectTo(service2kp.publicKey(), InetSocketAddress("127.0.0.1",
service2.actualPort())).await()
-
+ val conn = service.connectTo(service2kp.publicKey(),
InetSocketAddress("127.0.0.1", service2.actualPort())).await()
+ assertNotNull(conn)
+ delay(100)
+ assertTrue(conn.agreedSubprotocols().contains(ProxySubprotocol.ID))
val client2 = service2.getClient(ProxySubprotocol.ID) as ProxyClient
+ assertTrue(client2.knownSites().contains("datasink"))
client2.request("datasink", Bytes.wrap("Hello world".toByteArray()))
client2.request("datasink", Bytes.wrap("foo".toByteArray()))
client2.request("datasink", Bytes.wrap("foobar".toByteArray()))
diff --git
a/devp2p-proxy/src/main/kotlin/org/apache/tuweni/devp2p/proxy/ProxyClient.kt
b/devp2p-proxy/src/main/kotlin/org/apache/tuweni/devp2p/proxy/ProxyClient.kt
index 23bccc9..7e2b1fb 100644
--- a/devp2p-proxy/src/main/kotlin/org/apache/tuweni/devp2p/proxy/ProxyClient.kt
+++ b/devp2p-proxy/src/main/kotlin/org/apache/tuweni/devp2p/proxy/ProxyClient.kt
@@ -34,6 +34,11 @@ class ProxyError(message: String?) :
RuntimeException(message)
class ProxyClient(private val service: SubprotocolService) : SubProtocolClient
{
+ fun knownSites(): List<String> = service.repository().asIterable().map {
+ val peerInfo = proxyPeerRepository.peers[it.uri()]
+ peerInfo?.sites
+ }.filterNotNull().flatten().distinct()
+
suspend fun request(site: String, message: Bytes): Bytes {
val messageId = UUID.randomUUID().toString()
var selectedConn: WireConnection? = null
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]