Skip to content
Snippets Groups Projects
Commit 2d5972c9 authored by Sydney Anne Erickson's avatar Sydney Anne Erickson :chipmunk:
Browse files

Remove unused code

parent 684d791f
No related branches found
No related tags found
No related merge requests found
...@@ -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)
......
///////////////////////////////////////////////////////////////////////////////
// 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
}
*/
///////////////////////////////////////////////////////////////////////////////
// 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")
}
}
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment