Skip to content

Commit 6795485

Browse files
committed
multi: send authData in itests
In this commit, we adjust the itests to send authData from the server to the client and fail the test if the client does not receive the correct authData from the server.
1 parent 56ea7e2 commit 6795485

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

itest/client_harness.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package itest
22

33
import (
4+
"bytes"
45
"context"
56
"crypto/tls"
7+
"fmt"
68
"net/http"
79

810
"github.com/btcsuite/btcd/btcec/v2"
@@ -45,11 +47,18 @@ func (c *clientHarness) start() error {
4547
c.cancel = cancel
4648

4749
connData := mailbox.NewConnData(
48-
c.localStatic, c.remoteStatic, c.passphraseEntropy, nil,
49-
func(key *btcec.PublicKey) error {
50+
c.localStatic, c.remoteStatic, c.passphraseEntropy,
51+
nil, func(key *btcec.PublicKey) error {
5052
c.remoteStatic = key
5153
return nil
52-
}, nil,
54+
}, func(data []byte) error {
55+
if !bytes.Equal(data, authData) {
56+
return fmt.Errorf("incorrect auth data. "+
57+
"Expected %x, got %x", authData, data)
58+
}
59+
60+
return nil
61+
},
5362
)
5463

5564
transportConn, err := mailbox.NewClient(ctx, connData)

itest/server_harness.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"google.golang.org/grpc/credentials"
1313
)
1414

15+
var authData = []byte{1, 2, 3, 4}
16+
1517
type serverHarness struct {
1618
serverHost string
1719
mockServer *grpc.Server
@@ -64,7 +66,7 @@ func (s *serverHarness) stop() {
6466

6567
func (s *serverHarness) start() error {
6668
connData := mailbox.NewConnData(
67-
s.localStatic, s.remoteStatic, s.passphraseEntropy, nil,
69+
s.localStatic, s.remoteStatic, s.passphraseEntropy, authData,
6870
func(key *btcec.PublicKey) error {
6971
s.remoteStatic = key
7072
return nil

mailbox/conndata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type ConnData struct {
5858
func NewConnData(localKey keychain.SingleKeyECDH, remoteKey *btcec.PublicKey,
5959
passphraseEntropy []byte, authData []byte,
6060
onRemoteStatic func(key *btcec.PublicKey) error,
61-
onAuthData func(date []byte) error) *ConnData {
61+
onAuthData func(data []byte) error) *ConnData {
6262

6363
return &ConnData{
6464
localKey: localKey,

0 commit comments

Comments
 (0)