1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-06-26 03:01:42 +00:00
Files
.circleci
.github
DOCKER
benchmarks
blockchain
cmd
config
consensus
docs
evidence
libs
lite
mempool
networks
node
p2p
proxy
rpc
client
core
grpc
lib
client
args_test.go
http_client.go
integration_test.go
ws_client.go
ws_client_test.go
server
test
types
doc.go
rpc_test.go
version.go
test
scripts
state
test
types
version
.editorconfig
.gitignore
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
ROADMAP.md
SECURITY.md
Vagrantfile
appveyor.yml
codecov.yml
docker-compose.yml
tendermint/rpc/lib/client/args_test.go

44 lines
824 B
Go
Raw Normal View History

package rpcclient
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
2018-04-05 15:45:11 -07:00
"github.com/tendermint/go-amino"
)
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"}`},
}
2018-04-05 15:45:11 -07:00
cdc := amino.NewCodec()
for i, tc := range cases {
args := map[string]interface{}{"data": tc.input}
2018-04-05 15:45:11 -07:00
err := argsToJSON(cdc, 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)
}
}