forked from cerc-io/ipld-eth-server
Add FlipKick log events transformer
This commit is contained in:
@@ -37,6 +37,10 @@ type InfuraClient struct {
|
||||
PropertiesReader
|
||||
}
|
||||
|
||||
type GanacheClient struct {
|
||||
PropertiesReader
|
||||
}
|
||||
|
||||
func MakeNode(rpcClient core.RpcClient) core.Node {
|
||||
pr := makePropertiesReader(rpcClient)
|
||||
id, name := pr.NodeInfo()
|
||||
@@ -56,6 +60,8 @@ func makePropertiesReader(client core.RpcClient) IPropertiesReader {
|
||||
return ParityClient{PropertiesReader: PropertiesReader{client: client}}
|
||||
case core.INFURA:
|
||||
return InfuraClient{PropertiesReader: PropertiesReader{client: client}}
|
||||
case core.GANACHE:
|
||||
return GanacheClient{PropertiesReader: PropertiesReader{client: client}}
|
||||
default:
|
||||
return PropertiesReader{client: client}
|
||||
}
|
||||
@@ -65,6 +71,9 @@ func getNodeType(client core.RpcClient) core.NodeType {
|
||||
if strings.Contains(client.IpcPath(), "infura") {
|
||||
return core.INFURA
|
||||
}
|
||||
if strings.Contains(client.IpcPath(), "127.0.0.1") || strings.Contains(client.IpcPath(), "localhost") {
|
||||
return core.GANACHE
|
||||
}
|
||||
modules, _ := client.SupportedModules()
|
||||
if _, ok := modules["admin"]; ok {
|
||||
return core.GETH
|
||||
@@ -106,6 +115,10 @@ func (client InfuraClient) NodeInfo() (string, string) {
|
||||
return "infura", "infura"
|
||||
}
|
||||
|
||||
func (client GanacheClient) NodeInfo() (string, string) {
|
||||
return "ganache", "ganache"
|
||||
}
|
||||
|
||||
func (client ParityClient) parityNodeInfo() string {
|
||||
var nodeInfo core.ParityNodeInfo
|
||||
client.client.CallContext(context.Background(), &nodeInfo, "parity_versionInfo")
|
||||
|
||||
+51
-36
@@ -1,23 +1,22 @@
|
||||
package node_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
var EmpytHeaderHash = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
|
||||
|
||||
var _ = Describe("Parity Node Info", func() {
|
||||
|
||||
It("verifies parity_versionInfo can be unmarshalled into ParityNodeInfo", func() {
|
||||
var parityNodeInfo core.ParityNodeInfo
|
||||
nodeInfoJSON := []byte(
|
||||
`{
|
||||
var _ = Describe("Node Info", func() {
|
||||
Describe("Parity Node Info", func() {
|
||||
It("verifies parity_versionInfo can be unmarshalled into ParityNodeInfo", func() {
|
||||
var parityNodeInfo core.ParityNodeInfo
|
||||
nodeInfoJSON := []byte(
|
||||
`{
|
||||
"hash": "0x2ae8b4ca278dd7b896090366615fef81cbbbc0e0",
|
||||
"track": "null",
|
||||
"version": {
|
||||
@@ -26,25 +25,34 @@ var _ = Describe("Parity Node Info", func() {
|
||||
"patch": 0
|
||||
}
|
||||
}`)
|
||||
json.Unmarshal(nodeInfoJSON, &parityNodeInfo)
|
||||
Expect(parityNodeInfo.Hash).To(Equal("0x2ae8b4ca278dd7b896090366615fef81cbbbc0e0"))
|
||||
Expect(parityNodeInfo.Track).To(Equal("null"))
|
||||
Expect(parityNodeInfo.Major).To(Equal(1))
|
||||
Expect(parityNodeInfo.Minor).To(Equal(6))
|
||||
Expect(parityNodeInfo.Patch).To(Equal(0))
|
||||
})
|
||||
json.Unmarshal(nodeInfoJSON, &parityNodeInfo)
|
||||
Expect(parityNodeInfo.Hash).To(Equal("0x2ae8b4ca278dd7b896090366615fef81cbbbc0e0"))
|
||||
Expect(parityNodeInfo.Track).To(Equal("null"))
|
||||
Expect(parityNodeInfo.Major).To(Equal(1))
|
||||
Expect(parityNodeInfo.Minor).To(Equal(6))
|
||||
Expect(parityNodeInfo.Patch).To(Equal(0))
|
||||
})
|
||||
|
||||
It("Creates client string", func() {
|
||||
parityNodeInfo := core.ParityNodeInfo{
|
||||
Track: "null",
|
||||
ParityVersion: core.ParityVersion{
|
||||
Major: 1,
|
||||
Minor: 6,
|
||||
Patch: 0,
|
||||
},
|
||||
Hash: "0x1232144j",
|
||||
}
|
||||
Expect(parityNodeInfo.String()).To(Equal("Parity/v1.6.0/"))
|
||||
It("Creates client string", func() {
|
||||
parityNodeInfo := core.ParityNodeInfo{
|
||||
Track: "null",
|
||||
ParityVersion: core.ParityVersion{
|
||||
Major: 1,
|
||||
Minor: 6,
|
||||
Patch: 0,
|
||||
},
|
||||
Hash: "0x1232144j",
|
||||
}
|
||||
Expect(parityNodeInfo.String()).To(Equal("Parity/v1.6.0/"))
|
||||
})
|
||||
|
||||
It("returns parity ID and client name for parity node", func() {
|
||||
client := fakes.NewMockRpcClient()
|
||||
|
||||
n := node.MakeNode(client)
|
||||
Expect(n.ID).To(Equal("ParityNode"))
|
||||
Expect(n.ClientName).To(Equal("Parity/v1.2.3/"))
|
||||
})
|
||||
})
|
||||
|
||||
It("returns the genesis block for any client", func() {
|
||||
@@ -59,17 +67,12 @@ var _ = Describe("Parity Node Info", func() {
|
||||
Expect(n.NetworkID).To(Equal(float64(1234)))
|
||||
})
|
||||
|
||||
It("returns parity ID and client name for parity node", func() {
|
||||
client := fakes.NewMockRpcClient()
|
||||
client.SetNodeType(core.PARITY)
|
||||
n := node.MakeNode(client)
|
||||
Expect(n.ID).To(Equal("ParityNode"))
|
||||
Expect(n.ClientName).To(Equal("Parity/v1.2.3/"))
|
||||
})
|
||||
|
||||
It("returns geth ID and client name for geth node", func() {
|
||||
client := fakes.NewMockRpcClient()
|
||||
client.SetNodeType(core.GETH)
|
||||
supportedModules := make(map[string]string)
|
||||
supportedModules["admin"] = "ok"
|
||||
client.SetSupporedModules(supportedModules)
|
||||
|
||||
n := node.MakeNode(client)
|
||||
Expect(n.ID).To(Equal("enode://GethNode@172.17.0.1:30303"))
|
||||
Expect(n.ClientName).To(Equal("Geth/v1.7"))
|
||||
@@ -77,10 +80,22 @@ var _ = Describe("Parity Node Info", func() {
|
||||
|
||||
It("returns infura ID and client name for infura node", func() {
|
||||
client := fakes.NewMockRpcClient()
|
||||
client.SetNodeType(core.INFURA)
|
||||
client.SetIpcPath("infura/path")
|
||||
n := node.MakeNode(client)
|
||||
Expect(n.ID).To(Equal("infura"))
|
||||
Expect(n.ClientName).To(Equal("infura"))
|
||||
})
|
||||
|
||||
It("returns local id and client name for Local node", func() {
|
||||
client := fakes.NewMockRpcClient()
|
||||
client.SetIpcPath("127.0.0.1")
|
||||
n := node.MakeNode(client)
|
||||
Expect(n.ID).To(Equal("ganache"))
|
||||
Expect(n.ClientName).To(Equal("ganache"))
|
||||
|
||||
client.SetIpcPath("localhost")
|
||||
n = node.MakeNode(client)
|
||||
Expect(n.ID).To(Equal("ganache"))
|
||||
Expect(n.ClientName).To(Equal("ganache"))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user