From 48f1502167c1b9abd5358794aa071c13803289b4 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 17 Aug 2020 15:09:59 +0300 Subject: [PATCH] rpc/client: add tests for SignAndPushInvocationTx --- pkg/rpc/server/client_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/rpc/server/client_test.go b/pkg/rpc/server/client_test.go index dea10aabe..08f4d0450 100644 --- a/pkg/rpc/server/client_test.go +++ b/pkg/rpc/server/client_test.go @@ -132,3 +132,27 @@ func TestAddNetworkFee(t *testing.T) { require.Equal(t, int64(io.GetVarSize(tx))*feePerByte+cFee+cFeeM+10, tx.NetworkFee) }) } + +func TestSignAndPushInvocationTx(t *testing.T) { + chain, rpcSrv, httpSrv := initServerWithInMemoryChain(t) + defer chain.Close() + defer rpcSrv.Shutdown() + + c, err := client.New(context.Background(), httpSrv.URL, client.Options{Network: testchain.Network()}) + require.NoError(t, err) + + priv := testchain.PrivateKey(0) + acc, err := wallet.NewAccountFromWIF(priv.WIF()) + require.NoError(t, err) + h, err := c.SignAndPushInvocationTx([]byte{byte(opcode.PUSH1)}, acc, 30, 0, []transaction.Signer{{ + Account: priv.GetScriptHash(), + Scopes: transaction.CalledByEntry, + }}) + require.NoError(t, err) + + mp := chain.GetMemPool() + tx, ok := mp.TryGetValue(h) + require.True(t, ok) + require.Equal(t, h, tx.Hash()) + require.EqualValues(t, 30, tx.SystemFee) +}