Test API through jsonrpc
This commit is contained in:
parent
ba846e9bfb
commit
4ac8eba59e
@ -3,10 +3,11 @@ package node
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
|
||||
"github.com/ipfs/go-datastore"
|
||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
exchange "github.com/ipfs/go-ipfs-exchange-interface"
|
||||
|
@ -2,10 +2,14 @@ package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/filecoin-project/go-lotus/api/test"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/filecoin-project/go-lotus/api/client"
|
||||
"github.com/filecoin-project/go-lotus/api/test"
|
||||
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
||||
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
)
|
||||
|
||||
@ -32,3 +36,22 @@ func builder(t *testing.T, n int) []api.API {
|
||||
func TestAPI(t *testing.T) {
|
||||
test.TestApis(t, builder)
|
||||
}
|
||||
|
||||
var nextApi int
|
||||
|
||||
func rpcBuilder(t *testing.T, n int) []api.API {
|
||||
nodeApis := builder(t, n)
|
||||
out := make([]api.API, n)
|
||||
|
||||
for i, a := range nodeApis {
|
||||
rpcServer := jsonrpc.NewServer()
|
||||
rpcServer.Register("Filecoin", a)
|
||||
testServ := httptest.NewServer(rpcServer) // todo: close
|
||||
out[i] = client.NewRPC(testServ.URL)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestAPIRPC(t *testing.T) {
|
||||
test.TestApis(t, rpcBuilder)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user