-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: base denomination can't be parsed with decimal point (fixes #16
) Solution: - decimal point is something for the future: cosmos/cosmos-sdk#7113 - for the moment -- configured "human" denomination ("cro") + base ("basecro" / "carson") -- configs/tx use "basecro" - custom commands that use "human" denomination and convert it to the base - custom init that changes bond_denom + gov minimum deposit to use the base denomination
- Loading branch information
Showing
8 changed files
with
535 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package app_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/crypto-com/chain-main/app" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestConversion(t *testing.T) { | ||
app.SetConfig() | ||
|
||
testCases := []struct { | ||
input sdk.Coin | ||
denom string | ||
result sdk.Coin | ||
expErr bool | ||
}{ | ||
{sdk.NewCoin("foo", sdk.ZeroInt()), app.HumanCoinUnit, sdk.Coin{}, true}, | ||
{sdk.NewCoin(app.HumanCoinUnit, sdk.ZeroInt()), "foo", sdk.Coin{}, true}, | ||
{sdk.NewCoin(app.HumanCoinUnit, sdk.ZeroInt()), "FOO", sdk.Coin{}, true}, | ||
|
||
{sdk.NewCoin(app.HumanCoinUnit, sdk.NewInt(5)), app.BaseCoinUnit, sdk.NewCoin(app.BaseCoinUnit, sdk.NewInt(500000000)), false}, // cro => carson | ||
|
||
{sdk.NewCoin(app.BaseCoinUnit, sdk.NewInt(500000000)), app.HumanCoinUnit, sdk.NewCoin(app.HumanCoinUnit, sdk.NewInt(5)), false}, // carson => cro | ||
|
||
} | ||
|
||
for i, tc := range testCases { | ||
res, err := sdk.ConvertCoin(tc.input, tc.denom) | ||
require.Equal( | ||
t, tc.expErr, err != nil, | ||
"unexpected error; tc: #%d, input: %s, denom: %s", i+1, tc.input, tc.denom, | ||
) | ||
require.Equal( | ||
t, tc.result, res, | ||
"invalid result; tc: #%d, input: %s, denom: %s", i+1, tc.input, tc.denom, | ||
) | ||
} | ||
|
||
} |
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
Oops, something went wrong.