Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
5fdc90f9
Commit
5fdc90f9
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Remove recipient from connection file transfer send and instead use partner in connection
parent
66462228
No related branches found
No related tags found
1 merge request
!510
Release
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fileTransfer/connect/utils_test.go
+16
-5
16 additions, 5 deletions
fileTransfer/connect/utils_test.go
fileTransfer/connect/wrapper.go
+8
-4
8 additions, 4 deletions
fileTransfer/connect/wrapper.go
fileTransfer/connect/wrapper_test.go
+6
-6
6 additions, 6 deletions
fileTransfer/connect/wrapper_test.go
with
30 additions
and
15 deletions
fileTransfer/connect/utils_test.go
+
16
−
5
View file @
5fdc90f9
...
...
@@ -15,6 +15,7 @@ import (
"gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/ratchet/partner"
"gitlab.com/elixxir/client/e2e/receive"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/cyclic"
...
...
@@ -28,6 +29,7 @@ import (
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime"
"sync"
"testing"
"time"
)
...
...
@@ -167,21 +169,30 @@ func newMockConnectionHandler() *mockConnectionHandler {
var
_
Connection
=
(
*
mockConnection
)(
nil
)
type
mockConnection
struct
{
myID
*
id
.
ID
handler
*
mockConnectionHandler
myID
*
id
.
ID
recipient
*
id
.
ID
handler
*
mockConnectionHandler
t
*
testing
.
T
}
type
mockListener
struct
{
hearChan
chan
receive
.
Message
}
func
newMockConnection
(
myID
*
id
.
ID
,
handler
*
mockConnectionHandler
)
*
mockConnection
{
func
newMockConnection
(
myID
,
recipient
*
id
.
ID
,
handler
*
mockConnectionHandler
,
t
*
testing
.
T
)
*
mockConnection
{
return
&
mockConnection
{
myID
:
myID
,
handler
:
handler
,
myID
:
myID
,
recipient
:
recipient
,
handler
:
handler
,
t
:
t
,
}
}
func
(
m
*
mockConnection
)
GetPartner
()
partner
.
Manager
{
return
partner
.
NewTestManager
(
m
.
recipient
,
nil
,
nil
,
m
.
t
)
}
// SendE2E adds the message to the e2e handler map.
func
(
m
*
mockConnection
)
SendE2E
(
mt
catalog
.
MessageType
,
payload
[]
byte
,
_
e2e
.
Params
)
([]
id
.
Round
,
e2eCrypto
.
MessageID
,
time
.
Time
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
fileTransfer/connect/wrapper.go
+
8
−
4
View file @
5fdc90f9
...
...
@@ -10,6 +10,7 @@ package connect
import
(
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/ratchet/partner"
"gitlab.com/elixxir/client/e2e/receive"
ft
"gitlab.com/elixxir/client/fileTransfer"
e2eCrypto
"gitlab.com/elixxir/crypto/e2e"
...
...
@@ -38,6 +39,7 @@ type Wrapper struct {
// Connection interface matches a subset of the connect.Connection methods used
// by the Wrapper for easier testing.
type
Connection
interface
{
GetPartner
()
partner
.
Manager
SendE2E
(
mt
catalog
.
MessageType
,
payload
[]
byte
,
params
e2e
.
Params
)
(
[]
id
.
Round
,
e2eCrypto
.
MessageID
,
time
.
Time
,
error
)
RegisterListener
(
messageType
catalog
.
MessageType
,
...
...
@@ -84,10 +86,10 @@ func (w *Wrapper) MaxPreviewSize() int {
return
w
.
ft
.
MaxPreviewSize
()
}
// Send initiates the sending of a file to
a recipient
and returns a
transfer ID
// that uniquely identifies this file transfer. The initial and
final messages
// are sent via Connection E2E.
func
(
w
*
Wrapper
)
Send
(
recipient
*
id
.
ID
,
fileName
,
fileType
string
,
// Send initiates the sending of a file to
the connection partner
and returns a
//
transfer ID
that uniquely identifies this file transfer. The initial and
//
final messages
are sent via Connection E2E.
func
(
w
*
Wrapper
)
Send
(
fileName
,
fileType
string
,
fileData
[]
byte
,
retry
float32
,
preview
[]
byte
,
progressCB
ft
.
SentProgressCallback
,
period
time
.
Duration
)
(
*
ftCrypto
.
TransferID
,
error
)
{
...
...
@@ -98,6 +100,8 @@ func (w *Wrapper) Send(recipient *id.ID, fileName, fileType string,
modifiedProgressCB
:=
w
.
addEndMessageToCallback
(
progressCB
)
recipient
:=
w
.
conn
.
GetPartner
()
.
PartnerId
()
return
w
.
ft
.
Send
(
recipient
,
fileName
,
fileType
,
fileData
,
retry
,
preview
,
modifiedProgressCB
,
period
,
sendNew
)
}
...
...
This diff is collapsed.
Click to expand it.
fileTransfer/connect/wrapper_test.go
+
6
−
6
View file @
5fdc90f9
...
...
@@ -56,10 +56,11 @@ func Test_FileTransfer_Smoke(t *testing.T) {
tid
,
fileName
,
fileType
,
sender
,
size
,
preview
}
}
myID1
:=
id
.
NewIdFromString
(
"myID1"
,
id
.
User
,
t
)
myID2
:=
id
.
NewIdFromString
(
"myID2"
,
id
.
User
,
t
)
storage1
:=
newMockStorage
()
endE2eChan1
:=
make
(
chan
receive
.
Message
,
3
)
conn1
:=
newMockConnection
(
myID1
,
e2eHandler
)
conn1
.
RegisterListener
(
catalog
.
EndFileTransfer
,
newMockListener
(
endE2eChan1
))
conn1
:=
newMockConnection
(
myID1
,
myID2
,
e2eHandler
,
t
)
_
,
_
=
conn1
.
RegisterListener
(
catalog
.
EndFileTransfer
,
newMockListener
(
endE2eChan1
))
cmix1
:=
newMockCmix
(
myID1
,
cMixHandler
,
storage1
)
ftManager1
,
err
:=
ft
.
NewManager
(
ftParams
,
myID1
,
cmix1
,
storage1
,
rngGen
)
if
err
!=
nil
{
...
...
@@ -81,11 +82,10 @@ func Test_FileTransfer_Smoke(t *testing.T) {
receiveCbChan2
<-
receiveCbValues
{
tid
,
fileName
,
fileType
,
sender
,
size
,
preview
}
}
myID2
:=
id
.
NewIdFromString
(
"myID2"
,
id
.
User
,
t
)
storage2
:=
newMockStorage
()
endE2eChan2
:=
make
(
chan
receive
.
Message
,
3
)
conn2
:=
newMockConnection
(
myID2
,
e2eHandler
)
conn2
.
RegisterListener
(
catalog
.
EndFileTransfer
,
newMockListener
(
endE2eChan2
))
conn2
:=
newMockConnection
(
myID2
,
myID1
,
e2eHandler
,
t
)
_
,
_
=
conn2
.
RegisterListener
(
catalog
.
EndFileTransfer
,
newMockListener
(
endE2eChan2
))
cmix2
:=
newMockCmix
(
myID1
,
cMixHandler
,
storage2
)
ftManager2
,
err
:=
ft
.
NewManager
(
ftParams
,
myID2
,
cmix2
,
storage2
,
rngGen
)
if
err
!=
nil
{
...
...
@@ -160,7 +160,7 @@ func Test_FileTransfer_Smoke(t *testing.T) {
// Send file
sendStart
:=
netTime
.
Now
()
tid1
,
err
:=
m1
.
Send
(
myID2
,
fileName
,
fileType
,
fileData
,
retry
,
preview
,
sentProgressCb1
,
0
)
fileName
,
fileType
,
fileData
,
retry
,
preview
,
sentProgressCb1
,
0
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to send file: %+v"
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment