forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release-pio/v0.46.xLlama incorporate pr feedback (#356)
* PR feedback for #270" * fix assertion * fix broken unit test
- Loading branch information
1 parent
7462a84
commit f0cfe13
Showing
10 changed files
with
117 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/simapp" | ||
"github.com/cosmos/cosmos-sdk/x/bank/keeper" | ||
"github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/stretchr/testify/require" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
"testing" | ||
) | ||
|
||
func TestUpdateDenomMetadata(t *testing.T) { | ||
app := simapp.Setup(t, false) | ||
ctx := app.BaseApp.NewContext(false, tmproto.Header{}) | ||
msgServer := keeper.NewMsgServerImpl(app.BankKeeper) | ||
testCases := []struct { | ||
Name string | ||
ExpectErr bool | ||
ExpectedErr string | ||
req types.MsgUpdateDenomMetadata | ||
}{ | ||
{ | ||
Name: "fail - wrong authority", | ||
ExpectErr: true, | ||
ExpectedErr: "expected cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn got nongovaccount: expected gov account as only signer for proposal message", | ||
req: types.MsgUpdateDenomMetadata{ | ||
FromAddress: "nongovaccount", | ||
Title: "title", | ||
Description: "description", | ||
Metadata: &types.Metadata{ | ||
Name: "diamondback", | ||
Symbol: "DB", | ||
Description: "The native staking token", | ||
DenomUnits: []*types.DenomUnit{ | ||
{"udiamondback", uint32(0), []string{"microdiamondback"}}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "success - correct authority", | ||
ExpectErr: false, | ||
ExpectedErr: "", | ||
req: types.MsgUpdateDenomMetadata{ | ||
FromAddress: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", | ||
Title: "title", | ||
Description: "description", | ||
Metadata: &types.Metadata{ | ||
Base: "diamondback", | ||
Name: "diamondback", | ||
Symbol: "DB", | ||
Description: "The native staking token", | ||
DenomUnits: []*types.DenomUnit{ | ||
{"udiamondback", uint32(0), []string{"microdiamondback"}}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.Name, func(t *testing.T) { | ||
_, err := msgServer.UpdateDenomMetadata(ctx, &testCase.req) | ||
if testCase.ExpectErr { | ||
require.Error(t, err) | ||
require.Equal(t, testCase.ExpectedErr, err.Error()) | ||
} else { | ||
require.NoError(t, err) | ||
metadata, _ := app.BankKeeper.GetDenomMetaData(ctx, "diamondback") | ||
require.Equal(t, testCase.req.Metadata.String(), metadata.String()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters