diff --git a/client/ws_client.go b/client/ws_client.go index b08905a8f84812921ad39b61f4203e97b74db35c..2f562927f6a99bb19852570f46b185f0e3da6c7b 100644 --- a/client/ws_client.go +++ b/client/ws_client.go @@ -29,21 +29,21 @@ func (this *WSClient) Dial() (*http.Response, error) { return r, err } this.conn = conn - + return r, nil } // returns a channel from which messages can be pulled // from a go routine that reads the socket. // if the ws returns an error (eg. closes), we return -func (this *WSClient) StartRead() <- chan []byte { +func (this *WSClient) StartRead() <-chan []byte { ch := make(chan []byte) go func() { for { _, msg, err := this.conn.ReadMessage() if err != nil { if !this.closed { - // TODO For now. + // TODO For now. fmt.Println("Error: " + err.Error()) close(ch) } @@ -62,4 +62,4 @@ func (this *WSClient) WriteMsg(msg []byte) { func (this *WSClient) Close() { this.closed = true this.conn.Close() -} \ No newline at end of file +} diff --git a/erisdb/erisdbss/server_manager.go b/erisdb/erisdbss/server_manager.go index cf96e86e52ebd48c2fdea39dffa5051772e5af99..34834526691126e481bea3031f21a013b3f279c8 100644 --- a/erisdb/erisdbss/server_manager.go +++ b/erisdb/erisdbss/server_manager.go @@ -188,7 +188,7 @@ func (this *ServerManager) add(data *RequestData) (*ResponseData, error) { // TODO add validation data. The node should ideally return some post-deploy state data // and send it back with the server URL, so that the validity of the chain can be // established client-side before starting the tests. - return &ResponseData{fmt.Sprintf("%d",port)}, nil + return &ResponseData{fmt.Sprintf("%d", port)}, nil } // Add a new erisdb process to the list. diff --git a/erisdb/pipe/filters.go b/erisdb/pipe/filters.go index ba05335541202d087c7b2740bf13c800dfda1c7b..dcf40aea23cb9d5845ce01a8dde5f0d03b3e6f48 100644 --- a/erisdb/pipe/filters.go +++ b/erisdb/pipe/filters.go @@ -177,14 +177,14 @@ func GetRangeFilter(op, fName string) (func(a, b int64) bool, error) { } } -func GetStringFilter(op, fName string) (func(s0, s1 string) bool, error){ +func GetStringFilter(op, fName string) (func(s0, s1 string) bool, error) { if op == "==" { return func(s0, s1 string) bool { - return strings.EqualFold(s0,s1) + return strings.EqualFold(s0, s1) }, nil } else if op == "!=" { return func(s0, s1 string) bool { - return !strings.EqualFold(s0,s1) + return !strings.EqualFold(s0, s1) }, nil } else { return nil, fmt.Errorf("Op: " + op + " is not supported for '" + fName + "' filtering.") diff --git a/erisdb/serve.go b/erisdb/serve.go index 9d1345477b4bf70a65d21b4d83b4dd9d7e3bb385..b8decee63528cda8587f2b0630da58ad4476f2a7 100644 --- a/erisdb/serve.go +++ b/erisdb/serve.go @@ -53,9 +53,9 @@ func ServeErisDB(workDir string) (*server.ServeProcess, error) { // Get tendermint configuration tmConfig = tmcfg.GetConfig(workDir) - tmConfig.Set("version", TENDERMINT_VERSION) + tmConfig.Set("version", TENDERMINT_VERSION) cfg.ApplyConfig(tmConfig) // Notify modules of new config - + // Set the node up. nodeRd := make(chan struct{}) nd := node.NewNode() diff --git a/erisdb/wsService.go b/erisdb/wsService.go index 215dc4d6ee7428f2b09eb986fb8dfea7c25c7c50..258cccea795696acba82149b0b616528286a62f6 100644 --- a/erisdb/wsService.go +++ b/erisdb/wsService.go @@ -1,11 +1,11 @@ package erisdb import ( + "encoding/json" "fmt" ep "github.com/eris-ltd/eris-db/erisdb/pipe" rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" - "encoding/json" ) // Used for ErisDb. Implements WebSocketService. @@ -37,7 +37,7 @@ func (this *ErisDbWsService) Process(msg []byte, session *server.WSSession) { // Error when unmarshaling. if errU != nil { - this.writeError("Failed to parse request: " + errU.Error() + " . Raw: " + string(msg), "", rpc.PARSE_ERROR, session) + this.writeError("Failed to parse request: "+errU.Error()+" . Raw: "+string(msg), "", rpc.PARSE_ERROR, session) return } diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index eb2cfd8abccb5ea9f59bbcd6fc665a695d4105bc..bfafa4c2f9861f01192de0ad9b9aba05897d304d 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -32,4 +32,4 @@ func TestNewJsonRpcErrorResponse(t *testing.T) { } respGen := NewRPCErrorResponse(id, code, message) assert.Equal(t, respGen, resp) -} \ No newline at end of file +} diff --git a/server/config.go b/server/config.go index 9d979f06b4747ba0ff09ed389c4c608d3ea4dc79..8accf2a0a5ff42f7479a55227f2553e7d69e5504 100644 --- a/server/config.go +++ b/server/config.go @@ -43,7 +43,7 @@ type ( } WebSocket struct { - WebSocketEndpoint string `toml:"websocket_endpoint"` + WebSocketEndpoint string `toml:"websocket_endpoint"` MaxWebSocketSessions uint `toml:"max_websocket_sessions"` } @@ -69,7 +69,7 @@ func DefaultServerConfig() *ServerConfig { CORS: CORS{}, HTTP: HTTP{JsonRpcEndpoint: "/rpc"}, WebSocket: WebSocket{ - WebSocketEndpoint: "/socketrpc", + WebSocketEndpoint: "/socketrpc", MaxWebSocketSessions: 50, }, Logging: Logging{ diff --git a/server/server.go b/server/server.go index d2532cd3b066c0f051819dde3b670d0bb27a926a..aa4004f17738e095346d3f48ed970422ac8fa5a5 100644 --- a/server/server.go +++ b/server/server.go @@ -51,7 +51,7 @@ func (this *ServeProcess) Start() error { router := gin.New() config := this.config - + InitLogger(config) // if config.CORS.Enable { @@ -123,7 +123,7 @@ func (this *ServeProcess) Start() error { } }() // Listen to the process stop event, it will call 'Stop' - // on the graceful Server. This happens when someone + // on the graceful Server. This happens when someone // calls 'Stop' on the process. go func() { <-this.stopChan @@ -234,4 +234,3 @@ func NewCORSMiddleware(options CORS) gin.HandlerFunc { } return cors.Middleware(o) } - diff --git a/server/websocket.go b/server/websocket.go index 2481fb570ae940516ba4613da7b1fd0392d8e745..06e1a6c226b23504f4ad5e48d225198b462171a3 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -70,7 +70,7 @@ func (this *WebSocketServer) Start(config *ServerConfig, router *gin.Engine) { // TODO Will this be enough for massive "get blockchain" requests? WriteBufferSize: 1024, } - this.upgrader.CheckOrigin = func(r *http.Request) bool {return true} + this.upgrader.CheckOrigin = func(r *http.Request) bool { return true } router.GET(config.WebSocket.WebSocketEndpoint, this.handleFunc) this.running = true diff --git a/test/filters/filter_test.go b/test/filters/filter_test.go index 13caed45a8514bfa5f4be6834b67e473566f1811..8d667744799240c518ea96df1974e3529e7ff860 100644 --- a/test/filters/filter_test.go +++ b/test/filters/filter_test.go @@ -2,17 +2,17 @@ package filters import ( "fmt" + . "github.com/eris-ltd/eris-db/erisdb/pipe" "github.com/stretchr/testify/suite" - "testing" "sync" - . "github.com/eris-ltd/eris-db/erisdb/pipe" + "testing" ) const OBJECTS = 100 type FilterableObject struct { Integer int - String string + String string } // Filter for integer value. @@ -76,37 +76,37 @@ func (this *StringFilter) Match(v interface{}) bool { // Test suite type FilterSuite struct { suite.Suite - objects []FilterableObject + objects []FilterableObject filterFactory *FilterFactory } func (this *FilterSuite) SetupSuite() { objects := make([]FilterableObject, OBJECTS, OBJECTS) - + for i := 0; i < 100; i++ { - objects[i] = FilterableObject{i, fmt.Sprintf("string%d",i)} + objects[i] = FilterableObject{i, fmt.Sprintf("string%d", i)} } - + ff := NewFilterFactory() - + ff.RegisterFilterPool("integer", &sync.Pool{ New: func() interface{} { return &IntegerFilter{} }, }) - + ff.RegisterFilterPool("string", &sync.Pool{ New: func() interface{} { return &StringFilter{} }, }) - + this.objects = objects this.filterFactory = ff } func (this *FilterSuite) TearDownSuite() { - + } // ********************************************* Tests ********************************************* @@ -191,7 +191,6 @@ func (this *FilterSuite) Test_FilterIntegersGTEQ() { this.Equal(arr, this.objects[77:]) } - func (this *FilterSuite) Test_FilterIntegersNEQ() { fd := &FilterData{"integer", "!=", "50"} filter, err := this.filterFactory.NewFilter([]*FilterData{fd}) @@ -221,13 +220,12 @@ func (this *FilterSuite) Test_FilterStringEquals() { this.Equal(arr, this.objects[7:8]) } - func (this *FilterSuite) Test_FilterStringNEQ() { fd := &FilterData{"string", "!=", "string50"} filter, err := this.filterFactory.NewFilter([]*FilterData{fd}) this.NoError(err) arr := []FilterableObject{} - + for _, o := range this.objects { if filter.Match(o) { arr = append(arr, o) @@ -243,4 +241,4 @@ func (this *FilterSuite) Test_FilterStringNEQ() { func TestFilterSuite(t *testing.T) { suite.Run(t, &FilterSuite{}) -} \ No newline at end of file +} diff --git a/test/mock/mock_web_api_test.go b/test/mock/mock_web_api_test.go index 456d628342587cd4640aa6f9adfa44764e81590d..09d97b8180c2167f481d71c6937e19e8690ccf66 100644 --- a/test/mock/mock_web_api_test.go +++ b/test/mock/mock_web_api_test.go @@ -12,12 +12,12 @@ import ( td "github.com/eris-ltd/eris-db/test/testdata/testdata" "github.com/gin-gonic/gin" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/account" "github.com/tendermint/log15" + "github.com/tendermint/tendermint/account" "net/http" - "testing" "os" "runtime" + "testing" ) func init() { diff --git a/test/web_api/query_test.go b/test/web_api/query_test.go index 5b6e1299a0c4e3194663ac30ed5409d646309d55..643e6acbc5d6aa8db07d9f471612b2d821952b81 100644 --- a/test/web_api/query_test.go +++ b/test/web_api/query_test.go @@ -2,7 +2,6 @@ package web_api // Basic imports import ( - "io/ioutil" "bytes" "fmt" edb "github.com/eris-ltd/eris-db/erisdb" @@ -12,6 +11,7 @@ import ( "github.com/eris-ltd/eris-db/server" fd "github.com/eris-ltd/eris-db/test/testdata/filters" "github.com/stretchr/testify/suite" + "io/ioutil" "net/http" "os" "path" @@ -71,7 +71,6 @@ func (this *QuerySuite) TearDownSuite() { // ********************************************* Tests ********************************************* - // TODO make these functions into one. func (this *QuerySuite) Test_Accounts0() { fd := this.testData.Input.Filters0 diff --git a/util/util.go b/util/util.go index b3f7b1b3a3de89ee55cf40f9c3910b1d0e3a0d51..c0acaefc64d4b75b74c66a4a3802e9edc0d0385f 100644 --- a/util/util.go +++ b/util/util.go @@ -32,4 +32,4 @@ func IsPubKey(str string) bool { // Is the candidate a private key string (64 bytes, hex). This is not a good name. func IsPrivKey(str string) bool { return privRe.MatchString(str) -} \ No newline at end of file +} diff --git a/util/util_test.go b/util/util_test.go index 5353d6714c7106761155f761a7279bf6e9ee3553..deef5ebb81a9af2c5fe4074d10662ebab3bdb145 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -12,7 +12,7 @@ func TestIsHexSuccess(t *testing.T) { // This should fail because there is a non matching character. func TestIsHexFailChar(t *testing.T) { - assert.False(t,IsHex("562Q")) + assert.False(t, IsHex("562Q")) } // This should succeed @@ -22,12 +22,12 @@ func TestIsHashSuccess(t *testing.T) { // This should fail because there is a non matching character. func TestIsHashFailChar(t *testing.T) { - assert.False(t,IsHash("RM4F4DC4A54620F1E0AA1213631C4DC2957B7415E3F8C066C30009BC57C4E5FC")) + assert.False(t, IsHash("RM4F4DC4A54620F1E0AA1213631C4DC2957B7415E3F8C066C30009BC57C4E5FC")) } // This should fail because the length is not right. func TestIsHashFailLength(t *testing.T) { - assert.False(t,IsHash("DA4F4DC4A54620F1E0AA1213631C4DC2957B7415E3F8C066C30009BC57C4E5F")) + assert.False(t, IsHash("DA4F4DC4A54620F1E0AA1213631C4DC2957B7415E3F8C066C30009BC57C4E5F")) } // This should succeed @@ -37,12 +37,12 @@ func TestIsAddressSuccess(t *testing.T) { // This should fail because there is a non matching character. func TestIsAddressFailChar(t *testing.T) { - assert.False(t,IsAddress("37236DF251AB70022B1DA351F08A20FB52443E3Q")) + assert.False(t, IsAddress("37236DF251AB70022B1DA351F08A20FB52443E3Q")) } // This should fail because the length is not right. func TestIsAddressFailLength(t *testing.T) { - assert.False(t,IsAddress("37236DF251AB70022B1DA351F08A20FB52443E")) + assert.False(t, IsAddress("37236DF251AB70022B1DA351F08A20FB52443E")) } // This should succeed @@ -52,12 +52,12 @@ func TestIsPubKeySuccess(t *testing.T) { // This should fail because there is a non matching character. func TestIsPubKeyFailChar(t *testing.T) { - assert.False(t,IsPubKey("CB3688B7I6TD488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906")) + assert.False(t, IsPubKey("CB3688B7I6TD488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906")) } // This should fail because the length is not right. func TestIsPubKeyFailLength(t *testing.T) { - assert.False(t,IsPubKey("CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11")) + assert.False(t, IsPubKey("CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11")) } // This should succeed @@ -67,10 +67,10 @@ func TestIsPrivKeySuccess(t *testing.T) { // This should fail because there is a non matching character. func TestIsPrivKeyFailChar(t *testing.T) { - assert.False(t,IsPrivKey("6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834ESAEE9398BEF94844D8BDBBCA980C11E3654A45906")) + assert.False(t, IsPrivKey("6B72D45EB65F619F11CE580C8CAED9E0BADC774E9C9C334687A65DCBAD2C4151CB3688B7561D488A2A4834ESAEE9398BEF94844D8BDBBCA980C11E3654A45906")) } // This should fail because the length is not right. func TestIsPrivKeyFailLength(t *testing.T) { - assert.False(t,IsPrivKey("6B72D45EB65F619F11CE580C8CAED9E0BADC774ED2C4151CB3688B7561D488A2A48EF94844D8BDBBCA980C11E3654A45906")) -} \ No newline at end of file + assert.False(t, IsPrivKey("6B72D45EB65F619F11CE580C8CAED9E0BADC774ED2C4151CB3688B7561D488A2A48EF94844D8BDBBCA980C11E3654A45906")) +}