Skip to content

Commit

Permalink
Test to reproduce #147
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jun 30, 2017
1 parent d36486a commit 4b815f4
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions types/tx_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"encoding/hex"
"fmt"
"testing"

Expand Down Expand Up @@ -124,3 +125,53 @@ func TestSendTxJSON(t *testing.T) {
assert.Equal(tx, tx2)
assert.False(tx2.Inputs[0].Signature.Empty())
}

func TestSendTxIBC(t *testing.T) {
assert, require := assert.New(t), require.New(t)

good, err := hex.DecodeString("1960CA7E170862837AA8F22A947194F41F61860B")
require.Nil(err)
short, err := hex.DecodeString("1960CA7E170862837AA8F22F947194F41F610B")
require.Nil(err)
long, err := hex.DecodeString("1960CA7E170862837AA8F22A947194F41F6186120B")
require.Nil(err)
slash, err := hex.DecodeString("F40ECECEA86F29D0FDF2980EF72F1708687BD4BF")
require.Nil(err)

coins := Coins{{"atom", 5}}

addrs := []struct {
addr []byte
valid bool
}{
{good, true},
{slash, true},
{long, false},
{short, false},
}

prefixes := []struct {
prefix []byte
valid bool
}{
{nil, true},
{[]byte("chain-1/"), true},
{[]byte("chain/with/paths/"), false},
{[]byte("no-slash-here"), false},
}

for i, tc := range addrs {
for j, pc := range prefixes {
addr := append(pc.prefix, tc.addr...)
output := TxOutput{Address: addr, Coins: coins}
res := output.ValidateBasic()

if tc.valid && pc.valid {
assert.True(res.IsOK(), "%d,%d: %s", i, j, res.Log)
} else {
assert.False(res.IsOK(), "%d,%d: %s", i, j, res.Log)
}
}
}

}

0 comments on commit 4b815f4

Please sign in to comment.