1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-06-10 20:01:20 +00:00
Files
.github
DOCKER
benchmarks
blockchain
cmd
config
consensus
docs
mempool
node
p2p
proxy
rpc
client
core
grpc
lib
client
args_test.go
http_client.go
ws_client.go
ws_client_test.go
server
test
types
Dockerfile
Makefile
README.md
circle.yml
rpc_test.go
version.go
test
scripts
state
test
types
version
.codecov.yml
.editorconfig
.gitignore
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
INSTALL.md
LICENSE
Makefile
README.md
Vagrantfile
circle.yml
glide.lock
glide.yaml
tendermint/rpc/lib/client/args_test.go
2017-04-26 19:57:33 -04:00

40 lines
758 B
Go

package rpcclient
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type Tx []byte
type Foo struct {
Bar int
Baz string
}
func TestArgToJSON(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
cases := []struct {
input interface{}
expected string
}{
{[]byte("1234"), "0x31323334"},
{Tx("654"), "0x363534"},
{Foo{7, "hello"}, `{"Bar":7,"Baz":"hello"}`},
}
for i, tc := range cases {
args := map[string]interface{}{"data": tc.input}
err := argsToJson(args)
require.Nil(err, "%d: %+v", i, err)
require.Equal(1, len(args), "%d", i)
data, ok := args["data"].(string)
require.True(ok, "%d: %#v", i, args["data"])
assert.Equal(tc.expected, data, "%d", i)
}
}