good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
open
bor
Commits
1f2adb05
Commit
1f2adb05
authored
Jan 21, 2015
by
Viktor Trón
Committed by
Felix Lange
Feb 5, 2015
Browse files
Options
Downloads
Patches
Plain Diff
add initial peer level test (failing)
parent
4afde4e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
p2p/crypto_test.go
+52
-1
52 additions, 1 deletion
p2p/crypto_test.go
with
52 additions
and
1 deletion
p2p/crypto_test.go
+
52
−
1
View file @
1f2adb05
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
// "crypto/elliptic"
// "crypto/elliptic"
// "crypto/rand"
// "crypto/rand"
"fmt"
"fmt"
"net"
"testing"
"testing"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
...
@@ -114,7 +115,9 @@ func TestCryptoHandshake(t *testing.T) {
...
@@ -114,7 +115,9 @@ func TestCryptoHandshake(t *testing.T) {
t
.
Errorf
(
"%v"
,
err
)
t
.
Errorf
(
"%v"
,
err
)
}
}
fmt
.
Printf
(
"
\n
auth %x
\n
initNonce %x
\n
response%x
\n
remoteRecNonce %x
\n
remoteInitNonce %x
\n
remoteRandomPubKey %x
\n
recNonce %x
\n
remoteInitRandomPubKey %x
\n
initSessionToken %x
\n\n
"
,
auth
,
initNonce
,
response
,
remoteRecNonce
,
remoteInitNonce
,
remoteRandomPubKey
,
recNonce
,
remoteInitRandomPubKey
,
initSessionToken
)
fmt
.
Printf
(
"
\n
auth (%v) %x
\n\n
resp (%v) %x
\n\n
"
,
len
(
auth
),
auth
,
len
(
response
),
response
)
// fmt.Printf("\nauth %x\ninitNonce %x\nresponse%x\nremoteRecNonce %x\nremoteInitNonce %x\nremoteRandomPubKey %x\nrecNonce %x\nremoteInitRandomPubKey %x\ninitSessionToken %x\n\n", auth, initNonce, response, remoteRecNonce, remoteInitNonce, remoteRandomPubKey, recNonce, remoteInitRandomPubKey, initSessionToken)
if
!
bytes
.
Equal
(
initNonce
,
remoteInitNonce
)
{
if
!
bytes
.
Equal
(
initNonce
,
remoteInitNonce
)
{
t
.
Errorf
(
"nonces do not match"
)
t
.
Errorf
(
"nonces do not match"
)
...
@@ -140,3 +143,51 @@ func TestCryptoHandshake(t *testing.T) {
...
@@ -140,3 +143,51 @@ func TestCryptoHandshake(t *testing.T) {
}
}
}
}
func
TestPeersHandshake
(
t
*
testing
.
T
)
{
defer
testlog
(
t
)
.
detach
()
var
err
error
// var sessionToken []byte
prv0
,
_
:=
crypto
.
GenerateKey
()
// = ecdsa.GenerateKey(crypto.S256(), rand.Reader)
pub0
:=
&
prv0
.
PublicKey
prv1
,
_
:=
crypto
.
GenerateKey
()
pub1
:=
&
prv1
.
PublicKey
prv0s
:=
crypto
.
FromECDSA
(
prv0
)
pub0s
:=
crypto
.
FromECDSAPub
(
pub0
)
prv1s
:=
crypto
.
FromECDSA
(
prv1
)
pub1s
:=
crypto
.
FromECDSAPub
(
pub1
)
conn1
,
conn2
:=
net
.
Pipe
()
initiator
:=
newPeer
(
conn1
,
[]
Protocol
{},
nil
)
receiver
:=
newPeer
(
conn2
,
[]
Protocol
{},
nil
)
initiator
.
dialAddr
=
&
peerAddr
{
IP
:
net
.
ParseIP
(
"1.2.3.4"
),
Port
:
2222
,
Pubkey
:
pub1s
[
1
:
]}
initiator
.
ourID
=
&
peerId
{
prv0s
,
pub0s
}
// this is cheating. identity of initiator/dialler not available to listener/receiver
// its public key should be looked up based on IP address
receiver
.
identity
=
initiator
.
ourID
receiver
.
ourID
=
&
peerId
{
prv1s
,
pub1s
}
initiator
.
pubkeyHook
=
func
(
*
peerAddr
)
error
{
return
nil
}
receiver
.
pubkeyHook
=
func
(
*
peerAddr
)
error
{
return
nil
}
initiator
.
cryptoHandshake
=
true
receiver
.
cryptoHandshake
=
true
errc0
:=
make
(
chan
error
,
1
)
errc1
:=
make
(
chan
error
,
1
)
go
func
()
{
_
,
err
:=
initiator
.
loop
()
errc0
<-
err
}()
go
func
()
{
_
,
err
:=
receiver
.
loop
()
errc1
<-
err
}()
select
{
case
err
=
<-
errc0
:
t
.
Errorf
(
"peer 0 quit with error: %v"
,
err
)
case
err
=
<-
errc1
:
t
.
Errorf
(
"peer 1 quit with error: %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