Skip to content
Snippets Groups Projects
Commit 4e8a2802 authored by Josh Brooks's avatar Josh Brooks
Browse files

Modify tests for completeness and configurability

parent 2822eedf
No related branches found
No related tags found
No related merge requests found
...@@ -260,7 +260,7 @@ func (c *Client) StartNetworkFollower() error { ...@@ -260,7 +260,7 @@ func (c *Client) StartNetworkFollower() error {
} }
c.runner.Add(stopFollow) c.runner.Add(stopFollow)
// Key exchange // Key exchange
c.runner.Add(keyExchange.Start(c.switchboard, c.storage, c.network)) c.runner.Add(keyExchange.Start(c.switchboard, c.storage, c.network, params.GetDefaultRekey()))
err = c.status.toRunning() err = c.status.toRunning()
if err != nil { if err != nil {
......
...@@ -246,6 +246,8 @@ github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN ...@@ -246,6 +246,8 @@ github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN
github.com/zeebo/blake3 v0.0.4 h1:vtZ4X8B2lKXZFg2Xyg6Wo36mvmnJvc2VQYTtA4RDCkI= github.com/zeebo/blake3 v0.0.4 h1:vtZ4X8B2lKXZFg2Xyg6Wo36mvmnJvc2VQYTtA4RDCkI=
github.com/zeebo/blake3 v0.0.4/go.mod h1:YOZo8A49yNqM0X/Y+JmDUZshJWLt1laHsNSn5ny2i34= github.com/zeebo/blake3 v0.0.4/go.mod h1:YOZo8A49yNqM0X/Y+JmDUZshJWLt1laHsNSn5ny2i34=
github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm//LBaEvBiaXY7hXJ6KGe2V32X2F6E= github.com/zeebo/pcg v0.0.0-20181207190024-3cdc6b625a05/go.mod h1:Gr+78ptB0MwXxm//LBaEvBiaXY7hXJ6KGe2V32X2F6E=
gitlab.com/elixxir/client v1.5.0/go.mod h1:/uVTzYDhKaGgN8LGGh1sSsxbh+BrpVi1X8VToAT3DfA=
gitlab.com/elixxir/comms v0.0.0-20200707210150-b8ebd0951d23/go.mod h1:OsWMZ1O/R9fOkm+PoHnR3rkXfFtipGoPs73FuKuurHY=
gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656 h1:A5S3E7EPL95s3+PGhgAiwnMaa7VcWj8/RtBur3lxdOw= gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656 h1:A5S3E7EPL95s3+PGhgAiwnMaa7VcWj8/RtBur3lxdOw=
gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656/go.mod h1:EeS1z5wXKrnWOvR0dJlVNVv8OzuiGJz7fa6LyUeN6Q0= gitlab.com/elixxir/comms v0.0.0-20200810165153-3039323b5656/go.mod h1:EeS1z5wXKrnWOvR0dJlVNVv8OzuiGJz7fa6LyUeN6Q0=
gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741 h1:yIjgre8xSDpnhJkDzTr1lgR7NC1bPWCk2Sgn8udiS2A= gitlab.com/elixxir/comms v0.0.0-20200813225502-e879259ca741 h1:yIjgre8xSDpnhJkDzTr1lgR7NC1bPWCk2Sgn8udiS2A=
...@@ -272,6 +274,7 @@ gitlab.com/elixxir/comms v0.0.0-20200916212207-60e7bd5b0913 h1:p4TLPPaMysV//lOJU ...@@ -272,6 +274,7 @@ gitlab.com/elixxir/comms v0.0.0-20200916212207-60e7bd5b0913 h1:p4TLPPaMysV//lOJU
gitlab.com/elixxir/comms v0.0.0-20200916212207-60e7bd5b0913/go.mod h1:yBEsOZSPyJQJvDbtlQ5L8ydy1JRgVlRoNgMDy9koQcE= gitlab.com/elixxir/comms v0.0.0-20200916212207-60e7bd5b0913/go.mod h1:yBEsOZSPyJQJvDbtlQ5L8ydy1JRgVlRoNgMDy9koQcE=
gitlab.com/elixxir/comms v0.0.0-20200917172539-929fc227eb0c h1:go7/RknV7646Ie+nmQXZAa/aJ5wZBn5bpAYRB+tPens= gitlab.com/elixxir/comms v0.0.0-20200917172539-929fc227eb0c h1:go7/RknV7646Ie+nmQXZAa/aJ5wZBn5bpAYRB+tPens=
gitlab.com/elixxir/comms v0.0.0-20200917172539-929fc227eb0c/go.mod h1:yBEsOZSPyJQJvDbtlQ5L8ydy1JRgVlRoNgMDy9koQcE= gitlab.com/elixxir/comms v0.0.0-20200917172539-929fc227eb0c/go.mod h1:yBEsOZSPyJQJvDbtlQ5L8ydy1JRgVlRoNgMDy9koQcE=
gitlab.com/elixxir/comms v0.0.0-20200917221445-8a509560122a/go.mod h1:L2Va13j2AbQkpkveOQmNzrQD37uI5NKeBhYH+LWMOx0=
gitlab.com/elixxir/comms v0.0.0-20200921200427-5955a0a798b9 h1:skzHNWCMh+T7Cn58/88Mikg2R8KnSWfzLV0w7SnerOs= gitlab.com/elixxir/comms v0.0.0-20200921200427-5955a0a798b9 h1:skzHNWCMh+T7Cn58/88Mikg2R8KnSWfzLV0w7SnerOs=
gitlab.com/elixxir/comms v0.0.0-20200921200427-5955a0a798b9/go.mod h1:uRr8j6yTjCslxZxbRe6k4ixACu9gAeF61JZH36OFFa0= gitlab.com/elixxir/comms v0.0.0-20200921200427-5955a0a798b9/go.mod h1:uRr8j6yTjCslxZxbRe6k4ixACu9gAeF61JZH36OFFa0=
gitlab.com/elixxir/comms v0.0.0-20200922163657-3e723b7170f6 h1:dFgfdATZuiPybonCBh0s4HeLB8Qw3Zm9EoLDRh2Eaaw= gitlab.com/elixxir/comms v0.0.0-20200922163657-3e723b7170f6 h1:dFgfdATZuiPybonCBh0s4HeLB8Qw3Zm9EoLDRh2Eaaw=
...@@ -280,6 +283,10 @@ gitlab.com/elixxir/comms v0.0.0-20200924072138-2e2709483d89 h1:PQalM7pnCRzZRKvdz ...@@ -280,6 +283,10 @@ gitlab.com/elixxir/comms v0.0.0-20200924072138-2e2709483d89 h1:PQalM7pnCRzZRKvdz
gitlab.com/elixxir/comms v0.0.0-20200924072138-2e2709483d89/go.mod h1:uRr8j6yTjCslxZxbRe6k4ixACu9gAeF61JZH36OFFa0= gitlab.com/elixxir/comms v0.0.0-20200924072138-2e2709483d89/go.mod h1:uRr8j6yTjCslxZxbRe6k4ixACu9gAeF61JZH36OFFa0=
gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6 h1:ctVsHyiabgRls3esApbBemDwmQ/a0CramEmZt9RCQb8= gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6 h1:ctVsHyiabgRls3esApbBemDwmQ/a0CramEmZt9RCQb8=
gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6/go.mod h1:9+Jj7K8HOTgBjPuiP69VtTKTv7GvAK6bWlh4lgMAqrk= gitlab.com/elixxir/comms v0.0.0-20200924210331-d7903c023fa6/go.mod h1:9+Jj7K8HOTgBjPuiP69VtTKTv7GvAK6bWlh4lgMAqrk=
gitlab.com/elixxir/comms v0.0.0-20200924225440-76e02f95fb92 h1:KwqVzHpqYg1l1/KG6uRqnl7HBgvrzuknMVCeEvRsbow=
gitlab.com/elixxir/comms v0.0.0-20200924225440-76e02f95fb92/go.mod h1:3i4o6ie4LFC+EVN68l9tdt9JxJlAd3+pNNnKBFubKSg=
gitlab.com/elixxir/crypto v0.0.0-20200707005343-97f868cbd930/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME=
gitlab.com/elixxir/crypto v0.0.0-20200731174640-0503cf80524a/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A=
gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c=
gitlab.com/elixxir/crypto v0.0.0-20200805174804-bdf909f2a16d/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ= gitlab.com/elixxir/crypto v0.0.0-20200805174804-bdf909f2a16d/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ=
...@@ -321,6 +328,8 @@ gitlab.com/elixxir/ekv v0.1.1 h1:Em3rF8sv+tNbQGXbcpYzAS2blWRAP708JGhYlkN74Kg= ...@@ -321,6 +328,8 @@ gitlab.com/elixxir/ekv v0.1.1 h1:Em3rF8sv+tNbQGXbcpYzAS2blWRAP708JGhYlkN74Kg=
gitlab.com/elixxir/ekv v0.1.1/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s= gitlab.com/elixxir/ekv v0.1.1/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s=
gitlab.com/elixxir/ekv v0.1.3 h1:OE+LBMIhjGUMwc6hHJzYvEPNJQV7t1vMnJyIgxUMUo8= gitlab.com/elixxir/ekv v0.1.3 h1:OE+LBMIhjGUMwc6hHJzYvEPNJQV7t1vMnJyIgxUMUo8=
gitlab.com/elixxir/ekv v0.1.3/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4= gitlab.com/elixxir/ekv v0.1.3/go.mod h1:e6WPUt97taFZe5PFLPb1Dupk7tqmDCTQu1kkstqJvw4=
gitlab.com/elixxir/primitives v0.0.0-20200706165052-9fe7a4fb99a3/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
gitlab.com/elixxir/primitives v0.0.0-20200708185800-a06e961280e6/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg= gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
gitlab.com/elixxir/primitives v0.0.0-20200804170709-a1896d262cd9/go.mod h1:p0VelQda72OzoUckr1O+vPW0AiFe0nyKQ6gYcmFSuF8= gitlab.com/elixxir/primitives v0.0.0-20200804170709-a1896d262cd9/go.mod h1:p0VelQda72OzoUckr1O+vPW0AiFe0nyKQ6gYcmFSuF8=
gitlab.com/elixxir/primitives v0.0.0-20200804182913-788f47bded40/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc= gitlab.com/elixxir/primitives v0.0.0-20200804182913-788f47bded40/go.mod h1:tzdFFvb1ESmuTCOl1z6+yf6oAICDxH2NPUemVgoNLxc=
...@@ -346,8 +355,11 @@ gitlab.com/xx_network/comms v0.0.0-20200910173932-bd179f5fee4f h1:ExTCqEoro7VuS1 ...@@ -346,8 +355,11 @@ gitlab.com/xx_network/comms v0.0.0-20200910173932-bd179f5fee4f h1:ExTCqEoro7VuS1
gitlab.com/xx_network/comms v0.0.0-20200910173932-bd179f5fee4f/go.mod h1:+jEkDQKoK51WLl2ZZuxfAZkz6YFbUQ+oZfH0dt2wIF0= gitlab.com/xx_network/comms v0.0.0-20200910173932-bd179f5fee4f/go.mod h1:+jEkDQKoK51WLl2ZZuxfAZkz6YFbUQ+oZfH0dt2wIF0=
gitlab.com/xx_network/comms v0.0.0-20200915154643-d533291041b7 h1:lPx1wpkjNpwLaZ0pyd7/iCcdITjT+eCMmb0HXCVoIkk= gitlab.com/xx_network/comms v0.0.0-20200915154643-d533291041b7 h1:lPx1wpkjNpwLaZ0pyd7/iCcdITjT+eCMmb0HXCVoIkk=
gitlab.com/xx_network/comms v0.0.0-20200915154643-d533291041b7/go.mod h1:+jEkDQKoK51WLl2ZZuxfAZkz6YFbUQ+oZfH0dt2wIF0= gitlab.com/xx_network/comms v0.0.0-20200915154643-d533291041b7/go.mod h1:+jEkDQKoK51WLl2ZZuxfAZkz6YFbUQ+oZfH0dt2wIF0=
gitlab.com/xx_network/comms v0.0.0-20200916172635-6ab807c3c820/go.mod h1:J+GJ6fn71a4xnYVvbcrhtvWSOQIqqhaGcaej5xB3/JY=
gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee h1:dPRaW0OxcoBlWALd5H6VUYnL/ALvT7j14kWJNBi0K7A= gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee h1:dPRaW0OxcoBlWALd5H6VUYnL/ALvT7j14kWJNBi0K7A=
gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee/go.mod h1:jECvMkoYKZFooCudoZxxaf2bo1DzpWP0gCahXHdlqUM= gitlab.com/xx_network/comms v0.0.0-20200924172734-1124191b69ee/go.mod h1:jECvMkoYKZFooCudoZxxaf2bo1DzpWP0gCahXHdlqUM=
gitlab.com/xx_network/comms v0.0.0-20200924225518-0c867207b1e6 h1:8rNFHiwKJvcfN89FAmp4RyfjD/rknp4tNm9sI/Nos0g=
gitlab.com/xx_network/comms v0.0.0-20200924225518-0c867207b1e6/go.mod h1:jECvMkoYKZFooCudoZxxaf2bo1DzpWP0gCahXHdlqUM=
gitlab.com/xx_network/crypto v0.0.0-20200805231039-4aa0e350ed0a h1:BlfWGPokU6yU69O+PGGsgc5iA/P9gERbHzYUvjoYbgM= gitlab.com/xx_network/crypto v0.0.0-20200805231039-4aa0e350ed0a h1:BlfWGPokU6yU69O+PGGsgc5iA/P9gERbHzYUvjoYbgM=
gitlab.com/xx_network/crypto v0.0.0-20200806202113-978fa1984bbf/go.mod h1:i0df/q6dDCBiscgD51fMoS2U2TBrm6LcyN822JmB5Tw= gitlab.com/xx_network/crypto v0.0.0-20200806202113-978fa1984bbf/go.mod h1:i0df/q6dDCBiscgD51fMoS2U2TBrm6LcyN822JmB5Tw=
gitlab.com/xx_network/crypto v0.0.0-20200806235322-ede3c15881ce h1:gypNBUl2guESEv4MDgH+miwYqR4jPoWM8dLt2Zs5gIs= gitlab.com/xx_network/crypto v0.0.0-20200806235322-ede3c15881ce h1:gypNBUl2guESEv4MDgH+miwYqR4jPoWM8dLt2Zs5gIs=
...@@ -419,6 +431,7 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn ...@@ -419,6 +431,7 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
...@@ -498,6 +511,7 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 ...@@ -498,6 +511,7 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200514193133-8feb7f20f2a2/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3 h1:JwLN1jVnmIsfE4HkDVe2AblFAbo0Z+4cjteDSOnv6oE= google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3 h1:JwLN1jVnmIsfE4HkDVe2AblFAbo0Z+4cjteDSOnv6oE=
google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200709005830-7a2ca40e9dc3/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
......
package params
import "time"
type Rekey struct {
RoundTimeout time.Duration
}
func GetDefaultRekey() Rekey {
return Rekey{
RoundTimeout: time.Minute,
}
}
...@@ -29,15 +29,24 @@ func TestHandleConfirm(t *testing.T) { ...@@ -29,15 +29,24 @@ func TestHandleConfirm(t *testing.T) {
// Generate a session ID, bypassing some business logic here // Generate a session ID, bypassing some business logic here
sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup)
// Get Alice's manager for Bob
receivedManager, err := aliceSession.E2e().GetPartner(bobID)
if err != nil {
t.Errorf("Bob is not recognized as Alice's partner: %v", err)
}
// Trigger negotiations, so that negotiation statuses
// can be transitioned
receivedManager.TriggerNegotiations()
// Generate the message // Generate the message
rekey, _ := proto.Marshal(&RekeyConfirm{ rekey, _ := proto.Marshal(&RekeyConfirm{
SessionID: sessionID.Marshal(), SessionID: sessionID.Marshal(),
}) })
payload := make([]byte, 0)
payload = append(payload, rekey...)
receiveMsg := message.Receive{ receiveMsg := message.Receive{
Payload: payload, Payload: rekey,
MessageType: message.NoType, MessageType: message.NoType,
Sender: bobID, Sender: bobID,
Timestamp: time.Now(), Timestamp: time.Now(),
...@@ -46,4 +55,17 @@ func TestHandleConfirm(t *testing.T) { ...@@ -46,4 +55,17 @@ func TestHandleConfirm(t *testing.T) {
// Handle the confirmation // Handle the confirmation
handleConfirm(aliceSession, receiveMsg) handleConfirm(aliceSession, receiveMsg)
// Get Alice's session for Bob
confirmedSession := receivedManager.GetSendSession(sessionID)
// Check that the session is in the proper status
newSession := receivedManager.GetSendSession(sessionID)
if newSession.NegotiationStatus() != e2e.Confirmed {
t.Errorf("Session not in confirmed status!" +
"\n\tExpected: Confirmed" +
"\n\tReceived: %s", confirmedSession.NegotiationStatus())
}
} }
...@@ -3,6 +3,7 @@ package keyExchange ...@@ -3,6 +3,7 @@ package keyExchange
import ( import (
"gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/switchboard" "gitlab.com/elixxir/client/switchboard"
...@@ -14,8 +15,8 @@ const keyExchangeTriggerName = "KeyExchangeTrigger" ...@@ -14,8 +15,8 @@ const keyExchangeTriggerName = "KeyExchangeTrigger"
const keyExchangeConfirmName = "KeyExchangeConfirm" const keyExchangeConfirmName = "KeyExchangeConfirm"
const keyExchangeMulti = "KeyExchange" const keyExchangeMulti = "KeyExchange"
func Start(switchboard *switchboard.Switchboard, sess *storage.Session, func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net interfaces.NetworkManager,
net interfaces.NetworkManager) stoppable.Stoppable { params params.Rekey) stoppable.Stoppable {
// register the rekey trigger thread // register the rekey trigger thread
triggerCh := make(chan message.Receive, 100) triggerCh := make(chan message.Receive, 100)
...@@ -31,7 +32,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, ...@@ -31,7 +32,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session,
}) })
// start the trigger thread // start the trigger thread
go startTrigger(sess, net, triggerCh, triggerStop.Quit()) go startTrigger(sess, net, triggerCh, triggerStop.Quit(), params)
//register the rekey confirm thread //register the rekey confirm thread
confirmCh := make(chan message.Receive, 100) confirmCh := make(chan message.Receive, 100)
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/elixxir/client/switchboard" "gitlab.com/elixxir/client/switchboard"
...@@ -38,8 +39,10 @@ func TestFullExchange(t *testing.T) { ...@@ -38,8 +39,10 @@ func TestFullExchange(t *testing.T) {
e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams())
// Start the listeners for alice and bob // Start the listeners for alice and bob
Start(aliceSwitchboard, aliceSession, aliceManager) rekeyParams := params.GetDefaultRekey()
Start(bobSwitchboard, bobSession, bobManager) rekeyParams.RoundTimeout = 5 * time.Second
Start(aliceSwitchboard, aliceSession, aliceManager, rekeyParams)
Start(bobSwitchboard, bobSession, bobManager, rekeyParams)
// Generate a session ID, bypassing some business logic here // Generate a session ID, bypassing some business logic here
sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup)
......
...@@ -24,10 +24,10 @@ import ( ...@@ -24,10 +24,10 @@ import (
) )
func CheckKeyExchanges(instance *network.Instance, sendE2E interfaces.SendE2E, func CheckKeyExchanges(instance *network.Instance, sendE2E interfaces.SendE2E,
sess *storage.Session, manager *e2e.Manager) { sess *storage.Session, manager *e2e.Manager, sendTimeout time.Duration) {
sessions := manager.TriggerNegotiations() sessions := manager.TriggerNegotiations()
for _, session := range sessions { for _, session := range sessions {
go trigger(instance, sendE2E, sess, manager, session) go trigger(instance, sendE2E, sess, manager, session, sendTimeout)
} }
} }
...@@ -36,7 +36,8 @@ func CheckKeyExchanges(instance *network.Instance, sendE2E interfaces.SendE2E, ...@@ -36,7 +36,8 @@ func CheckKeyExchanges(instance *network.Instance, sendE2E interfaces.SendE2E,
// session. They run the same negotiation, the former does it on a newly created // session. They run the same negotiation, the former does it on a newly created
// session while the latter on an extand // session while the latter on an extand
func trigger(instance *network.Instance, sendE2E interfaces.SendE2E, func trigger(instance *network.Instance, sendE2E interfaces.SendE2E,
sess *storage.Session, manager *e2e.Manager, session *e2e.Session) { sess *storage.Session, manager *e2e.Manager, session *e2e.Session,
sendTimeout time.Duration) {
var negotiatingSession *e2e.Session var negotiatingSession *e2e.Session
switch session.NegotiationStatus() { switch session.NegotiationStatus() {
// If the passed session is triggering a negotiation on a new session to // If the passed session is triggering a negotiation on a new session to
...@@ -56,7 +57,7 @@ func trigger(instance *network.Instance, sendE2E interfaces.SendE2E, ...@@ -56,7 +57,7 @@ func trigger(instance *network.Instance, sendE2E interfaces.SendE2E,
} }
// send the rekey notification to the partner // send the rekey notification to the partner
err := negotiate(instance, sendE2E, sess, negotiatingSession) err := negotiate(instance, sendE2E, sess, negotiatingSession, sendTimeout)
// if sending the negotiation fails, revert the state of the session to // if sending the negotiation fails, revert the state of the session to
// unconfirmed so it will be triggered in the future // unconfirmed so it will be triggered in the future
if err != nil { if err != nil {
...@@ -66,7 +67,8 @@ func trigger(instance *network.Instance, sendE2E interfaces.SendE2E, ...@@ -66,7 +67,8 @@ func trigger(instance *network.Instance, sendE2E interfaces.SendE2E,
} }
func negotiate(instance *network.Instance, sendE2E interfaces.SendE2E, func negotiate(instance *network.Instance, sendE2E interfaces.SendE2E,
sess *storage.Session, session *e2e.Session) error { sess *storage.Session, session *e2e.Session,
sendTimeout time.Duration) error {
e2eStore := sess.E2e() e2eStore := sess.E2e()
//generate public key //generate public key
...@@ -111,7 +113,7 @@ func negotiate(instance *network.Instance, sendE2E interfaces.SendE2E, ...@@ -111,7 +113,7 @@ func negotiate(instance *network.Instance, sendE2E interfaces.SendE2E,
//Register the event for all rounds //Register the event for all rounds
roundEvents := instance.GetRoundEvents() roundEvents := instance.GetRoundEvents()
for _, r := range rounds { for _, r := range rounds {
roundEvents.AddRoundEventChan(r, sendResults, 1*time.Minute, roundEvents.AddRoundEventChan(r, sendResults, sendTimeout,
states.COMPLETED, states.FAILED) states.COMPLETED, states.FAILED)
} }
......
...@@ -14,7 +14,6 @@ import ( ...@@ -14,7 +14,6 @@ import (
ds "gitlab.com/elixxir/comms/network/dataStructures" ds "gitlab.com/elixxir/comms/network/dataStructures"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/primitives/states"
"time"
) )
const ( const (
...@@ -23,13 +22,13 @@ const ( ...@@ -23,13 +22,13 @@ const (
) )
func startTrigger(sess *storage.Session, net interfaces.NetworkManager, func startTrigger(sess *storage.Session, net interfaces.NetworkManager,
c chan message.Receive, quitCh <-chan struct{}) { c chan message.Receive, quitCh <-chan struct{}, params params.Rekey) {
for true { for true {
select { select {
case <-quitCh: case <-quitCh:
return return
case request := <-c: case request := <-c:
err := handleTrigger(sess, net, request) err := handleTrigger(sess, net, request, params)
if err != nil { if err != nil {
jww.ERROR.Printf("Failed to handle rekey trigger: %s", jww.ERROR.Printf("Failed to handle rekey trigger: %s",
err) err)
...@@ -39,7 +38,7 @@ func startTrigger(sess *storage.Session, net interfaces.NetworkManager, ...@@ -39,7 +38,7 @@ func startTrigger(sess *storage.Session, net interfaces.NetworkManager,
} }
func handleTrigger(sess *storage.Session, net interfaces.NetworkManager, func handleTrigger(sess *storage.Session, net interfaces.NetworkManager,
request message.Receive) error { request message.Receive, param params.Rekey) error {
//ensure the message was encrypted properly //ensure the message was encrypted properly
if request.Encryption != message.E2E { if request.Encryption != message.E2E {
errMsg := fmt.Sprintf(errBadTrigger, request.Sender) errMsg := fmt.Sprintf(errBadTrigger, request.Sender)
...@@ -122,14 +121,17 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager, ...@@ -122,14 +121,17 @@ func handleTrigger(sess *storage.Session, net interfaces.NetworkManager,
sendResults := make(chan ds.EventReturn, len(rounds)) sendResults := make(chan ds.EventReturn, len(rounds))
roundEvents := net.GetInstance().GetRoundEvents() roundEvents := net.GetInstance().GetRoundEvents()
for _, r := range rounds { for _, r := range rounds {
roundEvents.AddRoundEventChan(r, sendResults, 1*time.Minute, roundEvents.AddRoundEventChan(r, sendResults, param.RoundTimeout,
states.COMPLETED, states.FAILED) states.COMPLETED, states.FAILED)
} }
fmt.Println("before tracking")
//Wait until the result tracking responds //Wait until the result tracking responds
success, numTimeOut, numRoundFail := utility.TrackResults(sendResults, len(rounds)) success, numTimeOut, numRoundFail := utility.TrackResults(sendResults, len(rounds))
// If a single partition of the Key Negotiation request does not // If a single partition of the Key Negotiation request does not
// transmit, the partner will not be able to read the confirmation. If // transmit, the partner will not be able to read the confirmation. If
// such a failure occurs // such a failure occurs
fmt.Println("after tracking")
if !success { if !success {
jww.ERROR.Printf("Key Negotiation for %s failed to "+ jww.ERROR.Printf("Key Negotiation for %s failed to "+
"transmit %v/%v paritions: %v round failures, %v timeouts", "transmit %v/%v paritions: %v round failures, %v timeouts",
......
...@@ -2,7 +2,10 @@ package keyExchange ...@@ -2,7 +2,10 @@ package keyExchange
import ( import (
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/elixxir/crypto/csprng"
dh "gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"testing" "testing"
...@@ -19,6 +22,10 @@ func TestHandleTrigger(t *testing.T) { ...@@ -19,6 +22,10 @@ func TestHandleTrigger(t *testing.T) {
alicePrivKey := aliceSession.E2e().GetDHPrivateKey() alicePrivKey := aliceSession.E2e().GetDHPrivateKey()
bobPubKey := bobSession.E2e().GetDHPublicKey() bobPubKey := bobSession.E2e().GetDHPublicKey()
// Generate bob's new keypair
newBobPrivKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, genericGroup, csprng.NewSystemRNG())
newBobPubKey := dh.GeneratePublicKey(newBobPrivKey, genericGroup)
// Maintain an ID for bob // Maintain an ID for bob
bobID := id.NewIdFromBytes([]byte("test"), t) bobID := id.NewIdFromBytes([]byte("test"), t)
...@@ -27,19 +34,16 @@ func TestHandleTrigger(t *testing.T) { ...@@ -27,19 +34,16 @@ func TestHandleTrigger(t *testing.T) {
e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams()) e2e.GetDefaultSessionParams(), e2e.GetDefaultSessionParams())
// Generate a session ID, bypassing some business logic here // Generate a session ID, bypassing some business logic here
sessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup) oldSessionID := GeneratePartnerID(alicePrivKey, bobPubKey, genericGroup)
// Generate the message // Generate the message
rekey, _ := proto.Marshal(&RekeyTrigger{ rekey, _ := proto.Marshal(&RekeyTrigger{
SessionID: sessionID.Marshal(), SessionID: oldSessionID.Marshal(),
PublicKey: bobPubKey.Bytes(), PublicKey: newBobPubKey.Bytes(),
}) })
payload := make([]byte, 0)
payload = append(payload, rekey...)
receiveMsg := message.Receive{ receiveMsg := message.Receive{
Payload: payload, Payload: rekey,
MessageType: message.NoType, MessageType: message.NoType,
Sender: bobID, Sender: bobID,
Timestamp: time.Now(), Timestamp: time.Now(),
...@@ -47,8 +51,43 @@ func TestHandleTrigger(t *testing.T) { ...@@ -47,8 +51,43 @@ func TestHandleTrigger(t *testing.T) {
} }
// Handle the trigger and check for an error // Handle the trigger and check for an error
err := handleTrigger(aliceSession, aliceManager, receiveMsg) rekeyParams := params.GetDefaultRekey()
rekeyParams.RoundTimeout = 0 * time.Second
err := handleTrigger(aliceSession, aliceManager, receiveMsg, rekeyParams)
if err != nil { if err != nil {
t.Errorf("Handle trigger error: %v", err) t.Errorf("Handle trigger error: %v", err)
} }
// Get Alice's manager for reception from Bob
receivedManager, err := aliceSession.E2e().GetPartner(bobID)
if err != nil {
t.Errorf("Failed to get bob's manager: %v", err)
}
// Generate the new session ID based off of Bob's new keys
baseKey := dh.GenerateSessionKey(alicePrivKey, newBobPubKey, genericGroup)
newSessionID := e2e.GetSessionIDFromBaseKeyForTesting(baseKey, t)
// Check that this new session ID is now in the manager
newSession := receivedManager.GetReceiveSession(newSessionID)
if newSession == nil {
t.Errorf("Did not get expected session")
}
// Generate a keypair alice will not recognize
unknownPrivateKey := dh.GeneratePrivateKey(dh.DefaultPrivateKeyLength, genericGroup, csprng.NewSystemRNG())
unknownPubliceKey := dh.GeneratePublicKey(unknownPrivateKey, genericGroup)
// Generate a new session ID based off of these unrecognized keys
badSessionID := e2e.GetSessionIDFromBaseKeyForTesting(unknownPubliceKey, t)
// Check that this session with unrecognized keys is not valid
badSession := receivedManager.GetReceiveSession(badSessionID)
if badSession != nil {
t.Errorf("Alice found a session from an unknown keypair. " +
"\nSession: %v", badSession)
}
} }
...@@ -45,15 +45,15 @@ type testNetworkManagerGeneric struct { ...@@ -45,15 +45,15 @@ type testNetworkManagerGeneric struct {
} }
func (t *testNetworkManagerGeneric) GetHealthTracker() interfaces.HealthTracker { func (t *testNetworkManagerGeneric) GetHealthTracker() interfaces.HealthTracker {
panic("implement me") return nil
} }
func (t *testNetworkManagerGeneric) Follow() (stoppable.Stoppable, error) { func (t *testNetworkManagerGeneric) Follow() (stoppable.Stoppable, error) {
panic("implement me") return nil, nil
} }
func (t *testNetworkManagerGeneric) CheckGarbledMessages() { func (t *testNetworkManagerGeneric) CheckGarbledMessages() {
panic("implement me") return
} }
func (t *testNetworkManagerGeneric) SendE2E(m message.Send, p params.E2E) ([]id.Round, error) { func (t *testNetworkManagerGeneric) SendE2E(m message.Send, p params.E2E) ([]id.Round, error) {
...@@ -131,15 +131,15 @@ type testNetworkManagerFullExchange struct { ...@@ -131,15 +131,15 @@ type testNetworkManagerFullExchange struct {
} }
func (t *testNetworkManagerFullExchange) GetHealthTracker() interfaces.HealthTracker { func (t *testNetworkManagerFullExchange) GetHealthTracker() interfaces.HealthTracker {
panic("implement me") return nil
} }
func (t *testNetworkManagerFullExchange) Follow() (stoppable.Stoppable, error) { func (t *testNetworkManagerFullExchange) Follow() (stoppable.Stoppable, error) {
panic("implement me") return nil, nil
} }
func (t *testNetworkManagerFullExchange) CheckGarbledMessages() { func (t *testNetworkManagerFullExchange) CheckGarbledMessages() {
panic("implement me") return
} }
// Intended for alice to send to bob. Trigger's Bob's confirmation, chaining the operation // Intended for alice to send to bob. Trigger's Bob's confirmation, chaining the operation
......
...@@ -72,7 +72,7 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, error ...@@ -72,7 +72,7 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, error
// while waiting check if any rekeys need to happen and trigger them. This // while waiting check if any rekeys need to happen and trigger them. This
// can happen now because the key popping happens in this thread, // can happen now because the key popping happens in this thread,
// only the sending is parallelized // only the sending is parallelized
keyExchange.CheckKeyExchanges(m.Instance, m.SendE2E, m.Session, partner) keyExchange.CheckKeyExchanges(m.Instance, m.SendE2E, m.Session, partner, 1*time.Minute)
wg.Wait() wg.Wait()
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
dh "gitlab.com/elixxir/crypto/diffieHellman" dh "gitlab.com/elixxir/crypto/diffieHellman"
...@@ -18,6 +19,7 @@ import ( ...@@ -18,6 +19,7 @@ import (
"gitlab.com/elixxir/crypto/hash" "gitlab.com/elixxir/crypto/hash"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"sync" "sync"
"testing"
"time" "time"
) )
...@@ -216,6 +218,23 @@ func getSessionIDFromBaseKey(baseKey *cyclic.Int) SessionID { ...@@ -216,6 +218,23 @@ func getSessionIDFromBaseKey(baseKey *cyclic.Int) SessionID {
return sid return sid
} }
//underlying definition of session id
// FOR TESTING PURPOSES ONLY
func GetSessionIDFromBaseKeyForTesting(baseKey *cyclic.Int, i interface{}) SessionID {
switch i.(type) {
case *testing.T:
break
case *testing.M:
break
case *testing.B:
break
default:
globals.Log.FATAL.Panicf("GetSessionIDFromBaseKeyForTesting is restricted to testing only. Got %T", i)
}
return getSessionIDFromBaseKey(baseKey)
}
//Blake2B hash of base key used for storage //Blake2B hash of base key used for storage
func (s *Session) GetID() SessionID { func (s *Session) GetID() SessionID {
return getSessionIDFromBaseKey(s.baseKey) return getSessionIDFromBaseKey(s.baseKey)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment