aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-07-03 16:13:54 +0200
committerAlex Auvolat <alex@adnab.me>2018-07-03 16:13:54 +0200
commit66ab427e7ada3e8d9710eb79b1f768a8431b42eb (patch)
treed5a70563113b3cb3a9c164c1bc2cf66229a80c2d /test
parent8f3009715ee9ccdd7ecb54fea1244a32a29b62c0 (diff)
downloadshard-66ab427e7ada3e8d9710eb79b1f768a8431b42eb.tar.gz
shard-66ab427e7ada3e8d9710eb79b1f768a8431b42eb.zip
Add connection manager (to be fully fledged peer database)
Diffstat (limited to 'test')
-rw-r--r--test/conn_test.exs7
1 files changed, 3 insertions, 4 deletions
diff --git a/test/conn_test.exs b/test/conn_test.exs
index 48c92f8..a8cda43 100644
--- a/test/conn_test.exs
+++ b/test/conn_test.exs
@@ -15,11 +15,10 @@ defmodule ShardTest.Conn do
{:ok, challenge} = Salty.Random.buf 32
{:ok, socket} = :gen_tcp.connect {127,0,0,1}, 4044, [:binary, packet: 2, active: false]
- :gen_tcp.send(socket, srv_pkey <> sess_pkey <> challenge)
+ hello = {srv_pkey, sess_pkey, challenge, 0}
+ :gen_tcp.send(socket, :erlang.term_to_binary hello)
{:ok, pkt} = :gen_tcp.recv(socket, 0)
- cli_pkey = binary_part(pkt, 0, Sign.publickeybytes)
- cli_sess_pkey = binary_part(pkt, Sign.publickeybytes, Box.publickeybytes)
- cli_challenge = binary_part(pkt, Sign.publickeybytes + Box.publickeybytes, 32)
+ {cli_pkey, cli_sess_pkey, cli_challenge, _his_port} = :erlang.binary_to_term(pkt, [:safe])
{:ok, cli_challenge_sign} = Sign.sign_detached(cli_challenge, srv_skey)
sendmsg(socket, cli_challenge_sign, cli_sess_pkey, sess_skey)