Commit 5795fe6b authored by mdj33's avatar mdj33 Committed by vipwzw

fix ut

parent f1bc1850
......@@ -361,6 +361,23 @@ function para_cross_transfer_withdraw() {
break
fi
done
echo "check asset transfer tx=$hash"
res=$(${CLI} para asset_txinfo -s "${hash}")
echo "$res"
succ=$(jq -r ".success" <<<"$res")
if [ "${succ}" != "true" ]; then
echo "para asset transfer tx report fail"
exit 1
fi
echo "check asset withdraw tx=$hash2"
res=$(${CLI} para asset_txinfo -s "${hash2}")
echo "$res"
succ=$(jq -r ".success" <<<"$res")
if [ "${succ}" != "true" ]; then
echo "para asset withdraw tx report fail"
exit 1
fi
}
function token_create_on_mainChain() {
......
......@@ -15,7 +15,6 @@ import (
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
ptestNode "github.com/33cn/plugin/plugin/dapp/paracross/testnode"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"golang.org/x/net/context"
......@@ -31,117 +30,6 @@ func newJrpc(api client.QueueProtocolAPI) *Jrpc {
return &Jrpc{cli: newGrpc(api)}
}
func TestChannelClient_GetTitle(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
client := newGrpc(api)
client.Init("paracross", nil, nil, nil)
req := &types.ReqString{Data: "xxxxxxxxxxx"}
api.On("Query", pt.GetExecName(cfg), "GetTitle", req).Return(&pt.ParacrossStatus{}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{}, nil).Once()
_, err := client.GetTitle(context.Background(), req)
assert.Nil(t, err)
}
func TestJrpc_GetTitle(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
j := newJrpc(api)
req := &types.ReqString{Data: "xxxxxxxxxxx"}
var result interface{}
api.On("Query", pt.GetExecName(cfg), "GetTitle", req).Return(&pt.ParacrossStatus{
Title: "user.p.para", Height: int64(64), BlockHash: []byte{177, 17, 9, 106, 247, 117, 90, 242, 221, 160, 157, 31, 33, 51, 10, 99, 77, 47, 245, 223, 59, 64, 121, 121, 215, 167, 152, 17, 223, 218, 173, 83}}, nil)
api.On("GetLastHeader", mock.Anything).Return(&types.Header{}, nil).Once()
err := j.GetHeight(req, &result)
assert.Nil(t, err)
}
func TestChannelClient_ListTitles(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
client := newGrpc(api)
client.Init("paracross", nil, nil, nil)
req := &types.ReqNil{}
api.On("Query", pt.GetExecName(cfg), "ListTitles", req).Return(&pt.RespParacrossTitles{}, nil)
_, err := client.ListTitles(context.Background(), req)
assert.Nil(t, err)
}
func TestJrpc_ListTitles(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
j := newJrpc(api)
req := &types.ReqNil{}
var result interface{}
api.On("Query", pt.GetExecName(cfg), "ListTitles", req).Return(&pt.RespParacrossTitles{}, nil)
err := j.ListTitles(req, &result)
assert.Nil(t, err)
}
func TestChannelClient_GetTitleHeight(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
client := newGrpc(api)
client.Init("paracross", nil, nil, nil)
req := &pt.ReqParacrossTitleHeight{}
api.On("Query", pt.GetExecName(cfg), "GetTitleHeight", req).Return(&pt.ParacrossHeightStatusRsp{}, nil)
_, err := client.GetTitleHeight(context.Background(), req)
assert.Nil(t, err)
}
func TestChannelClient_GetTitleDoneHeight(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
client := newGrpc(api)
client.Init("paracross", nil, nil, nil)
req := &pt.ReqParacrossTitleHeight{}
api.On("Query", pt.GetExecName(cfg), "GetDoneTitleHeight", req).Return(&pt.RespParacrossDone{}, nil)
_, err := client.GetDoneTitleHeight(context.Background(), req)
assert.Nil(t, err)
}
func TestJrpc_GetTitleHeight(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
j := newJrpc(api)
req := &pt.ReqParacrossTitleHeight{}
var result interface{}
api.On("Query", pt.GetExecName(cfg), "GetTitleHeight", req).Return(&pt.ParacrossHeightStatusRsp{}, nil)
err := j.GetTitleHeight(req, &result)
assert.Nil(t, err)
}
func TestChannelClient_GetAssetTxResult(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
client := newGrpc(api)
client.Init("paracross", nil, nil, nil)
req := &types.ReqString{}
api.On("Query", pt.GetExecName(cfg), "GetAssetTxResult", req).Return(&pt.ParacrossAssetRsp{}, nil)
_, err := client.GetAssetTxResult(context.Background(), req)
assert.Nil(t, err)
}
func TestJrpc_GetAssetTxResult(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
api.On("GetConfig", mock.Anything).Return(cfg, nil)
j := newJrpc(api)
req := &types.ReqString{}
var result interface{}
api.On("Query", pt.GetExecName(cfg), "GetAssetTxResult", req).Return(&pt.ParacrossAssetRsp{}, nil)
err := j.GetAssetTxResult(req, &result)
assert.Nil(t, err)
}
func TestChannelClient_IsSync(t *testing.T) {
cfg := types.NewChain33Config(ptestNode.DefaultConfig)
api := new(mocks.QueueProtocolAPI)
......
......@@ -6,7 +6,10 @@ import (
"github.com/33cn/chain33/util"
_ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
_ "github.com/33cn/plugin/plugin"
pt "github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert"
)
func TestParaNode(t *testing.T) {
......@@ -20,4 +23,8 @@ func TestParaNode(t *testing.T) {
tx = util.CreateTxWithExecer(paraCfg, para.Para.GetGenesisKey(), "user.p.test.none")
para.Para.SendTxRPC(tx)
para.Para.WaitHeight(2)
res, err := para.Para.GetAPI().Query(pt.ParaX, "GetTitle", &types.ReqString{Data: "user.p.test."})
assert.Nil(t, err)
assert.Equal(t, int64(-1), res.(*pt.ParacrossStatus).Height)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment