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
88167f39
Commit
88167f39
authored
Jan 18, 2015
by
Viktor Trón
Committed by
Felix Lange
Feb 5, 2015
Browse files
Options
Downloads
Patches
Plain Diff
add privkey to clientIdentity + tests
parent
c8a8aa0d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
p2p/client_identity.go
+11
-4
11 additions, 4 deletions
p2p/client_identity.go
p2p/client_identity_test.go
+10
-1
10 additions, 1 deletion
p2p/client_identity_test.go
with
21 additions
and
5 deletions
p2p/client_identity.go
+
11
−
4
View file @
88167f39
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
type
ClientIdentity
interface
{
type
ClientIdentity
interface
{
String
()
string
// human readable identity
String
()
string
// human readable identity
Pubkey
()
[]
byte
// 512-bit public key
Pubkey
()
[]
byte
// 512-bit public key
PrivKey
()
[]
byte
// 512-bit private key
}
}
type
SimpleClientIdentity
struct
{
type
SimpleClientIdentity
struct
{
...
@@ -17,10 +18,11 @@ type SimpleClientIdentity struct {
...
@@ -17,10 +18,11 @@ type SimpleClientIdentity struct {
customIdentifier
string
customIdentifier
string
os
string
os
string
implementation
string
implementation
string
privkey
[]
byte
pubkey
[]
byte
pubkey
[]
byte
}
}
func
NewSimpleClientIdentity
(
clientIdentifier
string
,
version
string
,
customIdentifier
string
,
pubkey
[]
byte
)
*
SimpleClientIdentity
{
func
NewSimpleClientIdentity
(
clientIdentifier
string
,
version
string
,
customIdentifier
string
,
privkey
[]
byte
,
pubkey
[]
byte
)
*
SimpleClientIdentity
{
clientIdentity
:=
&
SimpleClientIdentity
{
clientIdentity
:=
&
SimpleClientIdentity
{
clientIdentifier
:
clientIdentifier
,
clientIdentifier
:
clientIdentifier
,
version
:
version
,
version
:
version
,
...
@@ -28,6 +30,7 @@ func NewSimpleClientIdentity(clientIdentifier string, version string, customIden
...
@@ -28,6 +30,7 @@ func NewSimpleClientIdentity(clientIdentifier string, version string, customIden
os
:
runtime
.
GOOS
,
os
:
runtime
.
GOOS
,
implementation
:
runtime
.
Version
(),
implementation
:
runtime
.
Version
(),
pubkey
:
pubkey
,
pubkey
:
pubkey
,
privkey
:
privkey
,
}
}
return
clientIdentity
return
clientIdentity
...
@@ -50,8 +53,12 @@ func (c *SimpleClientIdentity) String() string {
...
@@ -50,8 +53,12 @@ func (c *SimpleClientIdentity) String() string {
c
.
implementation
)
c
.
implementation
)
}
}
func
(
c
*
SimpleClientIdentity
)
Privkey
()
[]
byte
{
return
c
.
privkey
}
func
(
c
*
SimpleClientIdentity
)
Pubkey
()
[]
byte
{
func
(
c
*
SimpleClientIdentity
)
Pubkey
()
[]
byte
{
return
[]
byte
(
c
.
pubkey
)
return
c
.
pubkey
}
}
func
(
c
*
SimpleClientIdentity
)
SetCustomIdentifier
(
customIdentifier
string
)
{
func
(
c
*
SimpleClientIdentity
)
SetCustomIdentifier
(
customIdentifier
string
)
{
...
...
This diff is collapsed.
Click to expand it.
p2p/client_identity_test.go
+
10
−
1
View file @
88167f39
package
p2p
package
p2p
import
(
import
(
"bytes"
"fmt"
"fmt"
"runtime"
"runtime"
"testing"
"testing"
)
)
func
TestClientIdentity
(
t
*
testing
.
T
)
{
func
TestClientIdentity
(
t
*
testing
.
T
)
{
clientIdentity
:=
NewSimpleClientIdentity
(
"Ethereum(G)"
,
"0.5.16"
,
"test"
,
[]
byte
(
"pubkey"
))
clientIdentity
:=
NewSimpleClientIdentity
(
"Ethereum(G)"
,
"0.5.16"
,
"test"
,
[]
byte
(
"privkey"
),
[]
byte
(
"pubkey"
))
key
:=
clientIdentity
.
Privkey
()
if
!
bytes
.
Equal
(
key
,
[]
byte
(
"privkey"
))
{
t
.
Errorf
(
"Expected Privkey to be %x, got %x"
,
key
,
[]
byte
(
"privkey"
))
}
key
=
clientIdentity
.
Pubkey
()
if
!
bytes
.
Equal
(
key
,
[]
byte
(
"pubkey"
))
{
t
.
Errorf
(
"Expected Pubkey to be %x, got %x"
,
key
,
[]
byte
(
"pubkey"
))
}
clientString
:=
clientIdentity
.
String
()
clientString
:=
clientIdentity
.
String
()
expected
:=
fmt
.
Sprintf
(
"Ethereum(G)/v0.5.16/test/%s/%s"
,
runtime
.
GOOS
,
runtime
.
Version
())
expected
:=
fmt
.
Sprintf
(
"Ethereum(G)/v0.5.16/test/%s/%s"
,
runtime
.
GOOS
,
runtime
.
Version
())
if
clientString
!=
expected
{
if
clientString
!=
expected
{
...
...
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