diff --git a/cmd/commands/utils_test.go b/cmd/commands/utils_test.go new file mode 100644 index 0000000000..c530b04a14 --- /dev/null +++ b/cmd/commands/utils_test.go @@ -0,0 +1,40 @@ +package commands + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/tendermint/basecoin/types" +) + +//Test the parse coin and parse coins functionality +func TestParse(t *testing.T) { + + makeCoin := func(str string) types.Coin { + coin, err := ParseCoin(str) + if err != nil { + panic(err.Error()) + } + return coin + } + + makeCoins := func(str string) types.Coins { + coin, err := ParseCoins(str) + if err != nil { + panic(err.Error()) + } + return coin + } + + //testing ParseCoin Function + assert.True(t, types.Coin{} == makeCoin(""), "parseCoin makes bad empty coin") + assert.True(t, types.Coin{"fooCoin", 1} == makeCoin("1fooCoin"), "parseCoin makes bad coins") + assert.True(t, types.Coin{"barCoin", 10} == makeCoin("10 barCoin"), "parseCoin makes bad coins") + + //testing ParseCoins Function + assert.True(t, types.Coins{{"fooCoin", 1}}.IsEqual(makeCoins("1fooCoin")), "parseCoins doesn't parse a single coin") + assert.True(t, types.Coins{{"barCoin", 99}, {"fooCoin", 1}}.IsEqual(makeCoins("99barCoin,1fooCoin")), + "parseCoins doesn't properly parse two coins") + assert.True(t, types.Coins{{"barCoin", 99}, {"fooCoin", 1}}.IsEqual(makeCoins("99 barCoin, 1 fooCoin")), + "parseCoins doesn't properly parse two coins which use spaces") +} diff --git a/docs/guide/basecoin-basics.md b/docs/guide/basecoin-basics.md index f09213daa9..585b0a00ae 100644 --- a/docs/guide/basecoin-basics.md +++ b/docs/guide/basecoin-basics.md @@ -91,14 +91,14 @@ The first account is flush with cash, while the second account doesn't exist. Let's send funds from the first account to the second: ``` -basecoin tx send --to 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090 --amount 10blank +basecoin tx send --to 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090 --amount 10mycoin ``` By default, the CLI looks for a `priv_validator.json` to sign the transaction with, so this will only work if you are in the `$GOPATH/src/github.com/tendermint/basecoin/data`. To specify a different key, we can use the `--from` flag. -Now if we check the second account, it should have `10` 'blank' coins! +Now if we check the second account, it should have `10` 'mycoin' coins! ``` basecoin account 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090 @@ -107,7 +107,7 @@ basecoin account 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090 We can send some of these coins back like so: ``` -basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 5blank +basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 5mycoin ``` Note how we use the `--from` flag to select a different account to send from. @@ -115,7 +115,7 @@ Note how we use the `--from` flag to select a different account to send from. If we try to send too much, we'll get an error: ``` -basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 100blank +basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 100mycoin ``` See `basecoin tx send --help` for additional details. diff --git a/docs/guide/ibc.md b/docs/guide/ibc.md index 36ae260877..718754363c 100644 --- a/docs/guide/ibc.md +++ b/docs/guide/ibc.md @@ -236,13 +236,13 @@ export CHAIN_FLAGS2="--chain_id $CHAIN_ID2 --from ./data/chain2/basecoin/key.jso Let's start by registering `test_chain_1` on `test_chain_2`: ``` -basecoin tx ibc --amount 10blank $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json +basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json ``` Now we can create the outgoing packet on `test_chain_1`: ``` -basecoin tx ibc --amount 10blank $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload 0xDEADBEEF --sequence 1 +basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload 0xDEADBEEF --sequence 1 ``` Note our payload is just `DEADBEEF`. @@ -270,7 +270,7 @@ The former is used as input for later commands; the latter is human-readable, so Let's send this updated information about `test_chain_1` to `test_chain_2`: ``` -basecoin tx ibc --amount 10blank $CHAIN_FLAGS2 update --header 0x
--commit 0x +basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 update --header 0x
--commit 0x ``` where `
` and `` are the hex-encoded header and commit returned by the previous `block` command. @@ -280,7 +280,7 @@ along with proof the packet was committed on `test_chain_1`. Since `test_chain_2 of `test_chain_1`, it will be able to verify the proof! ``` -basecoin tx ibc --amount 10blank $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height --packet 0x --proof 0x +basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height --packet 0x --proof 0x ``` Here, `` is one greater than the height retuned by the previous `query` command, and `` and `` are the