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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
bdfd2211
Commit
bdfd2211
authored
Feb 28, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests associated with backup triggering on initialization
parent
d479cb88
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!231
Revert "Update store to print changes to the partners list"
,
!171
RestoreContactsFromBackup
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backup/backup.go
+8
-2
8 additions, 2 deletions
backup/backup.go
backup/backup_test.go
+16
-4
16 additions, 4 deletions
backup/backup_test.go
with
24 additions
and
6 deletions
backup/backup.go
+
8
−
2
View file @
bdfd2211
...
...
@@ -111,7 +111,7 @@ func initializeBackup(password string, updateBackupCb UpdateBackupFn,
// Setting backup trigger in client
b
.
backupContainer
.
SetBackup
(
b
.
TriggerBackup
)
b
.
backupContainer
.
TriggerBackup
(
"initializeBackup"
)
b
.
TriggerBackup
(
"initializeBackup"
)
jww
.
INFO
.
Print
(
"Initialized backup with new user key."
)
return
b
,
nil
...
...
@@ -199,7 +199,13 @@ func (b *Backup) TriggerBackup(reason string) {
jww
.
INFO
.
Printf
(
"Backup triggered: %s"
,
reason
)
// Send backup on callback
b
.
mux
.
RLock
()
defer
b
.
mux
.
RUnlock
()
if
b
.
updateBackupCb
!=
nil
{
go
b
.
updateBackupCb
(
encryptedBackup
)
}
else
{
jww
.
WARN
.
Printf
(
"could not call backup callback, stopped..."
)
}
}
// StopBackup stops the backup processes and deletes the user's password, key,
...
...
This diff is collapsed.
Click to expand it.
backup/backup_test.go
+
16
−
4
View file @
bdfd2211
...
...
@@ -9,15 +9,16 @@ package backup
import
(
"bytes"
"reflect"
"strings"
"testing"
"time"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/crypto/backup"
"gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/crypto/csprng"
"reflect"
"strings"
"testing"
"time"
)
// Tests that Backup.initializeBackup returns a new Backup with a copy of the
...
...
@@ -196,6 +197,11 @@ func TestBackup_TriggerBackup_NoKey(t *testing.T) {
cbChan
:=
make
(
chan
[]
byte
)
cb
:=
func
(
encryptedBackup
[]
byte
)
{
cbChan
<-
encryptedBackup
}
b
:=
newTestBackup
(
"MySuperSecurePassword"
,
cb
,
t
)
select
{
case
<-
cbChan
:
case
<-
time
.
After
(
10
*
time
.
Millisecond
)
:
t
.
Errorf
(
"backup not called"
)
}
err
:=
deleteBackup
(
b
.
store
.
GetKV
())
if
err
!=
nil
{
...
...
@@ -209,6 +215,7 @@ func TestBackup_TriggerBackup_NoKey(t *testing.T) {
t
.
Errorf
(
"Callback received when it should not have been called: %q"
,
r
)
case
<-
time
.
After
(
10
*
time
.
Millisecond
)
:
}
}
// Tests that Backup.StopBackup prevents the callback from triggering and that
...
...
@@ -217,6 +224,11 @@ func TestBackup_StopBackup(t *testing.T) {
cbChan
:=
make
(
chan
[]
byte
)
cb
:=
func
(
encryptedBackup
[]
byte
)
{
cbChan
<-
encryptedBackup
}
b
:=
newTestBackup
(
"MySuperSecurePassword"
,
cb
,
t
)
select
{
case
<-
cbChan
:
case
<-
time
.
After
(
1000
*
time
.
Millisecond
)
:
t
.
Errorf
(
"backup not called"
)
}
err
:=
b
.
StopBackup
()
if
err
!=
nil
{
...
...
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