Skip to content

Commit

Permalink
Merge pull request #4 from torusresearch/querystring
Browse files Browse the repository at this point in the history
fix: socket query string
  • Loading branch information
metalurgical authored Sep 4, 2023
2 parents 5a70bba + 808f764 commit cb68693
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static EndpointsData generateEndpoints(int parties, int clientIndex) {
}

@Test
public void testExample() throws Exception, DKLSError {
public void testExample() throws Exception {
int parties = 4;
String msg = "hello world";
String msgHash = TSSHelpers.hashMessage(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.web3auth.tss_client_android.client.TSSHelpers.padLeft;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import com.web3auth.tss_client_android.client.TSSClientError;
import com.web3auth.tss_client_android.client.TSSHelpers;
Expand Down Expand Up @@ -58,11 +57,11 @@ public void testGetDKLSCoefficient() throws TSSClientError {
BigInteger userTssIndex1 = new BigInteger("3");
BigInteger dklsCoeff = TSSHelpers.getDKLSCoefficient(true, List.of(participatingServerIndexes1), userTssIndex1, null);
BigInteger compare = new BigInteger("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a1", 16);
assertTrue(dklsCoeff.equals(compare));
assertEquals(dklsCoeff, compare);

BigInteger coeff2 = TSSHelpers.getDKLSCoefficient(false, List.of(new BigInteger[]{new BigInteger("1"), new BigInteger("2"), new BigInteger("5")}), new BigInteger("3"), new BigInteger("2"));
BigInteger comp = new BigInteger("955555555555555555555555555555549790ab8690ea5d782fe561d2241fa611", 16);
assertTrue(coeff2.equals(comp));
assertEquals(coeff2, comp);

BigInteger[] participatingServerIndexes = {new BigInteger("100"), new BigInteger("200")};
BigInteger userTssIndex = new BigInteger("100");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
import io.socket.engineio.client.transports.WebSocket;

public class TSSSocket {
Expand All @@ -24,7 +23,7 @@ public TSSSocket(String session, int party, String socketURL) {
boolean local_servers = System.getProperty("LOCAL_SERVERS") != null;
if (local_servers) {
options = IO.Options.builder()
.setQuery(session.split(Delimiters.Delimiter4)[1])
.setQuery("sessionId="+session.split(Delimiters.Delimiter4)[1])
.setTransports(new String[]{WebSocket.NAME})
.setReconnectionDelayMax(10000)
.setReconnectionAttempts(3)
Expand All @@ -33,9 +32,8 @@ public TSSSocket(String session, int party, String socketURL) {
} else {
options = IO.Options.builder()
.setPath("/tss/socket.io")
.setQuery(session.split(Delimiters.Delimiter4)[1])
.setQuery("sessionId="+session.split(Delimiters.Delimiter4)[1])
.setTransports(new String[]{WebSocket.NAME})
.setSecure(true)
.setReconnectionDelayMax(10000)
.setReconnectionAttempts(3)
.setForceNew(true)
Expand All @@ -62,7 +60,7 @@ public Socket getSocket() {
}

private void setupSocketEventHandlers() {
socket.on(Socket.EVENT_CONNECT_ERROR, (Emitter.Listener) args -> System.out.println("socket error, party: " + party));
socket.on(Socket.EVENT_CONNECT_ERROR, args -> System.out.println("socket error, party: " + party));

socket.on(Socket.EVENT_CONNECT, args -> System.out.println("connected, party: " + party));

Expand Down

0 comments on commit cb68693

Please sign in to comment.