Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
3b35bfd6
Commit
3b35bfd6
authored
Jul 31, 2019
by
Ivar Derksen
Committed by
Sietse Ringers
Oct 08, 2019
Browse files
Invert bolthold keys to achieve right sorting order + test
parent
563bd417
Changes
2
Hide whitespace changes
Inline
Side-by-side
internal/sessiontest/logs_test.go
View file @
3b35bfd6
...
...
@@ -26,7 +26,7 @@ func TestLogging(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
len
(
logs
)
==
oldLogLength
+
1
)
entry
:=
logs
[
len
(
logs
)
-
1
]
entry
:=
logs
[
0
]
require
.
NotNil
(
t
,
entry
)
require
.
NoError
(
t
,
err
)
issued
,
err
:=
entry
.
GetIssuedCredentials
(
client
.
Configuration
)
...
...
@@ -36,6 +36,8 @@ func TestLogging(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NotEmpty
(
t
,
disclosed
)
time
.
Sleep
(
2
*
time
.
Second
)
// Do disclosure session
request
=
getDisclosureRequest
(
attrid
)
sessionHelper
(
t
,
request
,
"verification"
,
client
)
...
...
@@ -43,20 +45,25 @@ func TestLogging(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
len
(
logs
)
==
oldLogLength
+
2
)
entry
=
logs
[
len
(
logs
)
-
1
]
entry
=
logs
[
0
]
require
.
NotNil
(
t
,
entry
)
require
.
NoError
(
t
,
err
)
disclosed
,
err
=
entry
.
GetDisclosedCredentials
(
client
.
Configuration
)
require
.
NoError
(
t
,
err
)
require
.
NotEmpty
(
t
,
disclosed
)
// Test before parameter
logs
,
err
=
client
.
LoadLogs
(
time
.
Time
(
entry
.
Time
),
100
)
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
len
(
logs
)
==
oldLogLength
+
1
)
// Do signature session
request
=
getSigningRequest
(
attrid
)
sessionHelper
(
t
,
request
,
"signature"
,
client
)
logs
,
err
=
client
.
LoadLogs
(
time
.
Now
(),
100
)
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
len
(
logs
)
==
oldLogLength
+
3
)
entry
=
logs
[
len
(
logs
)
-
1
]
entry
=
logs
[
0
]
require
.
NotNil
(
t
,
entry
)
require
.
NoError
(
t
,
err
)
sig
,
err
:=
entry
.
GetSignedMessage
()
...
...
irmaclient/storage.go
View file @
3b35bfd6
...
...
@@ -3,6 +3,7 @@ package irmaclient
import
(
"encoding/json"
"io/ioutil"
"math"
"os"
"path/filepath"
...
...
@@ -128,7 +129,8 @@ func (s *storage) AddLogEntry(entry *LogEntry) error {
}
func
(
s
*
storage
)
logEntryKey
(
entry
*
LogEntry
)
interface
{}
{
return
time
.
Time
(
entry
.
Time
)
.
UnixNano
()
// Time is inverted to reverse sorting order
return
math
.
MaxInt64
^
time
.
Time
(
entry
.
Time
)
.
UnixNano
()
}
func
(
s
*
storage
)
StorePreferences
(
prefs
Preferences
)
error
{
...
...
@@ -205,9 +207,10 @@ func (s *storage) LoadKeyshareServers() (ksses map[irma.SchemeManagerIdentifier]
}
func
(
s
*
storage
)
LoadLogs
(
before
time
.
Time
,
max
int
)
([]
*
LogEntry
,
error
)
{
// Bolthold key uses inverted times, so before is inverted
var
logs
[]
*
LogEntry
return
logs
,
s
.
db
.
Find
(
&
logs
,
bolthold
.
Where
(
bolthold
.
Key
)
.
L
t
(
before
.
UnixNano
())
.
SortBy
(
"Time"
)
.
Reverse
()
.
Limit
(
max
),
bolthold
.
Where
(
bolthold
.
Key
)
.
G
t
(
math
.
MaxInt64
^
before
.
UnixNano
())
.
Limit
(
max
),
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment