github.com/johnathanhowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/modules/transactionpool/standard_test.go (about) 1 package transactionpool 2 3 import ( 4 "crypto/rand" 5 "testing" 6 7 "github.com/NebulousLabs/Sia/modules" 8 "github.com/NebulousLabs/Sia/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("TestIntegrationLargeTransaction") 19 if err != nil { 20 t.Fatal(err) 21 } 22 23 // Create a large transaction and try to get it accepted. 24 arbData := make([]byte, modules.TransactionSizeLimit) 25 copy(arbData, modules.PrefixNonSia[:]) 26 _, err = rand.Read(arbData[100:116]) // prevents collisions with other transacitons in the loop. 27 if err != nil { 28 t.Fatal(err) 29 } 30 txn := types.Transaction{ArbitraryData: [][]byte{arbData}} 31 err = tpt.tpool.AcceptTransactionSet([]types.Transaction{txn}) 32 if err != modules.ErrLargeTransaction { 33 t.Fatal(err) 34 } 35 36 // Create a large transaction set and try to get it accepted. 37 var tset []types.Transaction 38 for i := 0; i <= modules.TransactionSetSizeLimit/10e3; i++ { 39 arbData := make([]byte, 10e3) 40 copy(arbData, modules.PrefixNonSia[:]) 41 _, err = rand.Read(arbData[100:116]) // prevents collisions with other transacitons in the loop. 42 if err != nil { 43 t.Fatal(err) 44 } 45 txn := types.Transaction{ArbitraryData: [][]byte{arbData}} 46 tset = append(tset, txn) 47 } 48 err = tpt.tpool.AcceptTransactionSet(tset) 49 if err != modules.ErrLargeTransactionSet { 50 t.Fatal(err) 51 } 52 }