fixed donotmodify bug

This commit is contained in:
Sunny Aggarwal 2018-07-25 16:05:43 -07:00
parent d6cd0d4acc
commit 29bdd663c2
3 changed files with 23 additions and 11 deletions

View File

@ -37,10 +37,10 @@ func init() {
fsAmount.String(FlagAmount, "1steak", "Amount of coins to bond") 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(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") 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(FlagMoniker, "", "validator name")
fsDescription.String(FlagIdentity, "[do-not-modify]", "optional identity signature (ex. UPort or Keybase)") fsDescription.String(FlagIdentity, "", "optional identity signature (ex. UPort or Keybase)")
fsDescription.String(FlagWebsite, "[do-not-modify]", "optional website") fsDescription.String(FlagWebsite, "", "optional website")
fsDescription.String(FlagDetails, "[do-not-modify]", "optional details") fsDescription.String(FlagDetails, "", "optional details")
fsValidator.String(FlagAddressValidator, "", "hex address of the validator") fsValidator.String(FlagAddressValidator, "", "hex address of the validator")
fsDelegator.String(FlagAddressDelegator, "", "hex address of the delegator") fsDelegator.String(FlagAddressDelegator, "", "hex address of the delegator")
fsRedelegation.String(FlagAddressValidatorSrc, "", "hex address of the source validator") fsRedelegation.String(FlagAddressValidatorSrc, "", "hex address of the source validator")

View File

@ -271,16 +271,16 @@ func NewDescription(moniker, identity, website, details string) Description {
// UpdateDescription updates the fields of a given description. An error is // UpdateDescription updates the fields of a given description. An error is
// returned if the resulting description contains an invalid length. // returned if the resulting description contains an invalid length.
func (d Description) UpdateDescription(d2 Description) (Description, sdk.Error) { func (d Description) UpdateDescription(d2 Description) (Description, sdk.Error) {
if d.Moniker == doNotModifyDescVal { if d2.Moniker == doNotModifyDescVal {
d2.Moniker = d.Moniker d2.Moniker = d.Moniker
} }
if d.Identity == doNotModifyDescVal { if d2.Identity == doNotModifyDescVal {
d2.Identity = d.Identity d2.Identity = d.Identity
} }
if d.Website == doNotModifyDescVal { if d2.Website == doNotModifyDescVal {
d2.Website = d.Website d2.Website = d.Website
} }
if d.Details == doNotModifyDescVal { if d2.Details == doNotModifyDescVal {
d2.Details = d.Details d2.Details = d.Details
} }

View File

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