Skip to content

Commit

Permalink
Invert ID when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Jun 7, 2019
1 parent 3dcae26 commit 687362f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/dmsg/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestClient(t *testing.T) {
logger := logging.MustGetLogger("dms_client")

p1, p2 := net.Pipe()
p1, p2 = invertedIDConn{p1}, invertedIDConn{p2}

var pk1, pk2 cipher.PubKey
err := pk1.Set("024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7")
Expand Down Expand Up @@ -53,3 +54,15 @@ func TestClient(t *testing.T) {
err = tr.Close()
assert.NoError(t, err)
}

type invertedIDConn struct {
net.Conn
}

func (c invertedIDConn) Write(b []byte) (n int, err error) {
frame := Frame(b)

newID := randID(!isInitiatorID(frame.TpID()))
newFrame := MakeFrame(frame.Type(), newID, frame.Pay())
return c.Conn.Write(newFrame)
}

0 comments on commit 687362f

Please sign in to comment.