Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
xxdk-wasm
Commits
8b3910d3
Commit
8b3910d3
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add test for duplicate inserts
parent
8266afbb
No related branches found
No related tags found
2 merge requests
!60
Revert "Fail a test to be sure it works"
,
!10
Make the message id index unique
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indexedDb/implementation.go
+2
-2
2 additions, 2 deletions
indexedDb/implementation.go
indexedDb/implementation_test.go
+44
-1
44 additions, 1 deletion
indexedDb/implementation_test.go
with
46 additions
and
3 deletions
indexedDb/implementation.go
+
2
−
2
View file @
8b3910d3
...
...
@@ -167,7 +167,7 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID,
if
!
messageID
.
Equals
(
cryptoChannel
.
MessageID
{})
{
jww
.
DEBUG
.
Printf
(
"non-empty messageID detected"
)
uuid
,
err
:=
w
.
msgIDLookup
(
messageID
)
if
err
!
=
nil
{
if
err
=
=
nil
{
jww
.
DEBUG
.
Printf
(
"MessageID found: %d"
,
uuid
)
// message is already in the database, no
// insert necessary
...
...
@@ -241,7 +241,7 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID,
// receives their own message from the mixnet.
if
!
messageID
.
Equals
(
cryptoChannel
.
MessageID
{})
{
uuid
,
err
:=
w
.
msgIDLookup
(
messageID
)
if
err
!
=
nil
{
if
err
=
=
nil
{
// message is already in the database, no insert necessary
return
uuid
}
...
...
This diff is collapsed.
Click to expand it.
indexedDb/implementation_test.go
+
44
−
1
View file @
8b3910d3
...
...
@@ -126,7 +126,7 @@ func TestWasmModel_JoinChannel_LeaveChannel(t *testing.T) {
}
}
// Test
wasmModel.UpdateSentStatus happy path and ensure fields don't change.
// Test
UUID gets returned when different messages are added
func
TestWasmModel_UUIDTest
(
t
*
testing
.
T
)
{
testString
:=
"testHello"
eventModel
,
err
:=
newWASMModel
(
testString
,
dummyCallback
)
...
...
@@ -167,3 +167,46 @@ func TestWasmModel_UUIDTest(t *testing.T) {
}
}
}
// TestWasmModel_DuplicateReceives tests if the same message ID being sent
// always returns the same uuid
func
TestWasmModel_DuplicateReceives
(
t
*
testing
.
T
)
{
testString
:=
"testHello"
eventModel
,
err
:=
newWASMModel
(
testString
,
dummyCallback
)
if
err
!=
nil
{
t
.
Fatalf
(
"%+v"
,
err
)
}
cid
:=
channel
.
Identity
{
Codename
:
"codename123"
,
PubKey
:
[]
byte
{
8
,
6
,
7
,
5
},
Color
:
"#FFFFFF"
,
Extension
:
"gif"
,
CodesetVersion
:
0
,
}
uuids
:=
make
([]
uint64
,
10
)
msgID
:=
channel
.
MessageID
{}
copy
(
msgID
[
:
],
testString
)
for
i
:=
0
;
i
<
10
;
i
++
{
// Store a test message
channelID
:=
id
.
NewIdFromBytes
([]
byte
(
testString
),
t
)
rnd
:=
rounds
.
Round
{
ID
:
id
.
Round
(
42
)}
uuid
:=
eventModel
.
ReceiveMessage
(
channelID
,
msgID
,
"test"
,
testString
+
fmt
.
Sprintf
(
"%d"
,
i
),
cid
,
time
.
Now
(),
time
.
Hour
,
rnd
,
0
,
channels
.
Sent
)
uuids
[
i
]
=
uuid
}
_
,
_
=
eventModel
.
dump
(
messageStoreName
)
for
i
:=
0
;
i
<
10
;
i
++
{
for
j
:=
i
+
1
;
j
<
10
;
j
++
{
if
uuids
[
i
]
!=
uuids
[
j
]
{
t
.
Fatalf
(
"uuid failed: %d[%d] != %d[%d]"
,
uuids
[
i
],
i
,
uuids
[
j
],
j
)
}
}
}
}
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