Skip to content

Commit 6a21ad5

Browse files
committed
tests, now uses mycoin
whoops
1 parent 49c3ab0 commit 6a21ad5

File tree

3 files changed

+48
-8
lines changed

3 files changed

+48
-8
lines changed

cmd/commands/utils_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package commands
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
"github.com/tendermint/basecoin/types"
8+
)
9+
10+
//Test the parse coin and parse coins functionality
11+
func TestParse(t *testing.T) {
12+
13+
makeCoin := func(str string) types.Coin {
14+
coin, err := ParseCoin(str)
15+
if err != nil {
16+
panic(err.Error())
17+
}
18+
return coin
19+
}
20+
21+
makeCoins := func(str string) types.Coins {
22+
coin, err := ParseCoins(str)
23+
if err != nil {
24+
panic(err.Error())
25+
}
26+
return coin
27+
}
28+
29+
//testing ParseCoin Function
30+
assert.True(t, types.Coin{} == makeCoin(""), "parseCoin makes bad empty coin")
31+
assert.True(t, types.Coin{"fooCoin", 1} == makeCoin("1fooCoin"), "parseCoin makes bad coins")
32+
assert.True(t, types.Coin{"barCoin", 10} == makeCoin("10 barCoin"), "parseCoin makes bad coins")
33+
34+
//testing ParseCoins Function
35+
assert.True(t, types.Coins{{"fooCoin", 1}}.IsEqual(makeCoins("1fooCoin")), "parseCoins doesn't parse a single coin")
36+
assert.True(t, types.Coins{{"barCoin", 99}, {"fooCoin", 1}}.IsEqual(makeCoins("99barCoin,1fooCoin")),
37+
"parseCoins doesn't properly parse two coins")
38+
assert.True(t, types.Coins{{"barCoin", 99}, {"fooCoin", 1}}.IsEqual(makeCoins("99 barCoin, 1 fooCoin")),
39+
"parseCoins doesn't properly parse two coins which use spaces")
40+
}

docs/guide/basecoin-basics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ The first account is flush with cash, while the second account doesn't exist.
9191
Let's send funds from the first account to the second:
9292

9393
```
94-
basecoin tx send --to 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090 --amount 10blank
94+
basecoin tx send --to 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090 --amount 10mycoin
9595
```
9696

9797
By default, the CLI looks for a `priv_validator.json` to sign the transaction with,
9898
so this will only work if you are in the `$GOPATH/src/github.com/tendermint/basecoin/data`.
9999
To specify a different key, we can use the `--from` flag.
100100

101-
Now if we check the second account, it should have `10` 'blank' coins!
101+
Now if we check the second account, it should have `10` 'mycoin' coins!
102102

103103
```
104104
basecoin account 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090
@@ -107,15 +107,15 @@ basecoin account 0x1DA7C74F9C219229FD54CC9F7386D5A3839F0090
107107
We can send some of these coins back like so:
108108

109109
```
110-
basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 5blank
110+
basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 5mycoin
111111
```
112112

113113
Note how we use the `--from` flag to select a different account to send from.
114114

115115
If we try to send too much, we'll get an error:
116116

117117
```
118-
basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 100blank
118+
basecoin tx send --to 0x1B1BE55F969F54064628A63B9559E7C21C925165 --from key2.json --amount 100mycoin
119119
```
120120

121121
See `basecoin tx send --help` for additional details.

docs/guide/ibc.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ export CHAIN_FLAGS2="--chain_id $CHAIN_ID2 --from ./data/chain2/basecoin/key.jso
236236
Let's start by registering `test_chain_1` on `test_chain_2`:
237237

238238
```
239-
basecoin tx ibc --amount 10blank $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json
239+
basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json
240240
```
241241

242242
Now we can create the outgoing packet on `test_chain_1`:
243243

244244
```
245-
basecoin tx ibc --amount 10blank $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload 0xDEADBEEF --sequence 1
245+
basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload 0xDEADBEEF --sequence 1
246246
```
247247

248248
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
270270
Let's send this updated information about `test_chain_1` to `test_chain_2`:
271271

272272
```
273-
basecoin tx ibc --amount 10blank $CHAIN_FLAGS2 update --header 0x<header>--commit 0x<commit>
273+
basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 update --header 0x<header>--commit 0x<commit>
274274
```
275275

276276
where `<header>` and `<commit>` 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
280280
of `test_chain_1`, it will be able to verify the proof!
281281

282282
```
283-
basecoin tx ibc --amount 10blank $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height <height + 1> --packet 0x<packet> --proof 0x<proof>
283+
basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height <height + 1> --packet 0x<packet> --proof 0x<proof>
284284
```
285285

286286
Here, `<height + 1>` is one greater than the height retuned by the previous `query` command, and `<packet>` and `<proof>` are the

0 commit comments

Comments
 (0)