github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/integration/rpctransact/send_test.go (about)

     1  // +build integration
     2  
     3  package rpctransact
     4  
     5  import (
     6  	"context"
     7  	"testing"
     8  
     9  	"github.com/hyperledger/burrow/integration"
    10  
    11  	"github.com/hyperledger/burrow/integration/rpctest"
    12  	"github.com/hyperledger/burrow/txs/payload"
    13  	"github.com/stretchr/testify/assert"
    14  	"github.com/stretchr/testify/require"
    15  )
    16  
    17  func TestSendTx(t *testing.T) {
    18  	t.Parallel()
    19  	kern, shutdown := integration.RunNode(t, rpctest.GenesisDoc, rpctest.PrivateAccounts)
    20  	defer shutdown()
    21  
    22  	t.Run("Sync", func(t *testing.T) {
    23  		cli := rpctest.NewTransactClient(t, kern.GRPCListenAddress().String())
    24  		for i := 0; i < 2; i++ {
    25  			txe, err := cli.SendTxSync(context.Background(), &payload.SendTx{
    26  				Inputs: []*payload.TxInput{{
    27  					Address: inputAddress,
    28  					Amount:  2003,
    29  				}},
    30  				Outputs: []*payload.TxOutput{{
    31  					Address: rpctest.PrivateAccounts[3].GetAddress(),
    32  					Amount:  2003,
    33  				}},
    34  			})
    35  			require.NoError(t, err)
    36  			assert.False(t, txe.Receipt.CreatesContract)
    37  		}
    38  	})
    39  
    40  	t.Run("Async", func(t *testing.T) {
    41  		cli := rpctest.NewTransactClient(t, kern.GRPCListenAddress().String())
    42  		numSends := 1000
    43  		expecter := rpctest.ExpectTxs(kern.Emitter, "SendTxAsync")
    44  		for i := 0; i < numSends; i++ {
    45  			receipt, err := cli.SendTxAsync(context.Background(), &payload.SendTx{
    46  				Inputs: []*payload.TxInput{{
    47  					Address: inputAddress,
    48  					Amount:  2003,
    49  				}},
    50  				Outputs: []*payload.TxOutput{{
    51  					Address: rpctest.PrivateAccounts[3].GetAddress(),
    52  					Amount:  2003,
    53  				}},
    54  			})
    55  			expecter.Expect(receipt.TxHash)
    56  			require.NoError(t, err)
    57  			assert.False(t, receipt.CreatesContract)
    58  		}
    59  		expecter.AssertCommitted(t)
    60  	})
    61  }