From 0dd9cb3164c8b44c974244cea21106b414e74cff Mon Sep 17 00:00:00 2001 From: Silas Davis <silas@erisindustries.com> Date: Thu, 11 Aug 2016 20:48:08 +0200 Subject: [PATCH] Some formatting clean up --- client/ws_client.go | 3 +- consensus/consensus.go | 1 + definitions/do.go | 2 +- files/files_test.go | 3 +- manager/eris-mint/eris-mint.go | 2 -- manager/eris-mint/evm/native.go | 1 + manager/eris-mint/evm/opcodes.go | 1 + manager/eris-mint/evm/stack.go | 1 + permission/types/permissions.go | 1 + rpc/rpc_test.go | 3 +- rpc/tendermint/test/common.go | 1 + rpc/tendermint/test/genesis.go | 9 ----- rpc/tendermint/test/shared.go | 3 +- server/server_test.go | 3 +- test/fixtures/file_fixtures.go | 9 ++++- test/mock/pipe.go | 10 +++--- test/server/http_burst_test.go | 3 +- test/server/ws_burst_test.go | 5 +-- test/testdata/helpers.go | 8 +++-- test/testdata/testdata/testdata.go | 56 +++++++++++++++--------------- txs/names.go | 3 +- txs/tx_utils.go | 1 + 22 files changed, 71 insertions(+), 58 deletions(-) diff --git a/client/ws_client.go b/client/ws_client.go index 2f562927..f2542c1a 100644 --- a/client/ws_client.go +++ b/client/ws_client.go @@ -3,8 +3,9 @@ package client import ( "fmt" - "github.com/gorilla/websocket" "net/http" + + "github.com/gorilla/websocket" ) // A websocket client subscribes and unsubscribes to events diff --git a/consensus/consensus.go b/consensus/consensus.go index 369210be..fb0fdab3 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -33,6 +33,7 @@ func LoadConsensusEngineInPipe(moduleConfig *config.ModuleConfig, if err != nil { return fmt.Errorf("Failed to load Tendermint node: %v", err) } + if err := pipe.SetConsensusEngine(tendermintNode); err != nil { return fmt.Errorf("Failed to hand Tendermint node to pipe: %v", err) } diff --git a/definitions/do.go b/definitions/do.go index 0ad4e108..273dc348 100644 --- a/definitions/do.go +++ b/definitions/do.go @@ -48,7 +48,7 @@ type Do struct { // Zip bool // Tarball bool DisableRpc bool - Config *viper.Viper + Config *viper.Viper // Accounts []*Account // Result string } diff --git a/files/files_test.go b/files/files_test.go index 2d9cdc23..16943df7 100644 --- a/files/files_test.go +++ b/files/files_test.go @@ -2,10 +2,11 @@ package files import ( "bytes" - "github.com/stretchr/testify/assert" "os" "path" "testing" + + "github.com/stretchr/testify/assert" ) var tempFolder = os.TempDir() diff --git a/manager/eris-mint/eris-mint.go b/manager/eris-mint/eris-mint.go index fb869083..e5ba9308 100644 --- a/manager/eris-mint/eris-mint.go +++ b/manager/eris-mint/eris-mint.go @@ -161,8 +161,6 @@ func (app *ErisMint) CheckTx(txBytes []byte) (res tmsp.Result) { return tmsp.NewError(tmsp.CodeType_EncodingError, fmt.Sprintf("Encoding error: %v", err)) } - log.Info("CheckTx", "tx", *tx) - // TODO: make errors tmsp aware err = sm.ExecTx(app.checkCache, *tx, false, nil) if err != nil { diff --git a/manager/eris-mint/evm/native.go b/manager/eris-mint/evm/native.go index 55b18a16..860f99bd 100644 --- a/manager/eris-mint/evm/native.go +++ b/manager/eris-mint/evm/native.go @@ -2,6 +2,7 @@ package vm import ( "crypto/sha256" + "golang.org/x/crypto/ripemd160" . "github.com/tendermint/go-common" diff --git a/manager/eris-mint/evm/opcodes.go b/manager/eris-mint/evm/opcodes.go index 87e09bfd..63e6b297 100644 --- a/manager/eris-mint/evm/opcodes.go +++ b/manager/eris-mint/evm/opcodes.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "gopkg.in/fatih/set.v0" ) diff --git a/manager/eris-mint/evm/stack.go b/manager/eris-mint/evm/stack.go index 979aba2e..3f3d727f 100644 --- a/manager/eris-mint/evm/stack.go +++ b/manager/eris-mint/evm/stack.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + . "github.com/tendermint/go-common" ) diff --git a/permission/types/permissions.go b/permission/types/permissions.go index cca221f8..5cdcdaf8 100644 --- a/permission/types/permissions.go +++ b/permission/types/permissions.go @@ -2,6 +2,7 @@ package types import ( "fmt" + . "github.com/tendermint/go-common" ) diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index bfafa4c2..f728d822 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -1,8 +1,9 @@ package rpc import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) // ... diff --git a/rpc/tendermint/test/common.go b/rpc/tendermint/test/common.go index d9ef3230..77be9cb1 100644 --- a/rpc/tendermint/test/common.go +++ b/rpc/tendermint/test/common.go @@ -8,6 +8,7 @@ import ( // Needs to be in a _test.go file to be picked up func TestWrapper(runner func() int) int { ffs := fixtures.NewFileFixtures("Eris-DB") + defer ffs.RemoveAll() err := initGlobalVariables(ffs) diff --git a/rpc/tendermint/test/genesis.go b/rpc/tendermint/test/genesis.go index 61cf2e6b..3136a933 100644 --- a/rpc/tendermint/test/genesis.go +++ b/rpc/tendermint/test/genesis.go @@ -38,12 +38,3 @@ var defaultGenesis = `{ } ] }` - -var defaultPrivValidator = `{ - "address": "1D7A91CB32F758A02EBB9BE1FB6F8DEE56F90D42", - "pub_key": [1,"06FBAC4E285285D1D91FCBC7E91C780ADA11516F67462340B3980CE2B94940E8"], - "priv_key": [1,"C453604BD6480D5538B4C6FD2E3E314B5BCE518D75ADE4DA3DA85AB8ADFD819606FBAC4E285285D1D91FCBC7E91C780ADA11516F67462340B3980CE2B94940E8"], - "last_height":0, - "last_round":0, - "last_step":0 -}` diff --git a/rpc/tendermint/test/shared.go b/rpc/tendermint/test/shared.go index 13ab2570..475e029b 100644 --- a/rpc/tendermint/test/shared.go +++ b/rpc/tendermint/test/shared.go @@ -17,10 +17,11 @@ import ( "github.com/tendermint/go-crypto" rpcclient "github.com/tendermint/go-rpc/client" + "path" + "github.com/spf13/viper" tm_common "github.com/tendermint/go-common" "github.com/tendermint/tendermint/types" - "path" ) // global variables for use across all tests diff --git a/server/server_test.go b/server/server_test.go index 05d954b7..61569515 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -2,8 +2,9 @@ package server import ( //"fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) // Unit tests for server components goes here. Full-on client-server tests diff --git a/test/fixtures/file_fixtures.go b/test/fixtures/file_fixtures.go index 5935e54c..0e188762 100644 --- a/test/fixtures/file_fixtures.go +++ b/test/fixtures/file_fixtures.go @@ -1,9 +1,10 @@ package fixtures import ( - "github.com/docker/docker/pkg/ioutils" "os" "path" + + "github.com/docker/docker/pkg/ioutils" ) // FileFixtures writes files to a temporary location for use in testing. @@ -25,6 +26,12 @@ func NewFileFixtures(identifyingPrefix string) *FileFixtures { } } +// Returns the root temporary directory that this FileFixtures will populate and +// clear on RemoveAll() +func (ffs *FileFixtures) TempDir() string { + return ffs.tempDir +} + // Add a file relative to the FileFixtures tempDir using name for the relative // part of the path. func (ffs *FileFixtures) AddFile(name, content string) string { diff --git a/test/mock/pipe.go b/test/mock/pipe.go index 413e6e1a..4cec0050 100644 --- a/test/mock/pipe.go +++ b/test/mock/pipe.go @@ -2,11 +2,11 @@ package mock import ( "fmt" - - account "github.com/eris-ltd/eris-db/account" - core_types "github.com/eris-ltd/eris-db/core/types" - definitions "github.com/eris-ltd/eris-db/definitions" - event "github.com/eris-ltd/eris-db/event" + + account "github.com/eris-ltd/eris-db/account" + core_types "github.com/eris-ltd/eris-db/core/types" + definitions "github.com/eris-ltd/eris-db/definitions" + event "github.com/eris-ltd/eris-db/event" manager_types "github.com/eris-ltd/eris-db/manager/types" td "github.com/eris-ltd/eris-db/test/testdata/testdata" diff --git a/test/server/http_burst_test.go b/test/server/http_burst_test.go index c2a1e89d..bb49275b 100644 --- a/test/server/http_burst_test.go +++ b/test/server/http_burst_test.go @@ -2,10 +2,11 @@ package server import ( // "fmt" - "github.com/stretchr/testify/assert" "net/http" "testing" "time" + + "github.com/stretchr/testify/assert" ) const ( diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go index aef23a19..cb9e7af4 100644 --- a/test/server/ws_burst_test.go +++ b/test/server/ws_burst_test.go @@ -1,11 +1,12 @@ package server import ( + "testing" + "time" + "github.com/eris-ltd/eris-db/client" "github.com/eris-ltd/eris-db/server" "github.com/stretchr/testify/assert" - "testing" - "time" ) const CONNS uint16 = 100 diff --git a/test/testdata/helpers.go b/test/testdata/helpers.go index 2b2b2edb..127440f7 100644 --- a/test/testdata/helpers.go +++ b/test/testdata/helpers.go @@ -2,14 +2,16 @@ package testdata import ( "fmt" - "github.com/eris-ltd/eris-db/files" - "github.com/eris-ltd/eris-db/server" "os" "path" - . "github.com/tendermint/go-common" + "github.com/eris-ltd/eris-db/files" + "github.com/eris-ltd/eris-db/server" + stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" + . "github.com/tendermint/go-common" "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/types" ) const TendermintConfigDefault = `# This is a TOML config file. diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index 34c7c895..56894ecb 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -1,11 +1,11 @@ package testdata import ( - account "github.com/eris-ltd/eris-db/account" - core_types "github.com/eris-ltd/eris-db/core/types" - event "github.com/eris-ltd/eris-db/event" - rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0" - stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" + account "github.com/eris-ltd/eris-db/account" + core_types "github.com/eris-ltd/eris-db/core/types" + event "github.com/eris-ltd/eris-db/event" + stypes "github.com/eris-ltd/eris-db/manager/eris-mint/state/types" + rpc_v0 "github.com/eris-ltd/eris-db/rpc/v0" transaction "github.com/eris-ltd/eris-db/txs" mintTypes "github.com/tendermint/tendermint/types" @@ -512,22 +512,22 @@ type ( GetAccountData struct { Input *rpc_v0.AddressParam `json:"input"` - Output *account.Account `json:"output"` + Output *account.Account `json:"output"` } GetAccountsData struct { - Input *rpc_v0.AccountsParam `json:"input"` - Output *core_types.AccountList `json:"output"` + Input *rpc_v0.AccountsParam `json:"input"` + Output *core_types.AccountList `json:"output"` } GetStorageData struct { Input *rpc_v0.AddressParam `json:"input"` - Output *core_types.Storage `json:"output"` + Output *core_types.Storage `json:"output"` } GetStorageAtData struct { - Input *rpc_v0.StorageAtParam `json:"input"` - Output *core_types.StorageItem `json:"output"` + Input *rpc_v0.StorageAtParam `json:"input"` + Output *core_types.StorageItem `json:"output"` } GenPrivAccountData struct { @@ -556,12 +556,12 @@ type ( GetBlockData struct { Input *rpc_v0.HeightParam `json:"input"` - Output *mintTypes.Block `json:"output"` + Output *mintTypes.Block `json:"output"` } GetBlocksData struct { - Input *rpc_v0.BlocksParam `json:"input"` - Output *core_types.Blocks `json:"output"` + Input *rpc_v0.BlocksParam `json:"input"` + Output *core_types.Blocks `json:"output"` } GetConsensusStateData struct { @@ -597,18 +597,18 @@ type ( } GetPeerData struct { - Input *rpc_v0.PeerParam `json:"input"` - Output *core_types.Peer `json:"output"` + Input *rpc_v0.PeerParam `json:"input"` + Output *core_types.Peer `json:"output"` } TransactData struct { Input *rpc_v0.TransactParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } TransactCreateData struct { Input *rpc_v0.TransactParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } GetUnconfirmedTxsData struct { @@ -617,36 +617,36 @@ type ( CallCodeData struct { Input *rpc_v0.CallCodeParam `json:"input"` - Output *core_types.Call `json:"output"` + Output *core_types.Call `json:"output"` } CallData struct { - Input *rpc_v0.CallParam `json:"input"` - Output *core_types.Call `json:"output"` + Input *rpc_v0.CallParam `json:"input"` + Output *core_types.Call `json:"output"` } EventSubscribeData struct { - Input *rpc_v0.EventIdParam `json:"input"` - Output *event.EventSub `json:"output"` + Input *rpc_v0.EventIdParam `json:"input"` + Output *event.EventSub `json:"output"` } EventUnsubscribeData struct { - Input *rpc_v0.SubIdParam `json:"input"` - Output *event.EventUnsub `json:"output"` + Input *rpc_v0.SubIdParam `json:"input"` + Output *event.EventUnsub `json:"output"` } TransactNameRegData struct { Input *rpc_v0.TransactNameRegParam `json:"input"` - Output *transaction.Receipt `json:"output"` + Output *transaction.Receipt `json:"output"` } GetNameRegEntryData struct { Input *rpc_v0.NameRegEntryParam `json:"input"` - Output *core_types.NameRegEntry `json:"output"` + Output *core_types.NameRegEntry `json:"output"` } GetNameRegEntriesData struct { - Input *rpc_v0.FilterListParam `json:"input"` + Input *rpc_v0.FilterListParam `json:"input"` Output *core_types.ResultListNames `json:"output"` } diff --git a/txs/names.go b/txs/names.go index 657cdc15..1cc00e16 100644 --- a/txs/names.go +++ b/txs/names.go @@ -1,8 +1,9 @@ package txs import ( - core_types "github.com/eris-ltd/eris-db/core/types" "regexp" + + core_types "github.com/eris-ltd/eris-db/core/types" ) var ( diff --git a/txs/tx_utils.go b/txs/tx_utils.go index e6979510..cdc4be24 100644 --- a/txs/tx_utils.go +++ b/txs/tx_utils.go @@ -2,6 +2,7 @@ package txs import ( "fmt" + acm "github.com/eris-ltd/eris-db/account" ptypes "github.com/eris-ltd/eris-db/permission/types" -- GitLab