Prefer all caps for initialisms and acronyms

This commit is contained in:
Rob Mulholand
2019-10-31 13:42:19 -05:00
parent eba868ff00
commit e1236b4072
62 changed files with 315 additions and 315 deletions
+11 -11
View File
@@ -33,12 +33,12 @@ import (
type IPropertiesReader interface {
NodeInfo() (id string, name string)
NetworkId() float64
NetworkID() float64
GenesisBlock() string
}
type PropertiesReader struct {
client core.RpcClient
client core.RPCClient
}
type ParityClient struct {
@@ -57,18 +57,18 @@ type GanacheClient struct {
PropertiesReader
}
func MakeNode(rpcClient core.RpcClient) core.Node {
func MakeNode(rpcClient core.RPCClient) core.Node {
pr := makePropertiesReader(rpcClient)
id, name := pr.NodeInfo()
return core.Node{
GenesisBlock: pr.GenesisBlock(),
NetworkID: pr.NetworkId(),
NetworkID: pr.NetworkID(),
ID: id,
ClientName: name,
}
}
func makePropertiesReader(client core.RpcClient) IPropertiesReader {
func makePropertiesReader(client core.RPCClient) IPropertiesReader {
switch getNodeType(client) {
case core.GETH:
return GethClient{PropertiesReader: PropertiesReader{client: client}}
@@ -83,7 +83,7 @@ func makePropertiesReader(client core.RpcClient) IPropertiesReader {
}
}
func getNodeType(client core.RpcClient) core.NodeType {
func getNodeType(client core.RPCClient) core.NodeType {
if strings.Contains(client.IpcPath(), "infura") {
return core.INFURA
}
@@ -97,14 +97,14 @@ func getNodeType(client core.RpcClient) core.NodeType {
return core.PARITY
}
func (reader PropertiesReader) NetworkId() float64 {
func (reader PropertiesReader) NetworkID() float64 {
var version string
err := reader.client.CallContext(context.Background(), &version, "net_version")
if err != nil {
log.Println(err)
}
networkId, _ := strconv.ParseFloat(version, 64)
return networkId
networkID, _ := strconv.ParseFloat(version, 64)
return networkID
}
func (reader PropertiesReader) GenesisBlock() string {
@@ -142,10 +142,10 @@ func (client ParityClient) parityNodeInfo() string {
}
func (client ParityClient) parityID() string {
var enodeId = regexp.MustCompile(`^enode://(.+)@.+$`)
var enodeID = regexp.MustCompile(`^enode://(.+)@.+$`)
var enodeURL string
client.client.CallContext(context.Background(), &enodeURL, "parity_enode")
enode := enodeId.FindStringSubmatch(enodeURL)
enode := enodeID.FindStringSubmatch(enodeURL)
if len(enode) < 2 {
return ""
}
+6 -6
View File
@@ -65,7 +65,7 @@ var _ = Describe("Node Info", func() {
})
It("returns parity ID and client name for parity node", func() {
client := fakes.NewMockRpcClient()
client := fakes.NewMockRPCClient()
n := node.MakeNode(client)
Expect(n.ID).To(Equal("ParityNode"))
@@ -74,19 +74,19 @@ var _ = Describe("Node Info", func() {
})
It("returns the genesis block for any client", func() {
client := fakes.NewMockRpcClient()
client := fakes.NewMockRPCClient()
n := node.MakeNode(client)
Expect(n.GenesisBlock).To(Equal(EmpytHeaderHash))
})
It("returns the network id for any client", func() {
client := fakes.NewMockRpcClient()
client := fakes.NewMockRPCClient()
n := node.MakeNode(client)
Expect(n.NetworkID).To(Equal(float64(1234)))
})
It("returns geth ID and client name for geth node", func() {
client := fakes.NewMockRpcClient()
client := fakes.NewMockRPCClient()
supportedModules := make(map[string]string)
supportedModules["admin"] = "ok"
client.SetSupporedModules(supportedModules)
@@ -97,7 +97,7 @@ var _ = Describe("Node Info", func() {
})
It("returns infura ID and client name for infura node", func() {
client := fakes.NewMockRpcClient()
client := fakes.NewMockRPCClient()
client.SetIpcPath("infura/path")
n := node.MakeNode(client)
Expect(n.ID).To(Equal("infura"))
@@ -105,7 +105,7 @@ var _ = Describe("Node Info", func() {
})
It("returns local id and client name for Local node", func() {
client := fakes.NewMockRpcClient()
client := fakes.NewMockRPCClient()
client.SetIpcPath("127.0.0.1")
n := node.MakeNode(client)
Expect(n.ID).To(Equal("ganache"))