Skip to content

Commit

Permalink
Merge pull request cosmos#937 from cosmos/rigel/stake-fix
Browse files Browse the repository at this point in the history
staking cli UnmarshalBinary -> UnmarshalJSON
  • Loading branch information
rigelrozanski authored Apr 30, 2018
2 parents c1daa08 + c8a39af commit 4700069
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions cmd/gaia/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ func TestIBCMsgs(t *testing.T) {
func TestStakeMsgs(t *testing.T) {
gapp := newGaiaApp()

genCoins, err := sdk.ParseCoins("42fermion")
genCoins, err := sdk.ParseCoins("42steak")
require.Nil(t, err)
bondCoin, err := sdk.ParseCoin("10fermion")
bondCoin, err := sdk.ParseCoin("10steak")
require.Nil(t, err)

acc1 := &auth.BaseAccount{
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ func GaiaAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (appState jso
return
}

// create the genesis account, give'm few fermions and a buncha token with there name
// create the genesis account, give'm few steaks and a buncha token with there name
accAuth := auth.NewBaseAccountWithAddress(genTx.Address)
accAuth.Coins = sdk.Coins{
{genTx.Name + "Token", 1000},
{"fermion", freeFermionsAcc},
{"steak", freeFermionsAcc},
}
acc := NewGenesisAccount(&accAuth)
genaccs[i] = acc
Expand Down
20 changes: 10 additions & 10 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ func TestGaiaCLISend(t *testing.T) {
barAddr, _ := executeGetAddrPK(t, "gaiacli keys show bar --output=json")

fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", fooAddr, flags))
assert.Equal(t, int64(50), fooAcc.GetCoins().AmountOf("fermion"))
assert.Equal(t, int64(50), fooAcc.GetCoins().AmountOf("steak"))

executeWrite(t, fmt.Sprintf("gaiacli send %v --amount=10fermion --to=%v --name=foo", flags, barAddr), pass)
executeWrite(t, fmt.Sprintf("gaiacli send %v --amount=10steak --to=%v --name=foo", flags, barAddr), pass)
time.Sleep(time.Second * 3) // waiting for some blocks to pass

barAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barAddr, flags))
assert.Equal(t, int64(10), barAcc.GetCoins().AmountOf("fermion"))
assert.Equal(t, int64(10), barAcc.GetCoins().AmountOf("steak"))
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", fooAddr, flags))
assert.Equal(t, int64(40), fooAcc.GetCoins().AmountOf("fermion"))
assert.Equal(t, int64(40), fooAcc.GetCoins().AmountOf("steak"))
}

func TestGaiaCLIDeclareCandidacy(t *testing.T) {
Expand All @@ -70,26 +70,26 @@ func TestGaiaCLIDeclareCandidacy(t *testing.T) {
fooAddr, _ := executeGetAddrPK(t, "gaiacli keys show foo --output=json")
barAddr, barPubKey := executeGetAddrPK(t, "gaiacli keys show bar --output=json")

executeWrite(t, fmt.Sprintf("gaiacli send %v --amount=10fermion --to=%v --name=foo", flags, barAddr), pass)
executeWrite(t, fmt.Sprintf("gaiacli send %v --amount=10steak --to=%v --name=foo", flags, barAddr), pass)
time.Sleep(time.Second * 3) // waiting for some blocks to pass

fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", fooAddr, flags))
assert.Equal(t, int64(40), fooAcc.GetCoins().AmountOf("fermion"))
assert.Equal(t, int64(40), fooAcc.GetCoins().AmountOf("steak"))
barAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barAddr, flags))
assert.Equal(t, int64(10), barAcc.GetCoins().AmountOf("fermion"))
assert.Equal(t, int64(10), barAcc.GetCoins().AmountOf("steak"))

// declare candidacy
declStr := fmt.Sprintf("gaiacli declare-candidacy %v", flags)
declStr += fmt.Sprintf(" --name=%v", "bar")
declStr += fmt.Sprintf(" --address-candidate=%v", barAddr)
declStr += fmt.Sprintf(" --pubkey=%v", barPubKey)
declStr += fmt.Sprintf(" --amount=%v", "3fermion")
declStr += fmt.Sprintf(" --amount=%v", "3steak")
declStr += fmt.Sprintf(" --moniker=%v", "bar-vally")
fmt.Printf("debug declStr: %v\n", declStr)
executeWrite(t, declStr, pass)
time.Sleep(time.Second) // waiting for some blocks to pass
barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barAddr, flags))
assert.Equal(t, int64(7), barAcc.GetCoins().AmountOf("fermion"))
assert.Equal(t, int64(7), barAcc.GetCoins().AmountOf("steak"))
candidate := executeGetCandidate(t, fmt.Sprintf("gaiacli candidate %v --address-candidate=%v", flags, barAddr))
assert.Equal(t, candidate.Address.String(), barAddr)
assert.Equal(t, int64(3), candidate.Assets.Evaluate())
Expand All @@ -106,7 +106,7 @@ func TestGaiaCLIDeclareCandidacy(t *testing.T) {
//executeWrite(t, unbondStr, pass)
//time.Sleep(time.Second * 3) // waiting for some blocks to pass
//barAcc = executeGetAccount(t, fmt.Sprintf("gaiacli account %v %v", barAddr, flags))
//assert.Equal(t, int64(99998), barAcc.GetCoins().AmountOf("fermion"))
//assert.Equal(t, int64(99998), barAcc.GetCoins().AmountOf("steak"))
//candidate = executeGetCandidate(t, fmt.Sprintf("gaiacli candidate %v --address-candidate=%v", flags, barAddr))
//assert.Equal(t, int64(2), candidate.Assets.Evaluate())
}
Expand Down
4 changes: 2 additions & 2 deletions docs/old/staking/public-testnet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Get Tokens
If you haven't already `created a key <../key-management.html>`__,
do so now. Copy your key's address and enter it into
`this utility <http://www.cosmosvalidators.com/>`__ which will send you
some ``fermion`` testnet tokens.
some ``steak`` testnet tokens.

Get Files
---------
Expand Down Expand Up @@ -59,6 +59,6 @@ and check our balance:

Where ``$MYADDR`` is the address originally generated by ``gaia keys new bob``.

You are now ready to declare candidacy or delegate some fermions. See the
You are now ready to declare candidacy or delegate some steaks. See the
`staking module overview <./staking-module.html>`__ for more information
on using the ``gaia client``.
2 changes: 1 addition & 1 deletion docs/sdk/lcd-rest-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ components:
properties:
denom:
type: string
example: fermion
example: steak
amount:
type: number
example: 50
Expand Down
4 changes: 2 additions & 2 deletions docs/staking/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The ``genesis.json`` should look something like:
"address": "1D9B2356CAADF46D3EE3488E3CCE3028B4283DEE",
"coins": [
{
"denom": "fermion",
"denom": "steak",
"amount": 100000
}
]
Expand Down Expand Up @@ -150,7 +150,7 @@ The ``genesis.json`` should look something like:
"denom": 100
},
"max_validators": 100,
"bond_denom": "fermion"
"bond_denom": "steak"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions docs/staking/testnet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ Nice. We can also lookup the validator set:

gaiacli validatorset

Then, we try to transfer some ``fermion`` to another account:
Then, we try to transfer some ``steak`` to another account:

::

gaiacli account <FOO-ADDR>
gaiacli account <BAR-ADDR>
gaiacli send --amount=10fermion --to=<BAR-ADDR> --name=foo --chain-id=test-chain
gaiacli send --amount=10steak --to=<BAR-ADDR> --name=foo --chain-id=test-chain

**Note:** We need to be careful with the ``chain-id`` and ``sequence``

Expand Down
2 changes: 1 addition & 1 deletion x/stake/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (

func init() {
fsPk.String(FlagPubKey, "", "Go-Amino encoded hex PubKey of the validator-candidate. For Ed25519 the go-amino prepend hex is 1624de6220")
fsAmount.String(FlagAmount, "1fermion", "Amount of coins to bond")
fsAmount.String(FlagAmount, "1steak", "Amount of coins to bond")
fsShares.String(FlagShares, "", "Amount of shares to unbond, either in decimal or keyword MAX (ex. 1.23456789, 99, MAX)")
fsDescription.String(FlagMoniker, "", "validator-candidate name")
fsDescription.String(FlagIdentity, "", "optional keybase signature")
Expand Down
4 changes: 2 additions & 2 deletions x/stake/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func GetCmdQueryCandidate(storeName string, cdc *wire.Codec) *cobra.Command {

// parse out the candidate
candidate := new(stake.Candidate)
err = cdc.UnmarshalBinary(res, candidate)
err = cdc.UnmarshalJSON(res, candidate)
if err != nil {
return err
}
Expand Down Expand Up @@ -122,7 +122,7 @@ func GetCmdQueryDelegatorBond(storeName string, cdc *wire.Codec) *cobra.Command

// parse out the bond
bond := new(stake.DelegatorBond)
err = cdc.UnmarshalBinary(res, bond)
err = cdc.UnmarshalJSON(res, bond)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/stake/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func BondingStatusHandlerFn(storeName string, cdc *wire.Codec, kb keys.Keybase,
}

var bond stake.DelegatorBond
err = cdc.UnmarshalBinary(res, &bond)
err = cdc.UnmarshalJSON(res, &bond)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(fmt.Sprintf("Couldn't decode bond. Error: %s", err.Error())))
Expand Down
4 changes: 2 additions & 2 deletions x/stake/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func newTestMsgDeclareCandidacy(address sdk.Address, pubKey crypto.PubKey, amt i
return MsgDeclareCandidacy{
Description: Description{},
CandidateAddr: address,
Bond: sdk.Coin{"fermion", amt},
Bond: sdk.Coin{"steak", amt},
PubKey: pubKey,
}
}
Expand All @@ -27,7 +27,7 @@ func newTestMsgDelegate(delegatorAddr, candidateAddr sdk.Address, amt int64) Msg
return MsgDelegate{
DelegatorAddr: delegatorAddr,
CandidateAddr: candidateAddr,
Bond: sdk.Coin{"fermion", amt},
Bond: sdk.Coin{"steak", amt},
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/stake/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MsgType = "stake"
// initialize at genesis - to allow for the same tests we should should make
// the ValidateBasic() function a return from an initializable function
// ValidateBasic(bondDenom string) function
const StakingToken = "fermion"
const StakingToken = "steak"

//Verify interface at compile time
var _, _, _, _ sdk.Msg = &MsgDeclareCandidacy{}, &MsgEditCandidacy{}, &MsgDelegate{}, &MsgUnbond{}
Expand Down
6 changes: 3 additions & 3 deletions x/stake/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
)

var (
coinPos = sdk.Coin{"fermion", 1000}
coinZero = sdk.Coin{"fermion", 0}
coinNeg = sdk.Coin{"fermion", -10000}
coinPos = sdk.Coin{"steak", 1000}
coinZero = sdk.Coin{"steak", 0}
coinNeg = sdk.Coin{"steak", -10000}
coinPosNotAtoms = sdk.Coin{"foo", 10000}
coinZeroNotAtoms = sdk.Coin{"foo", 0}
coinNegNotAtoms = sdk.Coin{"foo", -10000}
Expand Down
4 changes: 2 additions & 2 deletions x/stake/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func defaultParams() Params {
InflationMin: sdk.NewRat(7, 100),
GoalBonded: sdk.NewRat(67, 100),
MaxValidators: 100,
BondDenom: "fermion",
BondDenom: "steak",
}
}

Expand Down Expand Up @@ -142,7 +142,7 @@ func paramsNoInflation() Params {
InflationMin: sdk.ZeroRat(),
GoalBonded: sdk.NewRat(67, 100),
MaxValidators: 100,
BondDenom: "fermion",
BondDenom: "steak",
}
}

Expand Down

0 comments on commit 4700069

Please sign in to comment.