go-eth-proxy

Transparent proxy server for eth-cache
Info | Log | Files | Refs

service_test.go (1006B)


      1 package proxy
      2 
      3 import (
      4 	"log"
      5 	"os"
      6 	"testing"
      7 
      8 	"github.com/ethereum/go-ethereum/rpc"
      9 	"github.com/ethereum/go-ethereum/core/types"
     10 
     11 	"defalsify.org/go-eth-proxy/store/lmdb"
     12 )
     13 
     14 func TestProxyServerStart(t *testing.T) {
     15 	var err error
     16 	var tx types.Transaction
     17 	tx_test := "0x60891c813816bb378ee8af428c5eb53b0479c980307d265e4abe39b4efd02e1d"
     18 	//tx_test := "0xffee674f0467b59ce6dd455e9256f95f41118a5bf15a3cedf3d20b5fcbb787a1"
     19 
     20 	dbpath, dbenv := os.LookupEnv("TEST_LMDB_DIR")
     21 	if !dbenv {
     22 		dbpath = "."
     23 	}
     24 	log.Printf("dbpath %s", dbpath)
     25 
     26 	db, err := lmdb.NewStore(dbpath)
     27 	if err != nil {
     28 		t.Error(err)
     29 	}
     30 	defer db.Close()
     31 	svc := NewProxyService(db)
     32 
     33 	srv := rpc.NewServer()
     34 	err = srv.RegisterName("eth", svc)
     35 	if err != nil {
     36 		t.Fatal(err)
     37 	}
     38 	client := rpc.DialInProc(srv)
     39 	mods, err := client.SupportedModules()
     40 	if err != nil {
     41 		t.Fatal(err)
     42 	}
     43 	t.Logf("mods %s", mods)
     44 	err = client.Call(&tx, "eth_getTransactionByHash", tx_test)
     45 	if err != nil {
     46 		t.Fatal(err)
     47 	}
     48 	t.Logf("tx %v", tx_test)
     49 }