From 8792bc29ee6faade1c1b3168b6111314647647d7 Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Wed, 6 Dec 2023 02:37:07 +0000 Subject: [PATCH] go fmt --- client/notificationBot_test.go | 2 +- mixmessages/ndf_test.go | 3 ++- mixmessages/roundError_test.go | 3 ++- mixmessages/roundInfo_test.go | 3 ++- mixmessages/sharePiece_test.go | 3 ++- network/dataStructures/circuit.go | 4 ++-- network/dataStructures/circuit_test.go | 26 +++++++++++------------ network/dataStructures/group.go | 3 ++- network/dataStructures/ipOverride.go | 6 +++--- network/dataStructures/ipOverride_test.go | 2 +- network/dataStructures/roundUpdates.go | 2 +- network/historicalRoundData_test.go | 2 +- network/instance.go | 8 +++---- network/instance_test.go | 2 +- network/validation.go | 3 ++- node/handler.go | 5 +++-- publicAddress/getAddress.go | 3 ++- 17 files changed, 44 insertions(+), 36 deletions(-) diff --git a/client/notificationBot_test.go b/client/notificationBot_test.go index e3635370..e93e84ae 100644 --- a/client/notificationBot_test.go +++ b/client/notificationBot_test.go @@ -49,7 +49,7 @@ func TestRegisterForNotifications(t *testing.T) { } -//Smoke test for UnregisterForNotifications +// Smoke test for UnregisterForNotifications func TestUnregisterForNotifications(t *testing.T) { testId := id.NewIdFromString("test", id.Generic, t) clientId := id.NewIdFromString("client", id.Generic, t) diff --git a/mixmessages/ndf_test.go b/mixmessages/ndf_test.go index 12490c94..e1ab4763 100644 --- a/mixmessages/ndf_test.go +++ b/mixmessages/ndf_test.go @@ -21,7 +21,8 @@ import ( // Ensure message type conforms to genericSignable interface // If this ever fails, check for modifications in the source library -// as well as for this message type +// +// as well as for this message type var _ = signature.GenericRsaSignable(&NDF{}) // ------------------------------------ Get tests ------------------------------------------ diff --git a/mixmessages/roundError_test.go b/mixmessages/roundError_test.go index 84593ef9..48c61455 100644 --- a/mixmessages/roundError_test.go +++ b/mixmessages/roundError_test.go @@ -21,7 +21,8 @@ import ( // Ensure message type conforms to genericSignable interface // If this ever fails, check for modifications in the crypto library -// as well as for this message type +// +// as well as for this message type var _ = signature.GenericRsaSignable(&RoundError{}) // -------------------------------- Get tests ----------------------------------------------------------- diff --git a/mixmessages/roundInfo_test.go b/mixmessages/roundInfo_test.go index 9a8cc760..334dbdb2 100644 --- a/mixmessages/roundInfo_test.go +++ b/mixmessages/roundInfo_test.go @@ -23,7 +23,8 @@ import ( // Ensure message type conforms to genericSignable interface // If this ever fails, check for modifications in the source library -// as well as for this message type +// +// as well as for this message type var _ = signature.GenericRsaSignable(&RoundInfo{}) var _ = signature.GenericEccSignable(&RoundInfo{}) diff --git a/mixmessages/sharePiece_test.go b/mixmessages/sharePiece_test.go index b73978a8..0ee2c55d 100644 --- a/mixmessages/sharePiece_test.go +++ b/mixmessages/sharePiece_test.go @@ -21,7 +21,8 @@ import ( // Ensure message type conforms to genericSignable interface // If this ever fails, check for modifications in the source library -// as well as for this message type +// +// as well as for this message type var _ = signature.GenericRsaSignable(&SharePiece{}) // -------------------------- Signature tests -------------------------------------- diff --git a/network/dataStructures/circuit.go b/network/dataStructures/circuit.go index 8fff00ea..ef82be8f 100644 --- a/network/dataStructures/circuit.go +++ b/network/dataStructures/circuit.go @@ -141,7 +141,7 @@ func (c *Circuit) GetOrdering() []*Circuit { return circuits } -//GetHostAtIndex: Gets host at requested index. Panics if index is outside +// GetHostAtIndex: Gets host at requested index. Panics if index is outside // of the range of the list func (c *Circuit) GetHostAtIndex(index int) *connect.Host { if index < 0 || index >= len(c.hosts) { @@ -151,7 +151,7 @@ func (c *Circuit) GetHostAtIndex(index int) *connect.Host { return c.hosts[index] } -//SetHosts takes a list of hosts and copies them into the list of hosts in +// SetHosts takes a list of hosts and copies them into the list of hosts in // the circuit object func (c *Circuit) AddHost(newHost *connect.Host) { c.hosts = append(c.hosts, newHost) diff --git a/network/dataStructures/circuit_test.go b/network/dataStructures/circuit_test.go index 3e2a8174..f9f9ed60 100644 --- a/network/dataStructures/circuit_test.go +++ b/network/dataStructures/circuit_test.go @@ -16,7 +16,7 @@ import ( "testing" ) -//Tests the happy path of NewCircuit +// Tests the happy path of NewCircuit func TestNew(t *testing.T) { nodeIdList := makeTestingNodeIdList(5, t) @@ -60,7 +60,7 @@ func TestNew(t *testing.T) { } } -//Tests that New circuit properly errors when a list with duplicate nodes is passed +// Tests that New circuit properly errors when a list with duplicate nodes is passed func TestNew_Duplicate(t *testing.T) { nodeIdList := makeTestingNodeIdList(5, t) @@ -78,7 +78,7 @@ func TestNew_Duplicate(t *testing.T) { } -//Tests that New circuit properly errors when a list with duplicate nodes is passed +// Tests that New circuit properly errors when a list with duplicate nodes is passed func TestNew_LenZero(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -175,7 +175,7 @@ func TestCircuit_GetNodeAtIndex_OutOfList_Greater(t *testing.T) { } -//Tests that GetHostAtIndex panics whn the passed index +// Tests that GetHostAtIndex panics whn the passed index // is len or greater func TestCircuit_GetHostAtIndex_OutOfList_Greater(t *testing.T) { nodeIdList := makeTestingNodeIdList(5, t) @@ -229,7 +229,7 @@ func TestCircuit_GetHostAtIndex(t *testing.T) { } -//Tests to see if node retrieved is in fact the last node +// Tests to see if node retrieved is in fact the last node func TestCircuit_GetLastNode(t *testing.T) { nodeIdList := makeTestingNodeIdList(23, t) circuit := NewCircuit(nodeIdList) @@ -239,7 +239,7 @@ func TestCircuit_GetLastNode(t *testing.T) { } } -//Tests that len returns the correct length +// Tests that len returns the correct length func TestCircuit_Len(t *testing.T) { for i := 1; i < 100; i++ { circuit := Circuit{nodes: make([]*id.ID, i)} @@ -251,7 +251,7 @@ func TestCircuit_Len(t *testing.T) { } } -//Tests that all nodes in the circuit return the correct next node +// Tests that all nodes in the circuit return the correct next node func TestCircuit_GetNextNode(t *testing.T) { nodeIdList := makeTestingNodeIdList(9, t) @@ -270,7 +270,7 @@ func TestCircuit_GetNextNode(t *testing.T) { } } -//Tests GetNextNode panics when the passed node is invalid +// Tests GetNextNode panics when the passed node is invalid func TestCircuit_GetNextNode_Invalid(t *testing.T) { nodeIdList := makeTestingNodeIdList(9, t) @@ -289,7 +289,7 @@ func TestCircuit_GetNextNode_Invalid(t *testing.T) { t.Errorf("Circuit.GetNextNode: did not panic with invalid nodeID") } -//Tests that all nodes in the circuit return the correct next node +// Tests that all nodes in the circuit return the correct next node func TestCircuit_GetPrevNode(t *testing.T) { nodeIdList := makeTestingNodeIdList(9, t) @@ -315,7 +315,7 @@ func TestCircuit_GetPrevNode(t *testing.T) { } } -//Tests GetPrevNode panics when the passed node is invalid +// Tests GetPrevNode panics when the passed node is invalid func TestCircuit_GetPrevNode_Invalid(t *testing.T) { nodeIdList := makeTestingNodeIdList(9, t) @@ -334,7 +334,7 @@ func TestCircuit_GetPrevNode_Invalid(t *testing.T) { t.Errorf("Circuit.GetPrevNode: did not panic with invalid nodeID") } -//Test that IsFirstNode is only true when passed first node +// Test that IsFirstNode is only true when passed first node func TestCircuit_IsFirstNode(t *testing.T) { nodeIdList := makeTestingNodeIdList(23, t) @@ -353,7 +353,7 @@ func TestCircuit_IsFirstNode(t *testing.T) { } } -//Tests that IsLastNode is only true when passed last node +// Tests that IsLastNode is only true when passed last node func TestCircuit_IsLastNode(t *testing.T) { nodeIdList := makeTestingNodeIdList(23, t) @@ -454,7 +454,7 @@ func checkShift(t *testing.T, a, b []*id.ID, rotations int) { } } -//Utility function +// Utility function func makeTestingNodeIdList(len int, t *testing.T) []*id.ID { var nodeIdList []*id.ID diff --git a/network/dataStructures/group.go b/network/dataStructures/group.go index 9ae4f51a..15fb092f 100644 --- a/network/dataStructures/group.go +++ b/network/dataStructures/group.go @@ -46,7 +46,8 @@ func (g *Group) GetString() string { // Update sets the group's string and cyclic.Group object // If these values have not been set yet, we set these two values // If these values are set and the newGroup is different, it errors -// as the group should be immutable after being set +// +// as the group should be immutable after being set func (g *Group) Update(newGroup string) error { g.Lock() defer g.Unlock() diff --git a/network/dataStructures/ipOverride.go b/network/dataStructures/ipOverride.go index b2320fec..a1f044d4 100644 --- a/network/dataStructures/ipOverride.go +++ b/network/dataStructures/ipOverride.go @@ -12,20 +12,20 @@ import ( "sync" ) -//structure which holds a list of IP address to override +// structure which holds a list of IP address to override type IpOverrideList struct { ipOverride map[id.ID]string sync.Mutex } -//creates a new list over IP overrides +// creates a new list over IP overrides func NewIpOverrideList() *IpOverrideList { return &IpOverrideList{ ipOverride: make(map[id.ID]string), } } -//sets an id to be overridden with a specific IP address +// sets an id to be overridden with a specific IP address func (iol *IpOverrideList) Override(oid *id.ID, ip string) { iol.Lock() iol.ipOverride[*oid] = ip diff --git a/network/dataStructures/ipOverride_test.go b/network/dataStructures/ipOverride_test.go index 0fd39525..e019c642 100644 --- a/network/dataStructures/ipOverride_test.go +++ b/network/dataStructures/ipOverride_test.go @@ -12,7 +12,7 @@ import ( "testing" ) -//tests that NewIpOverrideList returns a properly formatted override list +// tests that NewIpOverrideList returns a properly formatted override list func TestNewIpOverrideList(t *testing.T) { nol := NewIpOverrideList() diff --git a/network/dataStructures/roundUpdates.go b/network/dataStructures/roundUpdates.go index de0f2f41..872b1f99 100644 --- a/network/dataStructures/roundUpdates.go +++ b/network/dataStructures/roundUpdates.go @@ -52,7 +52,7 @@ func (u *Updates) GetUpdate(id int) (*pb.RoundInfo, error) { return val.(*Round).Get(), nil } -//gets all updates after a given ID +// gets all updates after a given ID func (u *Updates) GetUpdates(id int) []*pb.RoundInfo { interfaceList, err := u.updates.GetNewerById(id) diff --git a/network/historicalRoundData_test.go b/network/historicalRoundData_test.go index 22ac89ea..32833156 100644 --- a/network/historicalRoundData_test.go +++ b/network/historicalRoundData_test.go @@ -15,7 +15,7 @@ import ( "testing" ) -//region ERS Memory Map Impl +// region ERS Memory Map Impl // Memory map based ExtendedRoundStorage database type ersMemMap struct { rounds map[id.Round]*pb.RoundInfo diff --git a/network/instance.go b/network/instance.go index 3ecbe548..5021145c 100644 --- a/network/instance.go +++ b/network/instance.go @@ -250,7 +250,7 @@ func NewInstanceTesting(c *connect.ProtoComms, partial, full *ndf.NetworkDefinit return instance, nil } -//update the partial ndf +// update the partial ndf func (i *Instance) UpdatePartialNdf(m *pb.NDF) error { if i.partial == nil { return errors.New("Cannot update the partial ndf when it is nil") @@ -314,12 +314,12 @@ func (i *Instance) UpdatePartialNdf(m *pb.NDF) error { return nil } -//overrides an IP address for an ID with one from +// overrides an IP address for an ID with one from func (i *Instance) GetIpOverrideList() *ds.IpOverrideList { return i.ipOverride } -//Gets the node and gateway with the given ID +// Gets the node and gateway with the given ID func (i *Instance) GetNodeAndGateway(ngid *id.ID) (NodeGateway, error) { index := -1 @@ -364,7 +364,7 @@ func (i *Instance) GetNodeAndGateway(ngid *id.ID) (NodeGateway, error) { }, nil } -//update the full ndf +// update the full ndf func (i *Instance) UpdateFullNdf(m *pb.NDF) error { if i.full == nil { return errors.New("Cannot update the full ndf when it is nil") diff --git a/network/instance_test.go b/network/instance_test.go index 1657d91e..bb6b80cb 100644 --- a/network/instance_test.go +++ b/network/instance_test.go @@ -117,7 +117,7 @@ func TestNewInstanceTesting_Error(t *testing.T) { } -//tests newInstance errors properly when there is no NDF +// tests newInstance errors properly when there is no NDF func TestNewInstance_NilNDFs(t *testing.T) { _, err := NewInstance(&connect.ProtoComms{}, nil, nil, nil, 0, false) if err == nil { diff --git a/network/validation.go b/network/validation.go index 5285d939..8fe3278a 100644 --- a/network/validation.go +++ b/network/validation.go @@ -10,7 +10,8 @@ package network import "fmt" // Level of validation types for pulling our round structure -// Strict: Signatures are checked every time (intended for nodes) +// +// Strict: Signatures are checked every time (intended for nodes) // Lazy: Only check we're involved, only verifies the first retrieval // None: no signature checks are done type ValidationType uint8 diff --git a/node/handler.go b/node/handler.go index 0c18f722..4a68927e 100644 --- a/node/handler.go +++ b/node/handler.go @@ -358,8 +358,9 @@ func (s *Implementation) RoundError(err *mixmessages.RoundError, auth *connect.A // Consensus node -> cMix node NDF request // NOTE: For now cMix nodes serve the NDF to the -// consensus nodes, but this will be reversed -// once consensus generates the NDF +// +// consensus nodes, but this will be reversed +// once consensus generates the NDF func (s *Implementation) GetNDF() (*interconnect.NDF, error) { return s.Functions.GetNdf() } diff --git a/publicAddress/getAddress.go b/publicAddress/getAddress.go index c07d7b97..73738a2d 100644 --- a/publicAddress/getAddress.go +++ b/publicAddress/getAddress.go @@ -67,7 +67,8 @@ func getIpFromList(urls []Service, timeout time.Duration) (string, error) { // getIpMultiCheck returns the caller's public IP address that is provided from // multiple Services. Services are tried one by one until the given number of -// services return the same valid IPv4 address. +// +// services return the same valid IPv4 address. func getIpMultiCheck(urls []Service, timeout time.Duration, checks int) (string, error) { serviceList := shuffleStrings(urls) var ipv6 bool -- GitLab