Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
client
Commits
2d5972c9
Commit
2d5972c9
authored
4 years ago
by
Sydney Anne Erickson
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused code
parent
684d791f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/version.go
+1
-4
1 addition, 4 deletions
cmd/version.go
permissioning/remoteVersion.go
+0
-47
0 additions, 47 deletions
permissioning/remoteVersion.go
permissioning/remoteVersion_test.go
+0
-108
0 additions, 108 deletions
permissioning/remoteVersion_test.go
with
1 addition
and
159 deletions
cmd/version.go
+
1
−
4
View file @
2d5972c9
...
@@ -11,6 +11,7 @@ package cmd
...
@@ -11,6 +11,7 @@ package cmd
import
(
import
(
"fmt"
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"gitlab.com/elixxir/client/api"
"gitlab.com/elixxir/client/api"
"gitlab.com/xx_network/primitives/utils"
"gitlab.com/xx_network/primitives/utils"
...
@@ -26,10 +27,6 @@ func Version() string {
...
@@ -26,10 +27,6 @@ func Version() string {
return
out
return
out
}
}
func
GetVersion
()
string
{
return
currentVersion
}
func
init
()
{
func
init
()
{
rootCmd
.
AddCommand
(
versionCmd
)
rootCmd
.
AddCommand
(
versionCmd
)
rootCmd
.
AddCommand
(
generateCmd
)
rootCmd
.
AddCommand
(
generateCmd
)
...
...
This diff is collapsed.
Click to expand it.
permissioning/remoteVersion.go
deleted
100644 → 0
+
0
−
47
View file @
684d791f
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package
permissioning
/*
// GetNetworkVersion contacts the permissioning server and returns the current
// supported client version.
// returns a bool which designates if the network is enforcing versioning
// (not enforcing versioning is mostly a debugging)
// returns the version and an error if problems arise
func (perm *Permissioning) GetNetworkVersion() (bool, version.Version, error) {
return getRemoteVersion(perm.host, perm.comms)
}
type getRemoteClientVersionComms interface {
SendGetCurrentClientVersionMessage(host *connect.Host) (*pb.ClientVersion, error)
}
// getRemoteVersion contacts the permissioning server and returns the current
// supported client version.
func getRemoteVersion(permissioningHost *connect.Host, comms getRemoteClientVersionComms) (bool, version.Version, error) {
//gets the remote version
response, err := comms.SendGetCurrentClientVersionMessage(
permissioningHost)
if err != nil {
return false, version.Version{}, errors.WithMessage(err,
"Failed to get minimum client version from network")
}
if response.Version == "" {
return false, version.Version{}, nil
}
netVersion, err := version.ParseVersion(response.Version)
if err != nil {
return false, version.Version{}, errors.WithMessagef(err,
"Failed to parse minimum client version %s from network",
response.Version)
}
return true, netVersion, nil
}
*/
This diff is collapsed.
Click to expand it.
permissioning/remoteVersion_test.go
deleted
100644 → 0
+
0
−
108
View file @
684d791f
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package
permissioning
import
(
pb
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/comms/connect"
)
type
MockVersionSender
struct
{
// param passed to SendRegistrationMessage
host
*
connect
.
Host
// original host returned from GetHost
getHost
*
connect
.
Host
succeedGetHost
bool
returnVersion
string
returnErr
error
}
func
(
s
*
MockVersionSender
)
SendGetCurrentClientVersionMessage
(
_
*
connect
.
Host
)
(
*
pb
.
ClientVersion
,
error
)
{
return
&
pb
.
ClientVersion
{
Version
:
s
.
returnVersion
},
s
.
returnErr
}
/*
// Test happy path: get a version
func TestPermissioning_GetNetworkVersion(t *testing.T) {
var sender MockVersionSender
var err error
sender.succeedGetHost = true
sender.getHost, err = connect.NewHost(&id.Permissioning, "address", nil,
connect.GetDefaultHostParams())
if err != nil {
t.Fatal(err)
}
sender.returnErr = nil
sender.returnVersion = "0.1.0"
ok, version, err := getRemoteVersion(sender.getHost, &sender)
if err != nil {
t.Error(err)
}
if ok != true {
t.Error("ok should be true after getting a response from permissioning")
}
if version.String() != sender.returnVersion {
t.Error("getRemoteVersion should have returned the version we asked for")
}
}
// Test errors: version unparseable or missing, or error returned
func TestPermissioning_GetNetworkVersion_Errors(t *testing.T) {
var sender MockVersionSender
var err error
sender.succeedGetHost = true
sender.getHost, err = connect.NewHost(&id.Permissioning, "address", nil,
connect.GetDefaultHostParams())
if err != nil {
t.Fatal(err)
}
// Case 1: RPC returns error
sender.returnErr = errors.New("an error")
sender.returnVersion = "0.1.0"
ok, v, err := getRemoteVersion(sender.getHost, &sender)
if ok {
t.Error("shouldn't have gotten OK in error case")
}
if !reflect.DeepEqual(v, version.Version{}) {
t.Error("returned version should be empty")
}
if err == nil {
t.Error("error should exist")
}
// Case 2: RPC returns an empty string
sender.returnErr = nil
sender.returnVersion = ""
ok, v, err = getRemoteVersion(sender.getHost, &sender)
if ok {
t.Error("shouldn't have gotten OK in error case")
}
if !reflect.DeepEqual(v, version.Version{}) {
t.Error("returned version should be empty")
}
if err != nil {
t.Error("returning an empty string and no error isn't an error case, so no error should be returned")
}
// Case 3: RPC returns an unparseable string
sender.returnErr = nil
sender.returnVersion = "flooble doodle"
ok, v, err = getRemoteVersion(sender.getHost, &sender)
if ok {
t.Error("shouldn't have gotten OK in error case")
}
if !reflect.DeepEqual(v, version.Version{}) {
t.Error("returned version should be empty")
}
if err == nil {
t.Error("Should return an error indicating the version string was unparseable")
}
}
*/
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