mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-17 15:11:21 +00:00
Revert "delete everything" (includes everything non-go-crypto)
This reverts commit 96a3502
This commit is contained in:
43
rpc/lib/client/args_test.go
Normal file
43
rpc/lib/client/args_test.go
Normal file
@ -0,0 +1,43 @@
|
||||
package rpcclient
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"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"}`},
|
||||
}
|
||||
|
||||
cdc := amino.NewCodec()
|
||||
|
||||
for i, tc := range cases {
|
||||
args := map[string]interface{}{"data": tc.input}
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user