Merge branch 'develop' into bucky/gaiadebug-bech32
This commit is contained in:
commit
6037243250
|
@ -62,7 +62,6 @@ jobs:
|
|||
command: |
|
||||
export PATH="$GOBIN:$PATH"
|
||||
make get_tools
|
||||
go get -u github.com/client9/misspell/cmd/misspell
|
||||
- run:
|
||||
name: Lint source
|
||||
command: |
|
||||
|
|
|
@ -10,3 +10,4 @@ v If a checkbox is n/a - please still include it but + a little note why
|
|||
* [ ] Updated CHANGELOG.md
|
||||
* [ ] Updated Gaia/Examples
|
||||
* [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr))
|
||||
* [ ] Added appropriate labels to PR (ex. wip, ready-for-review, docs)
|
||||
|
|
|
@ -38,6 +38,8 @@ FEATURES
|
|||
* misspell
|
||||
* gofmt
|
||||
* go vet -composites=false
|
||||
* unconvert
|
||||
* ineffassign
|
||||
* [server] Default config now creates a profiler at port 6060, and increase p2p send/recv rates
|
||||
* [tests] Add WaitForNextNBlocksTM helper method
|
||||
* [types] Switches internal representation of Int/Uint/Rat to use pointers
|
||||
|
|
2
Makefile
2
Makefile
|
@ -108,7 +108,7 @@ test_cover:
|
|||
@bash tests/test_cover.sh
|
||||
|
||||
test_lint:
|
||||
gometalinter.v2 --disable-all --enable='golint' --enable='misspell' --linter='vet:go vet -composites=false:PATH:LINE:MESSAGE' --enable='vet' --vendor ./...
|
||||
gometalinter.v2 --disable-all --enable='golint' --enable='misspell' --enable='unconvert' --enable='ineffassign' --linter='vet:go vet -composites=false:PATH:LINE:MESSAGE' --enable='vet' --deadline=500s --vendor ./...
|
||||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
|
||||
|
||||
benchmark:
|
||||
|
|
|
@ -127,8 +127,8 @@ func (ctx CoreContext) SignAndBuild(name, passphrase string, msgs []sdk.Msg, cdc
|
|||
|
||||
signMsg := auth.StdSignMsg{
|
||||
ChainID: chainID,
|
||||
AccountNumber: int64(accnum),
|
||||
Sequence: int64(sequence),
|
||||
AccountNumber: accnum,
|
||||
Sequence: sequence,
|
||||
Msgs: msgs,
|
||||
Memo: memo,
|
||||
Fee: auth.NewStdFee(ctx.Gas, sdk.Coin{}), // TODO run simulate to estimate gas?
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestKeys(t *testing.T) {
|
|||
var jsonStr = []byte(fmt.Sprintf(`{"name":"test_fail", "password":"%s"}`, password))
|
||||
res, body = Request(t, port, "POST", "/keys", jsonStr)
|
||||
|
||||
assert.Equal(t, http.StatusBadRequest, res.StatusCode, "Account creation should require a seed")
|
||||
assert.Equal(t, http.StatusBadRequest, res.StatusCode, "Account creation should require a seed "+body)
|
||||
|
||||
jsonStr = []byte(fmt.Sprintf(`{"name":"%s", "password":"%s", "seed": "%s"}`, newName, newPassword, newSeed))
|
||||
res, body = Request(t, port, "POST", "/keys", jsonStr)
|
||||
|
@ -212,7 +212,7 @@ func TestValidators(t *testing.T) {
|
|||
// --
|
||||
|
||||
res, body = Request(t, port, "GET", "/validatorsets/1000000000", nil)
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode, body)
|
||||
}
|
||||
|
||||
func TestCoinSend(t *testing.T) {
|
||||
|
@ -520,43 +520,43 @@ func TestVote(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProposalsQuery(t *testing.T) {
|
||||
name, password := "test", "1234567890"
|
||||
name2, password := "test2", "1234567890"
|
||||
addr, seed := CreateAddr(t, "test", password, GetKB(t))
|
||||
addr2, seed2 := CreateAddr(t, "test2", password, GetKB(t))
|
||||
name, password1 := "test", "1234567890"
|
||||
name2, password2 := "test2", "1234567890"
|
||||
addr, seed := CreateAddr(t, "test", password1, GetKB(t))
|
||||
addr2, seed2 := CreateAddr(t, "test2", password2, GetKB(t))
|
||||
cleanup, _, port := InitializeTestLCD(t, 1, []sdk.Address{addr, addr2})
|
||||
defer cleanup()
|
||||
|
||||
// Addr1 proposes (and deposits) proposals #1 and #2
|
||||
resultTx := doSubmitProposal(t, port, seed, name, password, addr)
|
||||
resultTx := doSubmitProposal(t, port, seed, name, password1, addr)
|
||||
var proposalID1 int64
|
||||
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID1)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
resultTx = doSubmitProposal(t, port, seed, name, password, addr)
|
||||
resultTx = doSubmitProposal(t, port, seed, name, password1, addr)
|
||||
var proposalID2 int64
|
||||
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID2)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Addr2 proposes (and deposits) proposals #3
|
||||
resultTx = doSubmitProposal(t, port, seed2, name2, password, addr2)
|
||||
resultTx = doSubmitProposal(t, port, seed2, name2, password2, addr2)
|
||||
var proposalID3 int64
|
||||
cdc.UnmarshalBinaryBare(resultTx.DeliverTx.GetData(), &proposalID3)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Addr2 deposits on proposals #2 & #3
|
||||
resultTx = doDeposit(t, port, seed2, name2, password, addr2, proposalID2)
|
||||
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID2)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
resultTx = doDeposit(t, port, seed2, name2, password, addr2, proposalID3)
|
||||
resultTx = doDeposit(t, port, seed2, name2, password2, addr2, proposalID3)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Addr1 votes on proposals #2 & #3
|
||||
resultTx = doVote(t, port, seed, name, password, addr, proposalID2)
|
||||
resultTx = doVote(t, port, seed, name, password1, addr, proposalID2)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
resultTx = doVote(t, port, seed, name, password, addr, proposalID3)
|
||||
resultTx = doVote(t, port, seed, name, password1, addr, proposalID3)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Addr2 votes on proposal #3
|
||||
resultTx = doVote(t, port, seed2, name2, password, addr2, proposalID3)
|
||||
resultTx = doVote(t, port, seed2, name2, password2, addr2, proposalID3)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Test query all proposals
|
||||
|
|
|
@ -24,6 +24,6 @@ func NodeVersionRequestHandler(cdc *wire.Codec, ctx context.CoreContext) http.Ha
|
|||
w.Write([]byte(fmt.Sprintf("Could't query version. Error: %s", err.Error())))
|
||||
return
|
||||
}
|
||||
w.Write([]byte(version))
|
||||
w.Write(version)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ func TestGenesis(t *testing.T) {
|
|||
},
|
||||
}
|
||||
stateBytes, err := json.MarshalIndent(genesisState, "", "\t")
|
||||
require.Nil(t, err)
|
||||
|
||||
vals := []abci.Validator{}
|
||||
bapp.InitChain(abci.RequestInitChain{Validators: vals, AppStateBytes: stateBytes})
|
||||
|
|
|
@ -34,6 +34,9 @@ func CoolAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState jso
|
|||
"trend": "ice-cold"
|
||||
}`)
|
||||
appState, err = server.AppendJSON(cdc, appState, key, value)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
key = "pow"
|
||||
value = json.RawMessage(`{
|
||||
"difficulty": 1,
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
|
@ -79,6 +80,7 @@ func TestBonding(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
|
||||
power, err := stakeKeeper.bondWithoutCoins(ctx, addr, pubKey, sdk.NewCoin("steak", 10))
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, int64(20), power)
|
||||
|
||||
pk, _, err := stakeKeeper.unbondWithoutCoins(ctx, addr)
|
||||
|
|
|
@ -155,7 +155,7 @@ func TestIAVLSubspaceIterator(t *testing.T) {
|
|||
iavlStore.Set([]byte{byte(255), byte(255), byte(1)}, []byte("test4"))
|
||||
iavlStore.Set([]byte{byte(255), byte(255), byte(255)}, []byte("test4"))
|
||||
|
||||
i := 0
|
||||
var i int
|
||||
|
||||
iter := sdk.KVStorePrefixIterator(iavlStore, []byte("test"))
|
||||
expected := []string{"test1", "test2", "test3"}
|
||||
|
@ -214,7 +214,7 @@ func TestIAVLReverseSubspaceIterator(t *testing.T) {
|
|||
iavlStore.Set([]byte{byte(255), byte(255), byte(1)}, []byte("test4"))
|
||||
iavlStore.Set([]byte{byte(255), byte(255), byte(255)}, []byte("test4"))
|
||||
|
||||
i := 0
|
||||
var i int
|
||||
|
||||
iter := sdk.KVStoreReversePrefixIterator(iavlStore, []byte("test"))
|
||||
expected := []string{"test3", "test2", "test1"}
|
||||
|
|
|
@ -104,7 +104,7 @@ func waitForHeight(height int64, url string) {
|
|||
res.Body.Close()
|
||||
|
||||
var resultBlock ctypes.ResultBlock
|
||||
err = cdc.UnmarshalJSON([]byte(body), &resultBlock)
|
||||
err = cdc.UnmarshalJSON(body, &resultBlock)
|
||||
if err != nil {
|
||||
fmt.Println("RES", res)
|
||||
fmt.Println("BODY", string(body))
|
||||
|
|
|
@ -7,9 +7,16 @@ all: get_tools
|
|||
DEP = github.com/golang/dep/cmd/dep
|
||||
GOLINT = github.com/tendermint/lint/golint
|
||||
GOMETALINTER = gopkg.in/alecthomas/gometalinter.v2
|
||||
UNCONVERT = github.com/mdempsky/unconvert
|
||||
INEFFASSIGN = github.com/gordonklaus/ineffassign
|
||||
MISSPELL = github.com/client9/misspell/cmd/misspell
|
||||
|
||||
DEP_CHECK := $(shell command -v dep 2> /dev/null)
|
||||
GOLINT_CHECK := $(shell command -v golint 2> /dev/null)
|
||||
GOMETALINTER_CHECK := $(shell command -v gometalinter.v2 2> /dev/null)
|
||||
UNCONVERT_CHECK := $(shell command -v unconvert 2> /dev/null)
|
||||
INEFFASSIGN_CHECK := $(shell command -v ineffassign 2> /dev/null)
|
||||
MISSPELL_CHECK := $(shell command -v misspell 2> /dev/null)
|
||||
|
||||
check_tools:
|
||||
ifndef DEP_CHECK
|
||||
|
@ -27,6 +34,21 @@ ifndef GOMETALINTER_CHECK
|
|||
else
|
||||
@echo "Found gometalinter in path."
|
||||
endif
|
||||
ifndef UNCONVERT_CHECK
|
||||
@echo "No unconvert in path. Install with 'make get_tools'."
|
||||
else
|
||||
@echo "Found unconvert in path."
|
||||
endif
|
||||
ifndef INEFFASSIGN_CHECK
|
||||
@echo "No ineffassign in path. Install with 'make get_tools'."
|
||||
else
|
||||
@echo "Found ineffassign in path."
|
||||
endif
|
||||
ifndef MISSPELL_CHECK
|
||||
@echo "No misspell in path. Install with 'make get_tools'."
|
||||
else
|
||||
@echo "Found misspell in path."
|
||||
endif
|
||||
|
||||
get_tools:
|
||||
ifdef DEP_CHECK
|
||||
|
@ -47,6 +69,24 @@ else
|
|||
@echo "Installing gometalinter.v2"
|
||||
go get -v $(GOMETALINTER)
|
||||
endif
|
||||
ifdef UNCONVERT_CHECK
|
||||
@echo "Unconvert is already installed. Run 'make update_tools' to update."
|
||||
else
|
||||
@echo "Installing unconvert"
|
||||
go get -v $(UNCONVERT)
|
||||
endif
|
||||
ifdef INEFFASSIGN_CHECK
|
||||
@echo "Ineffassign is already installed. Run 'make update_tools' to update."
|
||||
else
|
||||
@echo "Installing ineffassign"
|
||||
go get -v $(INEFFASSIGN)
|
||||
endif
|
||||
ifdef MISSPELL_CHECK
|
||||
@echo "misspell is already installed. Run 'make update_tools' to update."
|
||||
else
|
||||
@echo "Installing misspell"
|
||||
go get -v $(MISSPELL)
|
||||
endif
|
||||
|
||||
update_tools:
|
||||
@echo "Updating dep"
|
||||
|
@ -55,6 +95,12 @@ update_tools:
|
|||
go get -u -v $(GOLINT)
|
||||
@echo "Updating gometalinter.v2"
|
||||
go get -u -v $(GOMETALINTER)
|
||||
@echo "Updating unconvert"
|
||||
go get -u -v $(UNCONVERT)
|
||||
@echo "Updating ineffassign"
|
||||
go get -u -v $(INEFFASSIGN)
|
||||
@echo "Updating misspell"
|
||||
go get -u -v $(MISSPELL)
|
||||
|
||||
# To avoid unintended conflicts with file names, always add to .PHONY
|
||||
# unless there is a reason not to.
|
||||
|
|
|
@ -244,11 +244,11 @@ func (coins Coins) AmountOf(denom string) Int {
|
|||
midIdx := len(coins) / 2 // 2:1, 3:1, 4:2
|
||||
coin := coins[midIdx]
|
||||
if denom < coin.Denom {
|
||||
return Coins(coins[:midIdx]).AmountOf(denom)
|
||||
return coins[:midIdx].AmountOf(denom)
|
||||
} else if denom == coin.Denom {
|
||||
return coin.Amount
|
||||
} else {
|
||||
return Coins(coins[midIdx+1:]).AmountOf(denom)
|
||||
return coins[midIdx+1:].AmountOf(denom)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func (ibcm Mapper) PostIBCPacket(ctx sdk.Context, packet IBCPacket) sdk.Error {
|
|||
}
|
||||
|
||||
store.Set(EgressKey(packet.DestChain, index), bz)
|
||||
bz, err = ibcm.cdc.MarshalBinary(int64(index + 1))
|
||||
bz, err = ibcm.cdc.MarshalBinary(index + 1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) (tags
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
switch string(evidence.Type) {
|
||||
switch evidence.Type {
|
||||
case tmtypes.ABCIEvidenceTypeDuplicateVote:
|
||||
sk.handleDoubleSign(ctx, evidence.Height, evidence.Time, pk)
|
||||
default:
|
||||
ctx.Logger().With("module", "x/slashing").Error(fmt.Sprintf("ignored unknown evidence type: %s", string(evidence.Type)))
|
||||
ctx.Logger().With("module", "x/slashing").Error(fmt.Sprintf("ignored unknown evidence type: %s", evidence.Type))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,6 +117,9 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command {
|
|||
}
|
||||
|
||||
delegatorAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressDelegator))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
validatorAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressValidator))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -259,7 +262,13 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command {
|
|||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
delegatorAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressDelegator))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
validatorSrcAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressValidatorSrc))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
validatorDstAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressValidatorDst))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -351,6 +360,9 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command {
|
|||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
delegatorAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressDelegator))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
validatorAddr, err := sdk.GetAccAddressBech32(viper.GetString(FlagAddressValidator))
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -321,6 +321,9 @@ func (k Keeper) BeginRedelegation(ctx sdk.Context, delegatorAddr, validatorSrcAd
|
|||
return types.ErrBadRedelegationDst(k.Codespace())
|
||||
}
|
||||
sharesCreated, err := k.Delegate(ctx, delegatorAddr, returnCoin, dstValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create the unbonding delegation
|
||||
minTime := ctx.BlockHeader().Time + params.UnbondingTime
|
||||
|
|
|
@ -212,7 +212,7 @@ func TestLargeBond(t *testing.T) {
|
|||
keeper.SetParams(ctx, params)
|
||||
|
||||
// validator[9] will be bonded, bringing us from 25% to ~50% (bonding 400,000,000 tokens)
|
||||
pool, validator, _, _ = types.OpBondOrUnbond(r, pool, validator)
|
||||
pool, _, _, _ = types.OpBondOrUnbond(r, pool, validator)
|
||||
keeper.SetPool(ctx, pool)
|
||||
|
||||
// process provisions after the bonding, to compare the difference in expProvisions and expInflation
|
||||
|
|
|
@ -34,6 +34,7 @@ func TestSetValidator(t *testing.T) {
|
|||
// Check each store for being saved
|
||||
resVal, found := keeper.GetValidator(ctx, addrVals[0])
|
||||
assert.True(ValEq(t, validator, resVal))
|
||||
assert.True(t, found)
|
||||
|
||||
resVals := keeper.GetValidatorsBonded(ctx)
|
||||
require.Equal(t, 1, len(resVals))
|
||||
|
@ -87,6 +88,7 @@ func TestUpdateValidatorByPowerIndex(t *testing.T) {
|
|||
|
||||
pool = keeper.GetPool(ctx)
|
||||
validator, found = keeper.GetValidator(ctx, addrVals[0])
|
||||
assert.True(t, found)
|
||||
power = GetValidatorsByPowerIndexKey(validator, pool)
|
||||
assert.True(t, keeper.validatorByPowerIndexExists(ctx, power))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue