Skip to content

Commit

Permalink
Stub out other RPC endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mslipper committed Aug 28, 2018
1 parent 58a8b42 commit e3f3712
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 9 deletions.
98 changes: 97 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions server/rpc/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
package rpc

import (
"github.com/cosmos/ethermint/version"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
"github.com/cosmos/ethermint/version"
)

// returns the master list of public APIs for use with StartHTTPEndpoint
Expand All @@ -17,13 +17,19 @@ func GetRPCAPIs() []rpc.API {
Version: "1.0",
Service: NewPublicWeb3API(),
},
{
Namespace: "eth",
Version: "1.0",
Service: NewPublicEthAPI(),
},
}
}

// PublicWeb3API is the web3_ prefixed set of APIs in the WEB3 JSON-RPC spec.
// PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
type PublicWeb3API struct {
}

// NewPublicWeb3API creates an instance of the Web3 API.
func NewPublicWeb3API() *PublicWeb3API {
return &PublicWeb3API{}
}
Expand Down
12 changes: 11 additions & 1 deletion server/rpc/apis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package rpc

import (
"context"
"github.com/cosmos/ethermint/version"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/cosmos/ethermint/version"
"testing"
)

Expand Down Expand Up @@ -37,6 +37,16 @@ func (s *apisTestSuite) TestPublicWeb3APISha3() {
require.Equal(s.T(), "0x1b84adea42d5b7d192fd8a61a85b25abe0757e9a65cab1da470258914053823f", res)
}

func (s *apisTestSuite) TestMiningAPIs() {
res, err := rpcCall(s.Port, "eth_mining", nil)
require.Nil(s.T(), err, "unexpected error")
require.Equal(s.T(), false, res)

res, err = rpcCall(s.Port, "eth_hashrate", nil)
require.Nil(s.T(), err, "unexpected error")
require.Equal(s.T(), "0x0", res)
}

func TestAPIsTestSuite(t *testing.T) {
suite.Run(t, new(apisTestSuite))
}
Expand Down
8 changes: 4 additions & 4 deletions server/rpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package rpc
// behavior of the RPC HTTP server.
type Config struct {
// EnableRPC defines whether or not to enable the RPC server
EnableRPC bool
EnableRPC bool
// RPCAddr defines the IP address to listen on
RPCAddr string
RPCAddr string
// RPCPort defines the port to listen on
RPCPort int
RPCPort int
// RPCCORSDomains defines list of domains to enable CORS headers for (used by browsers)
RPCCORSDomains []string
// RPCVhosts defines list of domains to listen on (useful if Tendermint is addressable via DNS)
RPCVHosts []string
RPCVHosts []string
}
Loading

0 comments on commit e3f3712

Please sign in to comment.