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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
43f1046b
Commit
43f1046b
authored
Sep 13, 2022
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix WaitForNetwork
parent
45c57d9a
No related branches found
No related tags found
1 merge request
!6
XX-4050 / Send E2E test
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/sendE2E/sender.html
+1
-1
1 addition, 1 deletion
examples/sendE2E/sender.html
examples/sendE2E/xxdk.js
+27
-26
27 additions, 26 deletions
examples/sendE2E/xxdk.js
wasm/follow.go
+11
-2
11 additions, 2 deletions
wasm/follow.go
wasm/identity.go
+2
-2
2 additions, 2 deletions
wasm/identity.go
with
41 additions
and
31 deletions
examples/sendE2E/sender.html
+
1
−
1
View file @
43f1046b
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
const
stopNetworkFollowerBtn
=
document
.
getElementById
(
"
stopNetworkFollowerBtn
"
)
const
stopNetworkFollowerBtn
=
document
.
getElementById
(
"
stopNetworkFollowerBtn
"
)
// Client specific parameters
// Client specific parameters
const
recipientContactFile
=
'
<xxc(2)
I71lyX8LvKP6cJhedliFLIKzXN/2ArmBAfAxkk1QapADrgZ7Ugdw/BAr6RDo4K2MfHn7e06Kru7jW05ROtaaoNSyMIB3R77BIJy7xB/fvkzteTpxxmHtZdXPt9UpYVA9WKzbM57vkmy+U6BlRJIrN97tAlWbODIG1FGpjWI/BCdqwaLgu0wTYLzzEw38NNyax0E2MnvURgQoSfnX5V+m+Qd2sJBqfBKi9tlLu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ContactFileName
=
''
;
const
statePath
=
'
statePathSender
'
;
const
statePath
=
'
statePathSender
'
;
const
statePass
=
'
password
'
;
const
statePass
=
'
password
'
;
...
...
This diff is collapsed.
Click to expand it.
examples/sendE2E/xxdk.js
+
27
−
26
View file @
43f1046b
...
@@ -56,7 +56,7 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
...
@@ -56,7 +56,7 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
htmlConsole
.
log
(
"
Getting reception identity.
"
)
htmlConsole
.
log
(
"
Getting reception identity.
"
)
identity
=
LoadReceptionIdentity
(
identityStorageKey
,
net
.
GetID
());
identity
=
LoadReceptionIdentity
(
identityStorageKey
,
net
.
GetID
());
}
catch
(
e
)
{
}
catch
(
e
)
{
htmlConsole
.
log
(
"
No reception identity found. Generating a new one
:
"
+
e
)
htmlConsole
.
log
(
"
No reception identity found. Generating a new one
.
"
)
// If no extant xxdk.ReceptionIdentity, generate and store a new one
// If no extant xxdk.ReceptionIdentity, generate and store a new one
identity
=
net
.
MakeReceptionIdentity
();
identity
=
net
.
MakeReceptionIdentity
();
...
@@ -109,27 +109,26 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
...
@@ -109,27 +109,26 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
htmlConsole
.
log
(
"
Started network follower
"
)
htmlConsole
.
log
(
"
Started network follower
"
)
stopNetworkFollowerBtn
.
style
.
display
=
'
block
'
;
stopNetworkFollowerBtn
.
style
.
display
=
'
block
'
;
stopNetworkFollowerBtn
.
addEventListener
(
'
click
'
,
()
=>
{
stopNetworkFollowerBtn
.
addEventListener
(
'
click
'
,
async
()
=>
{
htmlConsole
.
log
(
"
Stopping network follower
"
)
htmlConsole
.
log
(
"
Stopping network follower
"
)
net
.
StopNetworkFollower
()
try
{
})
await
net
.
StopNetworkFollower
()
}
catch
(
e
)
{
// Provide a callback that will be signalled when network health status changes
htmlConsole
.
log
(
"
Failed to stop network follower:
"
+
e
)
let
health
=
false
net
.
AddHealthCallback
({
Callback
:
function
(
healthy
)
{
health
=
healthy
;
}
}
})
;
})
// Wait for network to become healthy
htmlConsole
.
log
(
"
Waiting for network to be healthy
"
)
htmlConsole
.
log
(
"
Waiting for network to be healthy
"
)
try
{
net
.
WaitForNetwork
(
25000
).
then
(
await
sleepUntil
(()
=>
health
===
true
,
25000
);
()
=>
{
}
catch
{
htmlConsole
.
log
(
"
Network is healthy
"
)
htmlConsole
.
error
(
"
Timed out. Network is not healthy:
"
+
health
)
},
throw
new
Error
(
"
Timed out. Network is not healthy:
"
+
health
)
()
=>
{
htmlConsole
.
error
(
"
Timed out. Network is not healthy.
"
)
throw
new
Error
(
"
Timed out. Network is not healthy.
"
)
}
}
htmlConsole
.
log
(
"
Network is healthy:
"
+
health
)
)
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
...
@@ -160,7 +159,7 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
...
@@ -160,7 +159,7 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
if
(
recipientContactFile
!==
''
)
{
if
(
recipientContactFile
!==
''
)
{
let
exists
=
false
;
let
exists
=
false
;
htmlConsole
.
log
(
"
getting ID from contact
"
)
htmlConsole
.
log
(
"
getting ID from contact
"
)
const
recipientContactID
=
GetIDFromContact
(
recipientContactFile
);
const
recipientContactID
=
GetIDFromContact
(
enc
.
encode
(
recipientContactFile
)
)
;
const
recipientContactIDBase64
=
Uint8ArrayToBase64
(
recipientContactID
)
const
recipientContactIDBase64
=
Uint8ArrayToBase64
(
recipientContactID
)
htmlConsole
.
log
(
"
Checking if partner
"
+
recipientContactIDBase64
+
"
exists
"
)
htmlConsole
.
log
(
"
Checking if partner
"
+
recipientContactIDBase64
+
"
exists
"
)
...
@@ -195,6 +194,8 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
...
@@ -195,6 +194,8 @@ async function SendE2e(htmlConsole, stopNetworkFollowerBtn, ndf,
throw
new
Error
(
"
Did not receive confirm:
"
+
confirm
)
throw
new
Error
(
"
Did not receive confirm:
"
+
confirm
)
}
}
console
.
log
(
"
confirmContact:
"
+
confirmContact
)
console
.
log
(
"
confirmContact:
"
+
dec
.
decode
(
confirmContact
))
const
confirmContactID
=
GetIDFromContact
(
confirmContact
)
const
confirmContactID
=
GetIDFromContact
(
confirmContact
)
if
(
!
Uint8ArrayEquals
(
recipientContactID
,
confirmContactID
))
{
if
(
!
Uint8ArrayEquals
(
recipientContactID
,
confirmContactID
))
{
htmlConsole
.
log
(
"
contact ID from confirmation
"
+
htmlConsole
.
log
(
"
contact ID from confirmation
"
+
...
...
This diff is collapsed.
Click to expand it.
wasm/follow.go
+
11
−
2
View file @
43f1046b
...
@@ -88,9 +88,18 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} {
...
@@ -88,9 +88,18 @@ func (c *Cmix) StopNetworkFollower(js.Value, []js.Value) interface{} {
// - args[0] - timeout when stopping threads in milliseconds (int)
// - args[0] - timeout when stopping threads in milliseconds (int)
//
//
// Returns:
// Returns:
// - returns true if the network is healthy (boolean)
// - A promise that resolves if the network is healthy and rejects if the
// network is not healthy.
func
(
c
*
Cmix
)
WaitForNetwork
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
func
(
c
*
Cmix
)
WaitForNetwork
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
return
c
.
api
.
WaitForNetwork
(
args
[
0
]
.
Int
())
promiseFn
:=
func
(
resolve
,
reject
func
(
args
...
interface
{})
js
.
Value
)
{
if
c
.
api
.
WaitForNetwork
(
args
[
0
]
.
Int
())
{
resolve
()
}
else
{
reject
()
}
}
return
utils
.
CreatePromise
(
promiseFn
)
}
}
// NetworkFollowerStatus gets the state of the network follower. It returns a
// NetworkFollowerStatus gets the state of the network follower. It returns a
...
...
This diff is collapsed.
Click to expand it.
wasm/identity.go
+
2
−
2
View file @
43f1046b
...
@@ -135,13 +135,13 @@ func GetContactFromReceptionIdentity(_ js.Value, args []js.Value) interface{} {
...
@@ -135,13 +135,13 @@ func GetContactFromReceptionIdentity(_ js.Value, args []js.Value) interface{} {
// GetIDFromContact returns the ID in the [contact.Contact] object.
// GetIDFromContact returns the ID in the [contact.Contact] object.
//
//
// Parameters:
// Parameters:
// - args[0] - marshalled bytes of [contact.Contact] (
string
)
// - args[0] - marshalled bytes of [contact.Contact] (
Uint8Array
)
//
//
// Returns:
// Returns:
// - marshalled [id.ID] object (Uint8Array)
// - marshalled [id.ID] object (Uint8Array)
// - throws a TypeError if loading the ID from the contact file fails
// - throws a TypeError if loading the ID from the contact file fails
func
GetIDFromContact
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
func
GetIDFromContact
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
cID
,
err
:=
bindings
.
GetIDFromContact
(
[]
byte
(
args
[
0
]
.
String
()
))
cID
,
err
:=
bindings
.
GetIDFromContact
(
utils
.
CopyBytesToGo
(
args
[
0
]
))
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Throw
(
utils
.
TypeError
,
err
)
utils
.
Throw
(
utils
.
TypeError
,
err
)
return
nil
return
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