Skip to content

Commit

Permalink
Merge PR cosmos#1836: docs: Fix build errors on latest tendermint
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored and cwgoes committed Jul 26, 2018
1 parent 5d02a74 commit 78c58bf
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 45 deletions.
4 changes: 3 additions & 1 deletion docs/sdk/core/examples/app2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"encoding/json"
"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"
Expand All @@ -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
}

Expand Down
27 changes: 14 additions & 13 deletions docs/sdk/core/examples/app2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ 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"
)

// 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()

sendMsg := MsgSend{
From: addr1,
To: addr2,
From: addr1,
To: addr2,
Amount: sdk.Coins{{"testCoins", sdk.NewInt(100)}},
}

Expand All @@ -30,8 +31,8 @@ func TestEncoding(t *testing.T) {
}

sendTxBefore := app2Tx{
Msg: sendMsg,
PubKey: priv1.PubKey(),
Msg: sendMsg,
PubKey: priv1.PubKey(),
Signature: sig,
}

Expand All @@ -47,13 +48,13 @@ func TestEncoding(t *testing.T) {
require.Nil(t, err, "Error decoding sendTx")

sendTxAfter := tx1.(app2Tx)

require.Equal(t, sendTxBefore, sendTxAfter, "Transaction changed after encoding/decoding")

issueMsg := MsgIssue{
Issuer: addr1,
Issuer: addr1,
Receiver: addr2,
Coin: sdk.Coin{"testCoin", sdk.NewInt(100)},
Coin: sdk.Coin{"testCoin", sdk.NewInt(100)},
}

signBytes = issueMsg.GetSignBytes()
Expand All @@ -63,8 +64,8 @@ func TestEncoding(t *testing.T) {
}

issueTxBefore := app2Tx{
Msg: issueMsg,
PubKey: priv1.PubKey(),
Msg: issueMsg,
PubKey: priv1.PubKey(),
Signature: sig,
}

Expand All @@ -80,4 +81,4 @@ func TestEncoding(t *testing.T) {

require.Equal(t, issueTxBefore, issueTxAfter, "Transaction changed after encoding/decoding")

}
}
6 changes: 3 additions & 3 deletions docs/sdk/core/examples/app3.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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
}
50 changes: 25 additions & 25 deletions docs/sdk/core/examples/app4_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -44,7 +45,7 @@ func InitTestChain(bc *bapp.BaseApp, chainID string, addrs ...sdk.AccAddress) {
// Generate basic SpendMsg with one input and output
func GenerateSpendMsg(sender, receiver sdk.AccAddress, amount sdk.Coins) bank.MsgSend {
return bank.MsgSend{
Inputs: []bank.Input{{sender, amount}},
Inputs: []bank.Input{{sender, amount}},
Outputs: []bank.Output{{receiver, amount}},
}
}
Expand All @@ -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()

Expand All @@ -64,7 +65,7 @@ func TestBadMsg(t *testing.T) {

// Construct transaction
fee := auth.StdFee{
Gas: 1000000000000000,
Gas: 1000000000000000,
Amount: sdk.Coins{{"testCoin", sdk.NewInt(0)}},
}
signBytes := auth.StdSignBytes("test-chain", 0, 0, fee, []sdk.Msg{msg}, "")
Expand All @@ -73,17 +74,17 @@ func TestBadMsg(t *testing.T) {
panic(err)
}
sigs := []auth.StdSignature{auth.StdSignature{
PubKey: priv1.PubKey(),
Signature: sig,
PubKey: priv1.PubKey(),
Signature: sig,
AccountNumber: 0,
Sequence: 0,
Sequence: 0,
}}

tx := auth.StdTx{
Msgs: []sdk.Msg{msg},
Fee: fee,
Msgs: []sdk.Msg{msg},
Fee: fee,
Signatures: sigs,
Memo: "",
Memo: "",
}

bc.BeginBlock(abci.RequestBeginBlock{Header: abci.Header{ChainID: "test-chain"}})
Expand All @@ -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()

Expand All @@ -110,7 +111,7 @@ func TestMsgSend(t *testing.T) {
msg := GenerateSpendMsg(addr1, addr2, sdk.Coins{{"testCoin", sdk.NewInt(100)}})

fee := auth.StdFee{
Gas: 1000000000000000,
Gas: 1000000000000000,
Amount: sdk.Coins{{"testCoin", sdk.NewInt(0)}},
}
signBytes := auth.StdSignBytes("test-chain", 0, 0, fee, []sdk.Msg{msg}, "")
Expand All @@ -119,17 +120,17 @@ func TestMsgSend(t *testing.T) {
panic(err)
}
sigs := []auth.StdSignature{auth.StdSignature{
PubKey: priv1.PubKey(),
Signature: sig,
PubKey: priv1.PubKey(),
Signature: sig,
AccountNumber: 0,
Sequence: 0,
Sequence: 0,
}}

tx := auth.StdTx{
Msgs: []sdk.Msg{msg},
Fee: fee,
Msgs: []sdk.Msg{msg},
Fee: fee,
Signatures: sigs,
Memo: "",
Memo: "",
}

bc.BeginBlock(abci.RequestBeginBlock{})
Expand All @@ -138,5 +139,4 @@ func TestMsgSend(t *testing.T) {

require.True(t, res.IsOK(), res.Log)


}
}
6 changes: 3 additions & 3 deletions x/gov/tally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ func TestTallyRevokedValidator(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))
Expand Down

0 comments on commit 78c58bf

Please sign in to comment.