diff --git a/blockchain/filter.go b/blockchain/filter.go index c61f77fb1c7803ef3ef03f3e51f5cea4616804ec..d0780f90e8773bae11db67b6d7580a8d1e8fc44b 100644 --- a/blockchain/filter.go +++ b/blockchain/filter.go @@ -70,7 +70,7 @@ func FilterBlocks(blockchain blockchain_types.Blockchain, // Optimization. Break any height filters out. Messy but makes sure we don't // fetch more blocks then necessary. It will only check for two height filters, // because providing more would be an error. - if filterData == nil || len(filterData) == 0 { + if len(filterData) == 0 { minHeight = 0 maxHeight = height } else { @@ -178,29 +178,24 @@ func getHeightMinMax(fda []*event.FilterData, height int) (int, int, []*event.Fi } min = val max = val - break case "<": mx := val - 1 if mx > min && mx < max { max = mx } - break case "<=": if val > min && val < max { max = val } - break case ">": mn := val + 1 if mn < max && mn > min { min = mn } - break case ">=": if val < max && val > min { min = val } - break default: return 0, 0, nil, fmt.Errorf("Operator not supported") } @@ -214,10 +209,3 @@ func getHeightMinMax(fda []*event.FilterData, height int) (int, int, []*event.Fi } return min, max, fda, nil } - -func min(x, y int) int { - if x > y { - return y - } - return x -} diff --git a/client/cmd/burrow-client.go b/client/cmd/burrow-client.go index 788d7fd16b727cf0eb9b2878486c4c32494114a3..77f746a38f4cee038f141e265f1c9ebbeacb0857 100644 --- a/client/cmd/burrow-client.go +++ b/client/cmd/burrow-client.go @@ -17,7 +17,6 @@ package commands import ( "os" "strconv" - "strings" "github.com/spf13/cobra" @@ -100,11 +99,3 @@ func setDefaultString(envVar, def string) string { } return def } - -func setDefaultStringSlice(envVar string, def []string) []string { - env := os.Getenv(envVar) - if env != "" { - return strings.Split(env, ",") - } - return def -} diff --git a/client/mock/client_mock.go b/client/mock/client_mock.go index 0460d63894f4d13d51ee3c26b1e1ee10f412799e..c6a0d12b8bb5f95a9bf98e1c1b5c28a1c53e02af 100644 --- a/client/mock/client_mock.go +++ b/client/mock/client_mock.go @@ -41,9 +41,9 @@ func NewMockNodeClient() *MockNodeClient { func (mock *MockNodeClient) Broadcast(transaction txs.Tx) (*txs.Receipt, error) { // make zero transaction receipt txReceipt := &txs.Receipt{ - TxHash: make([]byte, 20, 20), + TxHash: make([]byte, 20), CreatesContract: 0, - ContractAddr: make([]byte, 20, 20), + ContractAddr: make([]byte, 20), } return txReceipt, nil } @@ -55,7 +55,7 @@ func (mock *MockNodeClient) DeriveWebsocketClient() (nodeWsClient NodeWebsocketC func (mock *MockNodeClient) GetAccount(address []byte) (*acc.Account, error) { // make zero account var zero [32]byte - copyAddressBytes := make([]byte, len(address), len(address)) + copyAddressBytes := make([]byte, len(address)) copy(copyAddressBytes, address) account := &acc.Account{ Address: copyAddressBytes, diff --git a/client/rpc/client_test.go b/client/rpc/client_test.go index a805b99bc8f2040f2cda854554cf132a6adbabb5..603fe793fe2f7e32e9c355f8c5150f797428283c 100644 --- a/client/rpc/client_test.go +++ b/client/rpc/client_test.go @@ -117,7 +117,7 @@ func testName(t *testing.T, // set data dataString := fmt.Sprintf("%X", "We are DOUG.") // set name - nameString := fmt.Sprintf("%s", "DOUG") + nameString := "DOUG" _, err := Name(nodeClient, keyClient, publicKeyString, addressString, amountString, nonceString, feeString, nameString, dataString) diff --git a/client/websocket_client.go b/client/websocket_client.go index e3da5e9f720e01cc881c2986b2b805850a46641f..428f78fd66498efb40cdf380c5f71bf0f0eb1870 100644 --- a/client/websocket_client.go +++ b/client/websocket_client.go @@ -195,7 +195,6 @@ func (burrowNodeWebsocketClient *burrowNodeWebsocketClient) WaitForConfirmation( Exception: nil, Error: fmt.Errorf("timed out waiting for event"), } - return }() return confirmationChannel, nil } diff --git a/cmd/burrow.go b/cmd/burrow.go index bfa3b264a22ecd1d1d2c30e9c57c49c6cd81d658..a29f3e1fee9ace78eedd4f81eeed42f086834d3b 100644 --- a/cmd/burrow.go +++ b/cmd/burrow.go @@ -17,7 +17,6 @@ package commands import ( "os" "strconv" - "strings" "github.com/spf13/cobra" @@ -92,11 +91,3 @@ func setDefaultString(envVar, def string) string { } return def } - -func setDefaultStringSlice(envVar string, def []string) []string { - env := os.Getenv(envVar) - if env != "" { - return strings.Split(env, ",") - } - return def -} diff --git a/event/filters.go b/event/filters.go index ea04e989f45a8c61dd46370bebcaac02a86fc727..0a1c732437835d76bf056bd362a213c930a435a7 100644 --- a/event/filters.go +++ b/event/filters.go @@ -107,7 +107,7 @@ func (this *FilterFactory) RegisterFilterPool(fieldName string, pool *sync.Pool) // only if all the sub-filters matches. func (this *FilterFactory) NewFilter(fdArr []*FilterData) (Filter, error) { - if fdArr == nil || len(fdArr) == 0 { + if len(fdArr) == 0 { return &MatchAllFilter{}, nil } if len(fdArr) == 1 { diff --git a/files/files.go b/files/files.go index a11c8a62f145ba42813c5086713b9241f9212e21..2ab8b5152489d1fc82632b3636a0df56b30a98dc 100644 --- a/files/files.go +++ b/files/files.go @@ -17,7 +17,6 @@ package files import ( "fmt" - "io" "io/ioutil" "os" ) @@ -62,7 +61,6 @@ func WriteFile(fileName string, data []byte, perm os.FileMode) error { return err } if err2 == nil && n < len(data) { - err2 = io.ErrShortWrite return err } diff --git a/files/log.go b/files/log.go deleted file mode 100644 index b07f421feff655f01a8762505ab1d5ff31a09391..0000000000000000000000000000000000000000 --- a/files/log.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 Monax Industries Limited -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package files - -import ( - "github.com/tendermint/log15" -) - -var log = log15.New("module", "server/files") diff --git a/genesis/maker.go b/genesis/maker.go index bfabb4fbc3671a9f0d6f1157dc28339634ad0d4c..48f09c563e0cd49ad786be7e235091d82946e436 100644 --- a/genesis/maker.go +++ b/genesis/maker.go @@ -43,23 +43,19 @@ func NewGenesisValidator(amount int64, name string, unbondToAddress []byte, // convert the key bytes into a typed fixed size byte array var typedPublicKeyBytes []byte switch keyType { - case "ed25519": + case "ed25519": // ed25519 has type byte 0x01 // TODO: [ben] functionality and checks need to be inherit in the type if len(publicKeyBytes) != PublicKeyEd25519ByteLength { return nil, fmt.Errorf("Invalid length provided for ed25519 public key (%v bytes provided but expected %v bytes)", len(publicKeyBytes), PublicKeyEd25519ByteLength) } - // ed25519 has type byte 0x01 - typedPublicKeyBytes = make([]byte, PublicKeyEd25519ByteLength+1) // prepend type byte to public key typedPublicKeyBytes = append([]byte{crypto.TypeEd25519}, publicKeyBytes...) - case "secp256k1": + case "secp256k1": // secp256k1 has type byte 0x02 if len(publicKeyBytes) != PublicKeySecp256k1ByteLength { return nil, fmt.Errorf("Invalid length provided for secp256k1 public key (%v bytes provided but expected %v bytes)", len(publicKeyBytes), PublicKeySecp256k1ByteLength) } - // secp256k1 has type byte 0x02 - typedPublicKeyBytes = make([]byte, PublicKeySecp256k1ByteLength+1) // prepend type byte to public key typedPublicKeyBytes = append([]byte{crypto.TypeSecp256k1}, publicKeyBytes...) default: diff --git a/logging/config/sinks.go b/logging/config/sinks.go index 7eaea511a39371da16ded5a48b3eb624389b83a5..daf88c30d2e897f97b4099d8b2da026231d639ca 100644 --- a/logging/config/sinks.go +++ b/logging/config/sinks.go @@ -15,7 +15,6 @@ import ( // This file contains definitions for a configurable output graph for the // logging system. -type source string type outputType string type transformType string type filterMode string diff --git a/manager/burrow-mint/accounts.go b/manager/burrow-mint/accounts.go index 1443a653e92afc4eb44f30790cfb1bfb530598ab..b0e58c3566d5c09ed40778ef2115c9f874368600 100644 --- a/manager/burrow-mint/accounts.go +++ b/manager/burrow-mint/accounts.go @@ -226,8 +226,3 @@ func (this *AccountBalanceFilter) Match(v interface{}) bool { } return this.match(int64(acc.Balance), this.value) } - -// Function for matching accounts against filter data. -func (this *accounts) matchBlock(block, fda []*event.FilterData) bool { - return false -} diff --git a/manager/burrow-mint/evm/sha3/keccakf.go b/manager/burrow-mint/evm/sha3/keccakf.go index 107156cc9d325766aaa3dccf737fb7201334641d..e12792fdc6525bac4455556dd69ed67ab8bbf48d 100644 --- a/manager/burrow-mint/evm/sha3/keccakf.go +++ b/manager/burrow-mint/evm/sha3/keccakf.go @@ -40,7 +40,7 @@ var rc = [...]uint64{ // ro_xx represent the rotation offsets for use in the χ step. // Defining them as const instead of in an array allows the compiler to insert constant shifts. const ( - ro_00 = 0 + ro_00 = 0 // not used ro_01 = 36 ro_02 = 3 ro_03 = 41 diff --git a/manager/burrow-mint/evm/snative.go b/manager/burrow-mint/evm/snative.go index d256ddf23b151277885db854cef18cbce9c61f21..3f628e99d328e1f44ec04c0ad9ff4b19b8f5adc4 100644 --- a/manager/burrow-mint/evm/snative.go +++ b/manager/burrow-mint/evm/snative.go @@ -464,10 +464,7 @@ func (e ErrInvalidPermission) Error() string { // Checks if a permission flag is valid (a known base chain or snative permission) func ValidPermN(n ptypes.PermFlag) bool { - if n > ptypes.TopPermFlag { - return false - } - return true + return n <= ptypes.TopPermFlag } // Get the global BasePermissions diff --git a/manager/burrow-mint/evm/stack.go b/manager/burrow-mint/evm/stack.go index e383be25d60d3d479623b6e3b92c7ebbcd674d6e..f9d48986b2040aa7592f512f5e53aa7b89ca4a8c 100644 --- a/manager/burrow-mint/evm/stack.go +++ b/manager/burrow-mint/evm/stack.go @@ -106,7 +106,6 @@ func (st *Stack) Swap(n int) { return } st.data[st.ptr-n], st.data[st.ptr-1] = st.data[st.ptr-1], st.data[st.ptr-n] - return } func (st *Stack) Dup(n int) { @@ -116,7 +115,6 @@ func (st *Stack) Dup(n int) { return } st.Push(st.data[st.ptr-n]) - return } // Not an opcode, costs no gas. diff --git a/manager/burrow-mint/evm/vm_test.go b/manager/burrow-mint/evm/vm_test.go index a7e36a7088dc0c8b392b24d2dd4258bba2997770..0dd356827dbb1fa1d732ddf5cdd321af523dc16d 100644 --- a/manager/burrow-mint/evm/vm_test.go +++ b/manager/burrow-mint/evm/vm_test.go @@ -103,11 +103,10 @@ func TestJumpErr(t *testing.T) { var gas int64 = 100000 code := []byte{0x60, 0x10, 0x56} // jump to position 16, a clear failure - var output []byte var err error ch := make(chan struct{}) go func() { - output, err = ourVm.Call(account1, account2, code, []byte{}, 0, &gas) + _, err = ourVm.Call(account1, account2, code, []byte{}, 0, &gas) ch <- struct{}{} }() tick := time.NewTicker(time.Second * 2) diff --git a/manager/burrow-mint/state/block_cache_test.go b/manager/burrow-mint/state/block_cache_test.go index f3bef027d078009651273be87dea38f953163181..03f99b49024c1013670c5e2a4f223ac76205169f 100644 --- a/manager/burrow-mint/state/block_cache_test.go +++ b/manager/burrow-mint/state/block_cache_test.go @@ -21,8 +21,8 @@ func TestBlockCache_Sync_Accounts(t *testing.T) { // to remove them twice from merkle tree defer func() { if r := recover(); r != nil { - t.Fatalf("Consecutive calls to BlockCache.Sync() failed. " + - "Is cache dirty?\n Error: %s", r) + t.Fatalf("Consecutive calls to BlockCache.Sync() failed. "+ + "Is cache dirty?\n Error: %s", r) } }() blockCache.Sync() @@ -46,8 +46,8 @@ func TestBlockCache_Sync_NameReg(t *testing.T) { blockCache.Sync() defer func() { if r := recover(); r != nil { - t.Fatalf("Consecutive calls to BlockCache.Sync() failed. " + - "Is cache dirty?\n Error: %s", r) + t.Fatalf("Consecutive calls to BlockCache.Sync() failed. "+ + "Is cache dirty?\n Error: %s", r) } }() blockCache.Sync() diff --git a/manager/burrow-mint/state/execution.go b/manager/burrow-mint/state/execution.go index 50745e1a35aabc74b0c4a0403f9b6f163673047e..4c765ec7f985fa2b92ce500e0be8d2f8b36c3d79 100644 --- a/manager/burrow-mint/state/execution.go +++ b/manager/burrow-mint/state/execution.go @@ -16,7 +16,6 @@ package state import ( "bytes" - "errors" "fmt" acm "github.com/hyperledger/burrow/account" @@ -627,7 +626,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable // if the entry already exists, and hasn't expired, we must be owner if entry.Expires > lastBlockHeight { // ensure we are owner - if bytes.Compare(entry.Owner, tx.Input.Address) != 0 { + if !bytes.Equal(entry.Owner, tx.Input.Address) { logging.InfoMsg(logger, "Sender is trying to update a name for which they are not an owner", "sender_address", tx.Input.Address, "name", tx.Name) @@ -649,7 +648,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable // and changing the data if expired { if expiresIn < txs.MinNameRegistrationPeriod { - return errors.New(fmt.Sprintf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod)) + return fmt.Errorf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod) } entry.Expires = lastBlockHeight + expiresIn entry.Owner = tx.Input.Address @@ -664,7 +663,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable credit := oldCredit + value expiresIn = int(credit / costPerBlock) if expiresIn < txs.MinNameRegistrationPeriod { - return errors.New(fmt.Sprintf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod)) + return fmt.Errorf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod) } entry.Expires = lastBlockHeight + expiresIn logging.TraceMsg(logger, "Updated NameReg entry", @@ -679,7 +678,7 @@ func ExecTx(blockCache *BlockCache, tx txs.Tx, runCall bool, evc events.Fireable } } else { if expiresIn < txs.MinNameRegistrationPeriod { - return errors.New(fmt.Sprintf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod)) + return fmt.Errorf("Names must be registered for at least %d blocks", txs.MinNameRegistrationPeriod) } // entry does not exist, so create it entry = &core_types.NameRegEntry{ @@ -1001,11 +1000,11 @@ func HasPermission(state AccountGetter, acc *acm.Account, perm ptypes.PermFlag, sanity.PanicSanity("Checking an unknown permission in state should never happen") } - if acc == nil { - // TODO - // this needs to fall back to global or do some other specific things - // eg. a bondAcc may be nil and so can only bond if global bonding is true - } + //if acc == nil { + // TODO + // this needs to fall back to global or do some other specific things + // eg. a bondAcc may be nil and so can only bond if global bonding is true + //} permString := ptypes.PermFlagToString(perm) v, err := acc.Permissions.Base.Get(perm) diff --git a/manager/burrow-mint/state/genesis_test.go b/manager/burrow-mint/state/genesis_test.go index d699bc623150164bd3fb142e94312b4fd20e4ac3..983b5cb58432e1d1603f7dd9c1de77483609b46d 100644 --- a/manager/burrow-mint/state/genesis_test.go +++ b/manager/burrow-mint/state/genesis_test.go @@ -33,7 +33,7 @@ import ( var chain_id = "lone_ranger" var addr1, _ = hex.DecodeString("964B1493BBE3312278B7DEB94C39149F7899A345") -var send1, name1, call1 = 1, 1, 0 +var send1 = 1 var perms, setbit = 66, 70 var accName = "me" var roles1 = []string{"master", "universal-ruler"} @@ -79,7 +79,7 @@ func TestGenesisReadable(t *testing.T) { t.Fatalf("Incorrect chain id. Got %d, expected %d\n", genDoc.ChainID, chain_id) } acc := genDoc.Accounts[0] - if bytes.Compare(acc.Address, addr1) != 0 { + if !bytes.Equal(acc.Address, addr1) { t.Fatalf("Incorrect address for account. Got %X, expected %X\n", acc.Address, addr1) } if acc.Amount != amt1 { diff --git a/manager/burrow-mint/state/permissions_test.go b/manager/burrow-mint/state/permissions_test.go index dd812410f4939715c102e78d4239dd28f72ae978..a02f74069e0048c6e06601c655f44b46f3c83255 100644 --- a/manager/burrow-mint/state/permissions_test.go +++ b/manager/burrow-mint/state/permissions_test.go @@ -515,7 +515,7 @@ func TestCreatePermission(t *testing.T) { if contractAcc == nil { t.Fatalf("failed to create contract %X", contractAddr) } - if bytes.Compare(contractAcc.Code, contractCode) != 0 { + if !bytes.Equal(contractAcc.Code, contractCode) { t.Fatalf("contract does not have correct code. Got %X, expected %X", contractAcc.Code, contractCode) } @@ -540,7 +540,7 @@ func TestCreatePermission(t *testing.T) { if contractAcc == nil { t.Fatalf("failed to create contract %X", contractAddr) } - if bytes.Compare(contractAcc.Code, factoryCode) != 0 { + if !bytes.Equal(contractAcc.Code, factoryCode) { t.Fatalf("contract does not have correct code. Got %X, expected %X", contractAcc.Code, factoryCode) } diff --git a/manager/burrow-mint/state/state_test.go b/manager/burrow-mint/state/state_test.go index 2ecd60ff3f8f1094646f949f783c1a1df4ef9962..f9f91d9b76561772a5f654f35ea71b1da468e766 100644 --- a/manager/burrow-mint/state/state_test.go +++ b/manager/burrow-mint/state/state_test.go @@ -275,7 +275,7 @@ func TestNameTxs(t *testing.T) { if entry == nil { t.Fatalf("Could not find name %s", name) } - if bytes.Compare(entry.Owner, addr) != 0 { + if !bytes.Equal(entry.Owner, addr) { t.Fatalf("Wrong owner. Got %X expected %X", entry.Owner, addr) } if data != entry.Data { diff --git a/manager/burrow-mint/transactor.go b/manager/burrow-mint/transactor.go index 3f73737b1def8ccc376b9ec2d2f438bb4ff7284a..f0cab8b6f41c78f95f477ea6a10ccfc176fd77f1 100644 --- a/manager/burrow-mint/transactor.go +++ b/manager/burrow-mint/transactor.go @@ -391,12 +391,10 @@ func (this *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) ( input.PubKey = privAccounts[i].PubKey input.Signature = privAccounts[i].Sign(this.chainID, sendTx) } - break case *txs.CallTx: callTx := tx.(*txs.CallTx) callTx.Input.PubKey = privAccounts[0].PubKey callTx.Input.Signature = privAccounts[0].Sign(this.chainID, callTx) - break case *txs.BondTx: bondTx := tx.(*txs.BondTx) // the first privaccount corresponds to the BondTx pub key. @@ -406,15 +404,12 @@ func (this *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) ( input.PubKey = privAccounts[i+1].PubKey input.Signature = privAccounts[i+1].Sign(this.chainID, bondTx) } - break case *txs.UnbondTx: unbondTx := tx.(*txs.UnbondTx) unbondTx.Signature = privAccounts[0].Sign(this.chainID, unbondTx).(crypto.SignatureEd25519) - break case *txs.RebondTx: rebondTx := tx.(*txs.RebondTx) rebondTx.Signature = privAccounts[0].Sign(this.chainID, rebondTx).(crypto.SignatureEd25519) - break default: return nil, fmt.Errorf("Object is not a proper transaction: %v\n", tx) } diff --git a/rpc/tendermint/client/client_test.go b/rpc/tendermint/client/client_test.go index 673be6c1c60275cfb595c79079f719f976bb3fbe..13a5c98e48e668d53accfb113e91bf06c1ef72d1 100644 --- a/rpc/tendermint/client/client_test.go +++ b/rpc/tendermint/client/client_test.go @@ -26,6 +26,7 @@ func TestParamsMap(t *testing.T) { } dict, err := paramsMap("Foo", aStruct{5}, "Bar", "Nibbles") + assert.NoError(t, err, "Should not be a paramsMaperror") assert.Equal(t, map[string]interface{}{ "Foo": aStruct{5}, "Bar": "Nibbles", diff --git a/rpc/v0/rest_server.go b/rpc/v0/rest_server.go index 3f76af2042c5ac47bad6da66ed62e58636c711c0..03c70c5afd3af3bc8cd2104844646d5d0e874ad9 100644 --- a/rpc/v0/rest_server.go +++ b/rpc/v0/rest_server.go @@ -500,15 +500,6 @@ func heightParam(c *gin.Context) { c.Next() } -func subIdParam(c *gin.Context) { - subId := c.Param("id") - if len(subId) != 64 || !util.IsHex(subId) { - c.AbortWithError(400, fmt.Errorf("Malformed event id")) - } - c.Set("id", subId) - c.Next() -} - // TODO func peerAddressParam(c *gin.Context) { subId := c.Param("address") diff --git a/rpc/v0/rest_server_pipe_test.go b/rpc/v0/rest_server_pipe_test.go index eea240bacccc369191352837beabe6e7e52f432e..1cd8282288fb26024268a52b694c76856142c71c 100644 --- a/rpc/v0/rest_server_pipe_test.go +++ b/rpc/v0/rest_server_pipe_test.go @@ -286,7 +286,7 @@ func (trans *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { } func (trans *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) { - if address == nil || len(address) == 0 { + if len(address) == 0 { return trans.testData.TransactCreate.Output, nil } return trans.testData.Transact.Output, nil diff --git a/rpc/v0/rest_server_test.go b/rpc/v0/rest_server_test.go index 757993201a2189172be193e72410bd4cfd5ee0e7..fa4b27dc0e5cb25afeae2ce1018fe2901535c580 100644 --- a/rpc/v0/rest_server_test.go +++ b/rpc/v0/rest_server_test.go @@ -52,7 +52,6 @@ func init() { type MockSuite struct { suite.Suite - baseDir string serveProcess *server.ServeProcess codec rpc.Codec sUrl string diff --git a/server/websocket.go b/server/websocket.go index 265ac3a47451cb096f854cfcc33373ff70bb3155..b7c8a111cfbeb07a269cdde76df8f6f6b67e2989 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -358,9 +358,8 @@ func (sessionManager *SessionManager) RemoveSessionOpenEventChannel(lChan chan * if len(ec) == 0 { return false } - for i, c := range ec { + for _, c := range ec { if lChan == c { - ec[i], ec = ec[len(ec)-1], ec[:len(ec)-1] return true } } @@ -380,9 +379,8 @@ func (sessionManager *SessionManager) RemoveSessionCloseEventChannel(lChan chan if len(ec) == 0 { return false } - for i, c := range ec { + for _, c := range ec { if lChan == c { - ec[i], ec = ec[len(ec)-1], ec[:len(ec)-1] return true } } diff --git a/test/filters/filter_test.go b/test/filters/filter_test.go index e3cf1052c20d0e0d01e8281a935bf6abac2ab350..35601f4696a5f5df43b50376c49491699c415176 100644 --- a/test/filters/filter_test.go +++ b/test/filters/filter_test.go @@ -96,7 +96,7 @@ type FilterSuite struct { } func (this *FilterSuite) SetupSuite() { - objects := make([]FilterableObject, OBJECTS, OBJECTS) + objects := make([]FilterableObject, OBJECTS) for i := 0; i < 100; i++ { objects[i] = FilterableObject{i, fmt.Sprintf("string%d", i)} diff --git a/test/fixtures/file_fixtures.go b/test/fixtures/file_fixtures.go index d6926c0972911d33b3f4d3272645388e36bec8bd..d751f55fd72af565f9488dab26d2b273d5a408cd 100644 --- a/test/fixtures/file_fixtures.go +++ b/test/fixtures/file_fixtures.go @@ -84,6 +84,9 @@ func (ffs *FileFixtures) RemoveAll() { func createWriteClose(filename, content string) error { // We'll create any parent dirs, with permissive permissions err := os.MkdirAll(path.Dir(filename), 0777) + if err != nil { + return err + } f, err := os.Create(filename) if err != nil { return err diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go index 820e173ab15842380365707b21a228828eb4b155..1721fa9a22ffad3b54b4bc0fdef8935df9448bdd 100644 --- a/test/server/ws_burst_test.go +++ b/test/server/ws_burst_test.go @@ -94,7 +94,7 @@ func runWs() error { runners := uint16(0) for runners < CONNS { select { - case _ = <-doneChan: + case <-doneChan: runners++ case err := <-errChan: return err diff --git a/txs/tx.go b/txs/tx.go index d7b1c50a84832f9b57a3a93f286088df18c260bf..44cd1b1056dadd93225cad00f904d110039d684e 100644 --- a/txs/tx.go +++ b/txs/tx.go @@ -360,9 +360,9 @@ type DupeoutTx struct { } func (tx *DupeoutTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { - //PanicSanity("DupeoutTx has no sign bytes") + // PanicSanity("DupeoutTx has no sign bytes") // TODO - return + // return } func (tx *DupeoutTx) String() string { diff --git a/txs/tx_test.go b/txs/tx_test.go index 1ccef655be3c784226f0e0259073c964fd272f55..ca4b2ff0048278efdb71b55170bbd385d6e3af2e 100644 --- a/txs/tx_test.go +++ b/txs/tx_test.go @@ -212,6 +212,7 @@ func TestEncodeTxDecodeTx(t *testing.T) { t.Fatal(err) } txOut, err := DecodeTx(txBytes) + assert.NoError(t, err, "DecodeTx error") assert.Equal(t, tx, txOut) }