gitlab.com/SiaPrime/SiaPrime@v1.4.1/modules/transactionpool/standard_test.go (about)

     1  package transactionpool
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gitlab.com/NebulousLabs/fastrand"
     7  	"gitlab.com/SiaPrime/SiaPrime/modules"
     8  	"gitlab.com/SiaPrime/SiaPrime/types"
     9  )
    10  
    11  // TestIntegrationLargeTransactions tries to add a large transaction to the
    12  // transaction pool.
    13  func TestIntegrationLargeTransactions(t *testing.T) {
    14  	if testing.Short() {
    15  		t.SkipNow()
    16  	}
    17  
    18  	tpt, err := createTpoolTester(t.Name())
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	defer tpt.Close()
    23  
    24  	// Create a large transaction and try to get it accepted.
    25  	arbData := make([]byte, modules.TransactionSizeLimit)
    26  	copy(arbData, modules.PrefixNonSia[:])
    27  	fastrand.Read(arbData[100:116]) // prevents collisions with other transacitons in the loop.
    28  	txn := types.Transaction{ArbitraryData: [][]byte{arbData}}
    29  	err = tpt.tpool.AcceptTransactionSet([]types.Transaction{txn})
    30  	if err != modules.ErrLargeTransaction {
    31  		t.Fatal(err)
    32  	}
    33  
    34  	// Create a large transaction set and try to get it accepted.
    35  	var tset []types.Transaction
    36  	for i := 0; i <= modules.TransactionSetSizeLimit/10e3; i++ {
    37  		arbData := make([]byte, 10e3)
    38  		copy(arbData, modules.PrefixNonSia[:])
    39  		fastrand.Read(arbData[100:116]) // prevents collisions with other transacitons in the loop.
    40  		txn := types.Transaction{ArbitraryData: [][]byte{arbData}}
    41  		tset = append(tset, txn)
    42  	}
    43  	err = tpt.tpool.AcceptTransactionSet(tset)
    44  	if err != modules.ErrLargeTransactionSet {
    45  		t.Fatal(err)
    46  	}
    47  }