Merge branch 'develop' into rigel/server-fix

This commit is contained in:
Christopher Goes 2018-07-26 21:05:10 +02:00 committed by GitHub
commit 3c18467136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 284 additions and 256 deletions

32
Gopkg.lock generated
View File

@ -103,7 +103,7 @@
version = "v1.7.0"
[[projects]]
digest = "1:af1306bff89268721ea2550d504413c9487ebfca11e2ff8f39ae79b99a720ff5"
digest = "1:212285efb97b9ec2e20550d81f0446cb7897e57cbdfd7301b1363ab113d8be45"
name = "github.com/gogo/protobuf"
packages = [
"gogoproto",
@ -114,8 +114,8 @@
"types",
]
pruneopts = "UT"
revision = "1adfc126b41513cc696b209667c8656ea7aac67c"
version = "v1.0.0"
revision = "636bf0302bc95575d69441b25a2603156ffdddf1"
version = "v1.1.1"
[[projects]]
digest = "1:cb22af0ed7c72d495d8be1106233ee553898950f15fd3f5404406d44c2e86888"
@ -424,7 +424,7 @@
version = "v0.9.2"
[[projects]]
digest = "1:5f41a7655812fa5901c71735dc8845f33184e94a2020c770f60a1a80ed228cb3"
digest = "1:049c779b867a182cea567c65d7c81e3b9e4e4a7eece4c35a19639f75d2aa7da9"
name = "github.com/tendermint/tendermint"
packages = [
"abci/client",
@ -438,8 +438,13 @@
"consensus",
"consensus/types",
"crypto",
"crypto/armor",
"crypto/ed25519",
"crypto/encoding/amino",
"crypto/merkle",
"crypto/secp256k1",
"crypto/tmhash",
"crypto/xsalsa20symmetric",
"evidence",
"libs/autofile",
"libs/bech32",
@ -482,8 +487,8 @@
"version",
]
pruneopts = "UT"
revision = "c64a3c74c870d725ba1356f75b4afadf0928c297"
version = "v0.22.4"
revision = "5fdbcd70df57b71ffba71e1ff5f00d617852a9c0"
version = "v0.22.6"
[[projects]]
digest = "1:5bd938386bd1f61a581bf8cd6ff2b7b2f79c542929176db4ceb44965440dae07"
@ -568,7 +573,7 @@
revision = "02b4e95473316948020af0b7a4f0f22c73929b0e"
[[projects]]
digest = "1:4d7b5d9746840266938cdb21a40f8eba7137d9153c4ed404d6bb2a450d06f690"
digest = "1:4515e3030c440845b046354fd5d57671238428b820deebce2e9dabb5cd3c51ac"
name = "google.golang.org/grpc"
packages = [
".",
@ -580,9 +585,11 @@
"credentials",
"encoding",
"encoding/proto",
"grpclb/grpc_lb_v1/messages",
"grpclog",
"internal",
"internal/backoff",
"internal/channelz",
"internal/grpcrand",
"keepalive",
"metadata",
"naming",
@ -596,8 +603,8 @@
"transport",
]
pruneopts = "UT"
revision = "d11072e7ca9811b1100b80ca0269ac831f06d024"
version = "v1.11.3"
revision = "168a6198bcb0ef175f7dacec0b8691fc141dc9b8"
version = "v1.13.0"
[[projects]]
digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202"
@ -630,8 +637,13 @@
"github.com/tendermint/tendermint/cmd/tendermint/commands",
"github.com/tendermint/tendermint/config",
"github.com/tendermint/tendermint/crypto",
"github.com/tendermint/tendermint/crypto/armor",
"github.com/tendermint/tendermint/crypto/ed25519",
"github.com/tendermint/tendermint/crypto/encoding/amino",
"github.com/tendermint/tendermint/crypto/merkle",
"github.com/tendermint/tendermint/crypto/secp256k1",
"github.com/tendermint/tendermint/crypto/tmhash",
"github.com/tendermint/tendermint/crypto/xsalsa20symmetric",
"github.com/tendermint/tendermint/libs/bech32",
"github.com/tendermint/tendermint/libs/cli",
"github.com/tendermint/tendermint/libs/cli/flags",

View File

@ -57,7 +57,7 @@
[[override]]
name = "github.com/tendermint/tendermint"
version = "=0.22.4"
version = "=v0.22.6"
[[constraint]]
name = "github.com/bartekn/go-bip39"

View File

@ -1,6 +1,5 @@
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
PACKAGES_NOCLITEST=$(shell go list ./... | grep -v '/vendor/' | grep -v '/simulation' | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test)
PACKAGES_SIMTEST=$(shell go list ./... | grep -v '/vendor/' | grep '/simulation')
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
COMMIT_HASH := $(shell git rev-parse --short HEAD)
BUILD_TAGS = netgo ledger
BUILD_FLAGS = -tags "${BUILD_TAGS}" -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"
@ -123,13 +122,13 @@ godocs:
test: test_unit
test_cli:
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test`
@go test -count 1 -p 1 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test` -tags=cli_test
test_unit:
@go test $(PACKAGES_NOCLITEST)
@go test $(PACKAGES_NOSIMULATION)
test_race:
@go test -race $(PACKAGES_NOCLITEST)
@go test -race $(PACKAGES_NOSIMULATION)
test_sim:
@echo "Running individual module simulations."
@ -156,7 +155,7 @@ format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs misspell -w
benchmark:
@go test -bench=. $(PACKAGES_NOCLITEST)
@go test -bench=. $(PACKAGES_NOSIMULATION)
########################################

View File

@ -1,6 +1,7 @@
## PENDING
BREAKING CHANGES
* Update to tendermint v0.22.5. This involves changing all of the cryptography imports. [Ref](https://github.com/tendermint/tendermint/pull/1966)
* [baseapp] Msgs are no longer run on CheckTx, removed `ctx.IsCheckTx()`
* [x/gov] CLI flag changed from `proposalID` to `proposal-id`
* [x/stake] Fixed the period check for the inflation calculation
@ -45,6 +46,7 @@ IMPROVEMENTS
* [x/gov] Votes on a proposal can now be queried
* [x/bank] Unit tests are now table-driven
* [tests] Fixes ansible scripts to work with AWS too
* [tests] \#1806 CLI tests are now behind the build flag 'cli_test', so go test works on a new repo
BUG FIXES
* \#1666 Add intra-tx counter to the genesis validators
@ -52,3 +54,4 @@ BUG FIXES
* \#1787 Fixed bug where Tally fails due to revoked/unbonding validator
* \#1766 Fixes bad example for keybase identity
* \#1804 Fixes gen-tx genesis generation logic temporarily until upstream updates
* \#1799 Fix `gaiad export`

View File

@ -190,7 +190,8 @@ func (app *BaseApp) initFromStore(mainKey sdk.StoreKey) error {
if main == nil {
return errors.New("baseapp expects MultiStore with 'main' KVStore")
}
// Needed for `gaiad export`, which inits from store but never calls initchain
app.setCheckState(abci.Header{})
return nil
}

View File

@ -19,6 +19,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
tmcfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/cli"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -119,7 +120,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress
for i := 1; i < nValidators; i++ {
genDoc.Validators = append(genDoc.Validators,
tmtypes.GenesisValidator{
PubKey: crypto.GenPrivKeyEd25519().PubKey(),
PubKey: ed25519.GenPrivKey().PubKey(),
Power: 1,
Name: "val",
},

View File

@ -1,9 +1,15 @@
package app
import (
"os"
"testing"
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/stake"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
abci "github.com/tendermint/tendermint/abci/types"
)
@ -31,3 +37,14 @@ func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error {
return nil
}
func TestGaiadExport(t *testing.T) {
db := db.NewMemDB()
gapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil)
setGenesis(gapp)
// Making a new app object with the db, so that initchain hasn't been called
newGapp := NewGaiaApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil)
_, _, err := newGapp.ExportAppStateAndValidators()
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}

View File

@ -6,11 +6,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
func TestToAccount(t *testing.T) {
priv := crypto.GenPrivKeyEd25519()
priv := ed25519.GenPrivKey()
addr := sdk.AccAddress(priv.PubKey().Address())
authAcc := auth.NewBaseAccountWithAddress(addr)
genAcc := NewGenesisAccount(&authAcc)

View File

@ -1,3 +1,5 @@
// +build cli_test
package clitest
import (

3
cmd/gaia/cli_test/doc.go Normal file
View File

@ -0,0 +1,3 @@
package clitest
// package clitest runs integration tests which make use of CLI commands.

View File

@ -12,7 +12,8 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -95,9 +96,9 @@ func runHackCmd(cmd *cobra.Command, args []string) error {
}
}
func base64ToPub(b64 string) crypto.PubKeyEd25519 {
func base64ToPub(b64 string) ed25519.PubKeyEd25519 {
data, _ := base64.StdEncoding.DecodeString(b64)
var pubKey crypto.PubKeyEd25519
var pubKey ed25519.PubKeyEd25519
copy(pubKey[:], data)
return pubKey

View File

@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
func init() {
@ -116,11 +117,11 @@ func runPubKeyCmd(cmd *cobra.Command, args []string) error {
}
}
var pubKey crypto.PubKeyEd25519
var pubKey ed25519.PubKeyEd25519
if pubKeyI == nil {
copy(pubKey[:], pubkeyBytes)
} else {
pubKey = pubKeyI.(crypto.PubKeyEd25519)
pubKey = pubKeyI.(ed25519.PubKeyEd25519)
pubkeyBytes = pubKey[:]
}

View File

@ -2,14 +2,14 @@ package crypto
import (
"github.com/tendermint/go-amino"
tcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
RegisterAmino(cdc)
tcrypto.RegisterAmino(cdc)
cryptoAmino.RegisterAmino(cdc)
}
// RegisterAmino registers all go-crypto related types in the given (amino) codec.

View File

@ -1,11 +1,14 @@
package crypto
import (
"github.com/stretchr/testify/require"
"os"
"testing"
"github.com/stretchr/testify/require"
tcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1"
)
type byter interface {
@ -62,12 +65,12 @@ func TestKeyEncodings(t *testing.T) {
privSize, pubSize int // binary sizes with the amino overhead
}{
{
privKey: tcrypto.GenPrivKeyEd25519(),
privKey: ed25519.GenPrivKey(),
privSize: 69,
pubSize: 37,
},
{
privKey: tcrypto.GenPrivKeySecp256k1(),
privKey: secp256k1.GenPrivKey(),
privSize: 37,
pubSize: 38,
},

View File

@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/secp256k1"
)
type addrData struct {
@ -57,7 +58,7 @@ func TestFundraiserCompatibility(t *testing.T) {
master, ch := ComputeMastersFromSeed(seed)
priv, err := DerivePrivateKeyForPath(master, ch, "44'/118'/0'/0/0")
require.NoError(t, err)
pub := crypto.PrivKeySecp256k1(priv).PubKey()
pub := secp256k1.PrivKeySecp256k1(priv).PubKey()
t.Log("\tNODEJS GOLANG\n")
t.Logf("SEED \t%X %X\n", seedB, seed)
@ -70,7 +71,7 @@ func TestFundraiserCompatibility(t *testing.T) {
require.Equal(t, priv[:], privB, "Expected priv keys to match")
var pubBFixed [33]byte
copy(pubBFixed[:], pubB)
require.Equal(t, pub, crypto.PubKeySecp256k1(pubBFixed), fmt.Sprintf("Expected pub keys to match for %d", i))
require.Equal(t, pub, secp256k1.PubKeySecp256k1(pubBFixed), fmt.Sprintf("Expected pub keys to match for %d", i))
addr := pub.Address()
t.Logf("ADDR \t%X %X\n", addrB, addr)

View File

@ -22,7 +22,7 @@ import (
"strings"
"github.com/btcsuite/btcd/btcec"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/secp256k1"
)
// BIP44Prefix is the parts of the BIP32 HD path that are fixed by what we used during the fundraiser.
@ -128,9 +128,9 @@ func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, h
data = append([]byte{byte(0)}, privKeyBytes[:]...)
} else {
// this can't return an error:
pubkey := crypto.PrivKeySecp256k1(privKeyBytes).PubKey()
pubkey := secp256k1.PrivKeySecp256k1(privKeyBytes).PubKey()
public := pubkey.(crypto.PubKeySecp256k1)
public := pubkey.(secp256k1.PubKeySecp256k1)
data = public[:]
}
data = append(data, uint32ToBytes(index)...)

View File

@ -11,6 +11,8 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/hd"
"github.com/pkg/errors"
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/secp256k1"
dbm "github.com/tendermint/tendermint/libs/db"
)
@ -163,9 +165,9 @@ func (kb *dbKeybase) persistDerivedKey(seed []byte, passwd, name, fullHdPath str
// if we have a password, use it to encrypt the private key and store it
// else store the public key only
if passwd != "" {
info = kb.writeLocalKey(tmcrypto.PrivKeySecp256k1(derivedPriv), name, passwd)
info = kb.writeLocalKey(secp256k1.PrivKeySecp256k1(derivedPriv), name, passwd)
} else {
pubk := tmcrypto.PrivKeySecp256k1(derivedPriv).PubKey()
pubk := secp256k1.PrivKeySecp256k1(derivedPriv).PubKey()
info = kb.writeOfflineKey(pubk, name)
}
return
@ -314,7 +316,7 @@ func (kb dbKeybase) ImportPubKey(name string, armor string) (err error) {
if err != nil {
return
}
pubKey, err := tmcrypto.PubKeyFromBytes(pubBytes)
pubKey, err := cryptoAmino.PubKeyFromBytes(pubBytes)
if err != nil {
return
}

View File

@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
)
@ -69,7 +70,7 @@ func TestKeyManagement(t *testing.T) {
// create an offline key
o1 := "offline"
priv1 := crypto.GenPrivKeyEd25519()
priv1 := ed25519.GenPrivKey()
pub1 := priv1.PubKey()
i, err = cstore.CreateOffline(o1, pub1)
require.Nil(t, err)

View File

@ -8,6 +8,9 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/bcrypt"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/armor"
"github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/crypto/xsalsa20symmetric"
)
const (
@ -44,7 +47,7 @@ func armorBytes(bz []byte, blockType string) string {
"type": "Info",
"version": "0.0.0",
}
return crypto.EncodeArmor(blockType, header, bz)
return armor.EncodeArmor(blockType, header, bz)
}
func unarmorInfoBytes(armorStr string) (bz []byte, err error) {
@ -56,7 +59,7 @@ func unarmorPubKeyBytes(armorStr string) (bz []byte, err error) {
}
func unarmorBytes(armorStr, blockType string) (bz []byte, err error) {
bType, header, bz, err := crypto.DecodeArmor(armorStr)
bType, header, bz, err := armor.DecodeArmor(armorStr)
if err != nil {
return
}
@ -77,13 +80,13 @@ func encryptArmorPrivKey(privKey crypto.PrivKey, passphrase string) string {
"kdf": "bcrypt",
"salt": fmt.Sprintf("%X", saltBytes),
}
armorStr := crypto.EncodeArmor(blockTypePrivKey, header, encBytes)
armorStr := armor.EncodeArmor(blockTypePrivKey, header, encBytes)
return armorStr
}
func unarmorDecryptPrivKey(armorStr string, passphrase string) (crypto.PrivKey, error) {
var privKey crypto.PrivKey
blockType, header, encBytes, err := crypto.DecodeArmor(armorStr)
blockType, header, encBytes, err := armor.DecodeArmor(armorStr)
if err != nil {
return privKey, err
}
@ -112,7 +115,7 @@ func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte
}
key = crypto.Sha256(key) // Get 32 bytes
privKeyBytes := privKey.Bytes()
return saltBytes, crypto.EncryptSymmetric(privKeyBytes, key)
return saltBytes, xsalsa20symmetric.EncryptSymmetric(privKeyBytes, key)
}
func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey crypto.PrivKey, err error) {
@ -121,10 +124,10 @@ func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privK
cmn.Exit("Error generating bcrypt key from passphrase: " + err.Error())
}
key = crypto.Sha256(key) // Get 32 bytes
privKeyBytes, err := crypto.DecryptSymmetric(encBytes, key)
privKeyBytes, err := xsalsa20symmetric.DecryptSymmetric(encBytes, key)
if err != nil {
return privKey, err
}
privKey, err = crypto.PrivKeyFromBytes(privKeyBytes)
privKey, err = cryptoAmino.PrivKeyFromBytes(privKeyBytes)
return privKey, err
}

View File

@ -3,13 +3,13 @@ package keys
import (
ccrypto "github.com/cosmos/cosmos-sdk/crypto"
amino "github.com/tendermint/go-amino"
tcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
var cdc = amino.NewCodec()
func init() {
tcrypto.RegisterAmino(cdc)
cryptoAmino.RegisterAmino(cdc)
cdc.RegisterInterface((*Info)(nil), nil)
cdc.RegisterConcrete(ccrypto.PrivKeyLedgerSecp256k1{},
"tendermint/PrivKeyLedgerSecp256k1", nil)

View File

@ -6,6 +6,7 @@ import (
secp256k1 "github.com/btcsuite/btcd/btcec"
tmcrypto "github.com/tendermint/tendermint/crypto"
tmsecp256k1 "github.com/tendermint/tendermint/crypto/secp256k1"
)
var (
@ -140,7 +141,7 @@ func (pkl PrivKeyLedgerSecp256k1) signLedgerSecp256k1(msg []byte) (tmcrypto.Sign
return nil, err
}
return tmcrypto.SignatureSecp256k1FromBytes(sigBytes), nil
return tmsecp256k1.SignatureSecp256k1FromBytes(sigBytes), nil
}
func (pkl PrivKeyLedgerSecp256k1) pubkeyLedgerSecp256k1() (pub tmcrypto.PubKey, err error) {
@ -149,7 +150,7 @@ func (pkl PrivKeyLedgerSecp256k1) pubkeyLedgerSecp256k1() (pub tmcrypto.PubKey,
return nil, fmt.Errorf("error fetching public key: %v", err)
}
var pk tmcrypto.PubKeySecp256k1
var pk tmsecp256k1.PubKeySecp256k1
// re-serialize in the 33-byte compressed format
cmp, err := secp256k1.ParsePubKey(key[:], secp256k1.S256())

View File

@ -6,7 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
var ledgerEnabledEnv = "TEST_WITH_LEDGER"
@ -30,7 +30,7 @@ func TestRealLedgerSecp256k1(t *testing.T) {
// now, let's serialize the public key and make sure it still works
bs := priv.PubKey().Bytes()
pub2, err := tmcrypto.PubKeyFromBytes(bs)
pub2, err := cryptoAmino.PubKeyFromBytes(bs)
require.Nil(t, err, "%+v", err)
// make sure we get the same pubkey when we load from disk
@ -44,7 +44,7 @@ func TestRealLedgerSecp256k1(t *testing.T) {
// make sure pubkeys serialize properly as well
bs = pub.Bytes()
bpub, err := tmcrypto.PubKeyFromBytes(bs)
bpub, err := cryptoAmino.PubKeyFromBytes(bs)
require.NoError(t, err)
require.Equal(t, pub, bpub)
}

View File

@ -6,6 +6,8 @@ import (
"fmt"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -20,7 +22,7 @@ const (
)
var (
issuer = crypto.GenPrivKeyEd25519().PubKey().Address()
issuer = ed25519.GenPrivKey().PubKey().Address()
)
func NewCodec() *wire.Codec {
@ -28,7 +30,7 @@ func NewCodec() *wire.Codec {
cdc.RegisterInterface((*sdk.Msg)(nil), nil)
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
crypto.RegisterAmino(cdc)
cryptoAmino.RegisterAmino(cdc)
return cdc
}

View File

@ -2,8 +2,9 @@ package app
import (
"testing"
"github.com/tendermint/tendermint/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/stretchr/testify/require"
)
@ -11,8 +12,8 @@ import (
// Test encoding of app2Tx is correct with both msg types
func TestEncoding(t *testing.T) {
// Create privkeys and addresses
priv1 := crypto.GenPrivKeyEd25519()
priv2 := crypto.GenPrivKeyEd25519()
priv1 := ed25519.GenPrivKey()
priv2 := ed25519.GenPrivKey()
addr1 := priv1.PubKey().Address().Bytes()
addr2 := priv2.PubKey().Address().Bytes()

View File

@ -1,16 +1,16 @@
package app
import (
cryptoAmino "github.com/tendermint/tendermint/crypto/encoding/amino"
cmn "github.com/tendermint/tendermint/libs/common"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/crypto"
bapp "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/wire"
)
const (
@ -57,6 +57,6 @@ func UpdatedCodec() *wire.Codec {
cdc.RegisterConcrete(MsgSend{}, "example/MsgSend", nil)
cdc.RegisterConcrete(MsgIssue{}, "example/MsgIssue", nil)
auth.RegisterWire(cdc)
crypto.RegisterAmino(cdc)
cryptoAmino.RegisterAmino(cdc)
return cdc
}

View File

@ -1,14 +1,15 @@
package app
import (
"github.com/stretchr/testify/require"
"os"
"encoding/json"
"os"
"testing"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
bapp "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -54,8 +55,8 @@ func TestBadMsg(t *testing.T) {
bc := newTestChain()
// Create privkeys and addresses
priv1 := crypto.GenPrivKeyEd25519()
priv2 := crypto.GenPrivKeyEd25519()
priv1 := ed25519.GenPrivKey()
priv2 := ed25519.GenPrivKey()
addr1 := priv1.PubKey().Address().Bytes()
addr2 := priv2.PubKey().Address().Bytes()
@ -99,8 +100,8 @@ func TestBadMsg(t *testing.T) {
func TestMsgSend(t *testing.T) {
bc := newTestChain()
priv1 := crypto.GenPrivKeyEd25519()
priv2 := crypto.GenPrivKeyEd25519()
priv1 := ed25519.GenPrivKey()
priv2 := ed25519.GenPrivKey()
addr1 := priv1.PubKey().Address().Bytes()
addr2 := priv2.PubKey().Address().Bytes()
@ -138,5 +139,4 @@ func TestMsgSend(t *testing.T) {
require.True(t, res.IsOK(), res.Log)
}

View File

@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
)
@ -42,7 +42,7 @@ func TestGenesis(t *testing.T) {
baseApp := NewBasecoinApp(logger, db)
// construct a pubkey and an address for the test account
pubkey := crypto.GenPrivKeyEd25519().PubKey()
pubkey := ed25519.GenPrivKey().PubKey()
addr := sdk.AccAddress(pubkey.Address())
// construct some test coins

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
)
@ -46,7 +46,7 @@ func TestGenesis(t *testing.T) {
bapp := NewDemocoinApp(logger, db)
// Construct some genesis bytes to reflect democoin/types/AppAccount
pk := crypto.GenPrivKeyEd25519().PubKey()
pk := ed25519.GenPrivKey().PubKey()
addr := sdk.AccAddress(pk.Address())
coins, err := sdk.ParseCoins("77foocoin,99barcoin")
require.Nil(t, err)

View File

@ -9,11 +9,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/mock"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
var (
priv1 = crypto.GenPrivKeyEd25519()
priv1 = ed25519.GenPrivKey()
pubKey = priv1.PubKey()
addr1 = sdk.AccAddress(pubKey.Address())

View File

@ -11,11 +11,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/mock"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
var (
priv1 = crypto.GenPrivKeyEd25519()
priv1 = ed25519.GenPrivKey()
addr1 = sdk.AccAddress(priv1.PubKey().Address())
)

View File

@ -5,9 +5,9 @@ import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -55,7 +55,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
if err != nil {
return err
}
var pubKeyEd crypto.PubKeyEd25519
var pubKeyEd ed25519.PubKeyEd25519
copy(pubKeyEd[:], rawPubKey)
msg := simplestake.NewMsgBond(from, stake, pubKeyEd)

View File

@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -43,7 +43,7 @@ func TestKeeperGetSet(t *testing.T) {
bi := stakeKeeper.getBondInfo(ctx, addr)
require.Equal(t, bi, bondInfo{})
privKey := crypto.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
bi = bondInfo{
PubKey: privKey.PubKey(),
@ -69,7 +69,7 @@ func TestBonding(t *testing.T) {
coinKeeper := bank.NewKeeper(accountMapper)
stakeKeeper := NewKeeper(capKey, coinKeeper, DefaultCodespace)
addr := sdk.AccAddress([]byte("some-address"))
privKey := crypto.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey()
_, _, err := stakeKeeper.unbondWithoutCoins(ctx, addr)

View File

@ -4,14 +4,13 @@ import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestBondMsgValidation(t *testing.T) {
privKey := crypto.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
cases := []struct {
valid bool
msgBond MsgBond

View File

@ -7,6 +7,8 @@ import (
"fmt"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/libs/bech32"
)
@ -225,7 +227,7 @@ func GetAccPubKeyBech32(address string) (pk crypto.PubKey, err error) {
return nil, err
}
pk, err = crypto.PubKeyFromBytes(bz)
pk, err = cryptoAmino.PubKeyFromBytes(bz)
if err != nil {
return nil, err
}
@ -249,7 +251,7 @@ func GetValPubKeyBech32(pubkey string) (pk crypto.PubKey, err error) {
return nil, err
}
pk, err = crypto.PubKeyFromBytes(bz)
pk, err = cryptoAmino.PubKeyFromBytes(bz)
if err != nil {
return nil, err
}

View File

@ -5,7 +5,7 @@ import (
"encoding/json"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding/amino"
)
// amino codec to marshal/unmarshal
@ -18,7 +18,7 @@ func NewCodec() *Codec {
// Register the go-crypto to the codec
func RegisterCrypto(cdc *Codec) {
crypto.RegisterAmino(cdc)
cryptoAmino.RegisterAmino(cdc)
}
// attempt to make some pretty json

View File

@ -6,13 +6,14 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
wire "github.com/cosmos/cosmos-sdk/wire"
)
func keyPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) {
key := crypto.GenPrivKeyEd25519()
key := ed25519.GenPrivKey()
pub := key.PubKey()
addr := sdk.AccAddress(pub.Address())
return key, pub, addr

View File

@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -32,7 +33,7 @@ func newCoins() sdk.Coins {
// generate a priv key and return it with its address
func privAndAddr() (crypto.PrivKey, sdk.AccAddress) {
priv := crypto.GenPrivKeyEd25519()
priv := ed25519.GenPrivKey()
addr := sdk.AccAddress(priv.PubKey().Address())
return priv, addr
}

View File

@ -5,14 +5,13 @@ import (
"testing"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestStdTx(t *testing.T) {
priv := crypto.GenPrivKeyEd25519()
priv := ed25519.GenPrivKey()
addr := sdk.AccAddress(priv.PubKey().Address())
msgs := []sdk.Msg{sdk.NewTestMsg(addr)}
fee := newStdFee()
@ -27,7 +26,7 @@ func TestStdTx(t *testing.T) {
}
func TestStdSignBytes(t *testing.T) {
priv := crypto.GenPrivKeyEd25519()
priv := ed25519.GenPrivKey()
addr := sdk.AccAddress(priv.PubKey().Address())
msgs := []sdk.Msg{sdk.NewTestMsg(addr)}
fee := newStdFee()

View File

@ -11,6 +11,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
type (
@ -30,12 +31,12 @@ type (
)
var (
priv1 = crypto.GenPrivKeyEd25519()
priv1 = ed25519.GenPrivKey()
addr1 = sdk.AccAddress(priv1.PubKey().Address())
priv2 = crypto.GenPrivKeyEd25519()
priv2 = ed25519.GenPrivKey()
addr2 = sdk.AccAddress(priv2.PubKey().Address())
addr3 = sdk.AccAddress(crypto.GenPrivKeyEd25519().PubKey().Address())
priv4 = crypto.GenPrivKeyEd25519()
addr3 = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
priv4 = ed25519.GenPrivKey()
addr4 = sdk.AccAddress(priv4.PubKey().Address())
coins = sdk.Coins{sdk.NewCoin("foocoin", 10)}

View File

@ -8,21 +8,32 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/cosmos/cosmos-sdk/x/stake"
)
var (
pubkeys = []crypto.PubKey{ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey()}
)
func createValidators(t *testing.T, stakeHandler sdk.Handler, ctx sdk.Context, addrs []sdk.AccAddress, coinAmt []int64) {
require.True(t, len(addrs) <= len(pubkeys), "Not enough pubkeys specified at top of file.")
dummyDescription := stake.NewDescription("T", "E", "S", "T")
for i := 0; i < len(addrs); i++ {
valCreateMsg := stake.NewMsgCreateValidator(addrs[i], pubkeys[i], sdk.NewCoin("steak", coinAmt[i]), dummyDescription)
res := stakeHandler(ctx, valCreateMsg)
require.True(t, res.IsOK())
}
}
func TestTallyNoOneVotes(t *testing.T) {
mapp, keeper, sk, addrs, _, _ := getMockApp(t, 10)
mapp.BeginBlock(abci.RequestBeginBlock{})
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:2], []int64{5, 5})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -40,13 +51,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
res := stakeHandler(ctx, val1CreateMsg)
require.True(t, res.IsOK())
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
res = stakeHandler(ctx, val2CreateMsg)
require.True(t, res.IsOK())
createValidators(t, stakeHandler, ctx, addrs[:2], []int64{5, 5})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -69,11 +74,7 @@ func TestTallyOnlyValidators51No(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:2], []int64{5, 6})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -96,13 +97,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{6, 6, 7})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -127,13 +122,7 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{6, 6, 7})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -158,13 +147,7 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{6, 6, 7})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -189,13 +172,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{6, 6, 7})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -220,13 +197,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{6, 6, 7})
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposalID := proposal.GetProposalID()
@ -251,13 +222,7 @@ func TestTallyDelgatorOverride(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{5, 6, 7})
delegator1Msg := stake.NewMsgDelegate(addrs[3], addrs[2], sdk.NewCoin("steak", 30))
stakeHandler(ctx, delegator1Msg)
@ -287,13 +252,7 @@ func TestTallyDelgatorInherit(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{5, 6, 7})
delegator1Msg := stake.NewMsgDelegate(addrs[3], addrs[2], sdk.NewCoin("steak", 30))
stakeHandler(ctx, delegator1Msg)
@ -322,13 +281,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 5), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{5, 6, 7})
delegator1Msg := stake.NewMsgDelegate(addrs[3], addrs[2], sdk.NewCoin("steak", 10))
stakeHandler(ctx, delegator1Msg)
@ -361,11 +314,11 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) {
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 25), dummyDescription)
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], ed25519.GenPrivKey().PubKey(), sdk.NewCoin("steak", 25), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], ed25519.GenPrivKey().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], ed25519.GenPrivKey().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
delegator1Msg := stake.NewMsgDelegate(addrs[3], addrs[2], sdk.NewCoin("steak", 10))
@ -396,13 +349,7 @@ func TestTallyRevokedValidator(t *testing.T) {
ctx := mapp.BaseApp.NewContext(false, abci.Header{})
stakeHandler := stake.NewHandler(sk)
dummyDescription := stake.NewDescription("T", "E", "S", "T")
val1CreateMsg := stake.NewMsgCreateValidator(addrs[0], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 25), dummyDescription)
stakeHandler(ctx, val1CreateMsg)
val2CreateMsg := stake.NewMsgCreateValidator(addrs[1], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 6), dummyDescription)
stakeHandler(ctx, val2CreateMsg)
val3CreateMsg := stake.NewMsgCreateValidator(addrs[2], crypto.GenPrivKeyEd25519().PubKey(), sdk.NewCoin("steak", 7), dummyDescription)
stakeHandler(ctx, val3CreateMsg)
createValidators(t, stakeHandler, ctx, addrs[:3], []int64{25, 6, 7})
delegator1Msg := stake.NewMsgDelegate(addrs[3], addrs[2], sdk.NewCoin("steak", 10))
stakeHandler(ctx, delegator1Msg)

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/mock"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
// initialize the mock application for this module
@ -34,7 +34,7 @@ func TestIBCMsgs(t *testing.T) {
sourceChain := "source-chain"
destChain := "dest-chain"
priv1 := crypto.GenPrivKeyEd25519()
priv1 := ed25519.GenPrivKey()
addr1 := sdk.AccAddress(priv1.PubKey().Address())
coins := sdk.Coins{sdk.NewCoin("foocoin", 10)}
var emptyCoins sdk.Coins

View File

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -29,7 +29,7 @@ func defaultContext(key sdk.StoreKey) sdk.Context {
}
func newAddress() sdk.AccAddress {
return sdk.AccAddress(crypto.GenPrivKeyEd25519().PubKey().Address())
return sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
}
func getCoins(ck bank.Keeper, ctx sdk.Context, addr sdk.AccAddress) (sdk.Coins, sdk.Error) {

View File

@ -10,6 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
)
@ -97,7 +98,7 @@ func (app *App) InitChainer(ctx sdk.Context, _ abci.RequestInitChain) abci.Respo
// their addresses, pubkeys, and privkeys.
func CreateGenAccounts(numAccs int, genCoins sdk.Coins) (genAccs []auth.Account, addrs []sdk.AccAddress, pubKeys []crypto.PubKey, privKeys []crypto.PrivKey) {
for i := 0; i < numAccs; i++ {
privKey := crypto.GenPrivKeyEd25519()
privKey := ed25519.GenPrivKey()
pubKey := privKey.PubKey()
addr := sdk.AccAddress(pubKey.Address())
@ -158,7 +159,7 @@ func GeneratePrivKeys(n int) (keys []crypto.PrivKey) {
// TODO: Randomize this between ed25519 and secp256k1
keys = make([]crypto.PrivKey, n, n)
for i := 0; i < n; i++ {
keys[i] = crypto.GenPrivKeyEd25519()
keys[i] = ed25519.GenPrivKey()
}
return
@ -170,7 +171,7 @@ func GeneratePrivKeyAddressPairs(n int) (keys []crypto.PrivKey, addrs []sdk.AccA
keys = make([]crypto.PrivKey, n, n)
addrs = make([]sdk.AccAddress, n, n)
for i := 0; i < n; i++ {
keys[i] = crypto.GenPrivKeyEd25519()
keys[i] = ed25519.GenPrivKey()
addrs[i] = sdk.AccAddress(keys[i].PubKey().Address())
}
return

View File

@ -11,11 +11,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/stake"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
var (
priv1 = crypto.GenPrivKeyEd25519()
priv1 = ed25519.GenPrivKey()
addr1 = sdk.AccAddress(priv1.PubKey().Address())
coins = sdk.Coins{sdk.NewCoin("foocoin", 10)}
)

View File

@ -9,6 +9,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -88,7 +89,7 @@ func newPubKey(pk string) (res crypto.PubKey) {
if err != nil {
panic(err)
}
var pkEd crypto.PubKeyEd25519
var pkEd ed25519.PubKeyEd25519
copy(pkEd[:], pkBytes[:])
return pkEd
}

View File

@ -9,16 +9,16 @@ import (
"github.com/cosmos/cosmos-sdk/x/mock"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
var (
priv1 = crypto.GenPrivKeyEd25519()
priv1 = ed25519.GenPrivKey()
addr1 = sdk.AccAddress(priv1.PubKey().Address())
priv2 = crypto.GenPrivKeyEd25519()
priv2 = ed25519.GenPrivKey()
addr2 = sdk.AccAddress(priv2.PubKey().Address())
addr3 = sdk.AccAddress(crypto.GenPrivKeyEd25519().PubKey().Address())
priv4 = crypto.GenPrivKeyEd25519()
addr3 = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address())
priv4 = ed25519.GenPrivKey()
addr4 = sdk.AccAddress(priv4.PubKey().Address())
coins = sdk.Coins{{"foocoin", sdk.NewInt(10)}}
fee = auth.StdFee{

View File

@ -2,6 +2,8 @@ package cli
import (
flag "github.com/spf13/pflag"
"github.com/cosmos/cosmos-sdk/x/stake/types"
)
// nolint
@ -26,7 +28,8 @@ var (
fsPk = flag.NewFlagSet("", flag.ContinueOnError)
fsAmount = flag.NewFlagSet("", flag.ContinueOnError)
fsShares = flag.NewFlagSet("", flag.ContinueOnError)
fsDescription = flag.NewFlagSet("", flag.ContinueOnError)
fsDescriptionCreate = flag.NewFlagSet("", flag.ContinueOnError)
fsDescriptionEdit = flag.NewFlagSet("", flag.ContinueOnError)
fsValidator = flag.NewFlagSet("", flag.ContinueOnError)
fsDelegator = flag.NewFlagSet("", flag.ContinueOnError)
fsRedelegation = flag.NewFlagSet("", flag.ContinueOnError)
@ -37,10 +40,14 @@ func init() {
fsAmount.String(FlagAmount, "1steak", "Amount of coins to bond")
fsShares.String(FlagSharesAmount, "", "Amount of source-shares to either unbond or redelegate as a positive integer or decimal")
fsShares.String(FlagSharesPercent, "", "Percent of source-shares to either unbond or redelegate as a positive integer or decimal >0 and <=1")
fsDescription.String(FlagMoniker, "[do-not-modify]", "validator name")
fsDescription.String(FlagIdentity, "[do-not-modify]", "optional identity signature (ex. UPort or Keybase)")
fsDescription.String(FlagWebsite, "[do-not-modify]", "optional website")
fsDescription.String(FlagDetails, "[do-not-modify]", "optional details")
fsDescriptionCreate.String(FlagMoniker, "", "validator name")
fsDescriptionCreate.String(FlagIdentity, "", "optional identity signature (ex. UPort or Keybase)")
fsDescriptionCreate.String(FlagWebsite, "", "optional website")
fsDescriptionCreate.String(FlagDetails, "", "optional details")
fsDescriptionEdit.String(FlagMoniker, types.DoNotModifyDesc, "validator name")
fsDescriptionEdit.String(FlagIdentity, types.DoNotModifyDesc, "optional identity signature (ex. UPort or Keybase)")
fsDescriptionEdit.String(FlagWebsite, types.DoNotModifyDesc, "optional website")
fsDescriptionEdit.String(FlagDetails, types.DoNotModifyDesc, "optional details")
fsValidator.String(FlagAddressValidator, "", "hex address of the validator")
fsDelegator.String(FlagAddressDelegator, "", "hex address of the delegator")
fsRedelegation.String(FlagAddressValidatorSrc, "", "hex address of the source validator")

View File

@ -73,7 +73,7 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command {
cmd.Flags().AddFlagSet(fsPk)
cmd.Flags().AddFlagSet(fsAmount)
cmd.Flags().AddFlagSet(fsDescription)
cmd.Flags().AddFlagSet(fsDescriptionCreate)
cmd.Flags().AddFlagSet(fsDelegator)
return cmd
}
@ -108,7 +108,7 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command {
},
}
cmd.Flags().AddFlagSet(fsDescription)
cmd.Flags().AddFlagSet(fsDescriptionEdit)
return cmd
}

View File

@ -10,6 +10,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
@ -131,7 +132,7 @@ func NewPubKey(pk string) (res crypto.PubKey) {
panic(err)
}
//res, err = crypto.PubKeyFromBytes(pkBytes)
var pkEd crypto.PubKeyEd25519
var pkEd ed25519.PubKeyEd25519
copy(pkEd[:], pkBytes[:])
return pkEd
}

View File

@ -3,12 +3,13 @@ package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
)
var (
pk1 = crypto.GenPrivKeyEd25519().PubKey()
pk2 = crypto.GenPrivKeyEd25519().PubKey()
pk3 = crypto.GenPrivKeyEd25519().PubKey()
pk1 = ed25519.GenPrivKey().PubKey()
pk2 = ed25519.GenPrivKey().PubKey()
pk3 = ed25519.GenPrivKey().PubKey()
addr1 = sdk.AccAddress(pk1.Address())
addr2 = sdk.AccAddress(pk2.Address())
addr3 = sdk.AccAddress(pk3.Address())

View File

@ -13,8 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/wire"
)
const doNotModifyDescVal = "[do-not-modify]"
// Validator defines the total amount of bond shares and their exchange rate to
// coins. Accumulation of interest is modelled as an in increase in the
// exchange rate, and slashing as a decrease. When coins are delegated to this
@ -250,6 +248,9 @@ func (v Validator) Equal(c2 Validator) bool {
v.LastBondedTokens.Equal(c2.LastBondedTokens)
}
// constant used in flags to indicate that description field should not be updated
const DoNotModifyDesc = "[do-not-modify]"
// Description - description fields for a validator
type Description struct {
Moniker string `json:"moniker"` // name
@ -271,16 +272,16 @@ func NewDescription(moniker, identity, website, details string) Description {
// UpdateDescription updates the fields of a given description. An error is
// returned if the resulting description contains an invalid length.
func (d Description) UpdateDescription(d2 Description) (Description, sdk.Error) {
if d.Moniker == doNotModifyDescVal {
if d2.Moniker == DoNotModifyDesc {
d2.Moniker = d.Moniker
}
if d.Identity == doNotModifyDescVal {
if d2.Identity == DoNotModifyDesc {
d2.Identity = d.Identity
}
if d.Website == doNotModifyDescVal {
if d2.Website == DoNotModifyDesc {
d2.Website = d.Website
}
if d.Details == doNotModifyDescVal {
if d2.Details == DoNotModifyDesc {
d2.Details = d.Details
}

View File

@ -25,19 +25,31 @@ func TestValidatorEqual(t *testing.T) {
func TestUpdateDescription(t *testing.T) {
d1 := Description{
Moniker: doNotModifyDescVal,
Identity: doNotModifyDescVal,
Website: doNotModifyDescVal,
Details: doNotModifyDescVal,
}
d2 := Description{
Website: "https://validator.cosmos",
Details: "Test validator",
}
d2 := Description{
Moniker: DoNotModifyDesc,
Identity: DoNotModifyDesc,
Website: DoNotModifyDesc,
Details: DoNotModifyDesc,
}
d3 := Description{
Moniker: "",
Identity: "",
Website: "",
Details: "",
}
d, err := d1.UpdateDescription(d2)
require.Nil(t, err)
require.Equal(t, d, d1)
d, err = d1.UpdateDescription(d3)
require.Nil(t, err)
require.Equal(t, d, d3)
}
func TestABCIValidator(t *testing.T) {