Skip to content

Commit

Permalink
tests, now uses mycoin
Browse files Browse the repository at this point in the history
whoops
  • Loading branch information
rigelrozanski committed Feb 17, 2017
1 parent 49c3ab0 commit 6a21ad5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
40 changes: 40 additions & 0 deletions cmd/commands/utils_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
8 changes: 4 additions & 4 deletions docs/guide/basecoin-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -107,15 +107,15 @@ 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.

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.
Expand Down
8 changes: 4 additions & 4 deletions docs/guide/ibc.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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<header>--commit 0x<commit>
basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 update --header 0x<header>--commit 0x<commit>
```

where `<header>` and `<commit>` are the hex-encoded header and commit returned by the previous `block` command.
Expand All @@ -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 <height + 1> --packet 0x<packet> --proof 0x<proof>
basecoin tx ibc --amount 10mycoin $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height <height + 1> --packet 0x<packet> --proof 0x<proof>
```

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

0 comments on commit 6a21ad5

Please sign in to comment.