Skip to content

Commit

Permalink
add incremental delay executing the first depost transaction by n tra…
Browse files Browse the repository at this point in the history
…nsactions
  • Loading branch information
stackdump committed Nov 1, 2018
1 parent 194bd49 commit 1d53e45
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions engine/factomd_test.go
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/FactomProject/factomd/common/messages"
"github.com/FactomProject/factomd/common/primitives/random"
"io/ioutil"
"math/rand"
"net/http"
"os"
"reflect"
Expand Down Expand Up @@ -2014,23 +2013,29 @@ func TestProcessedBlockFailure(t *testing.T) {
return transactions, bal, i
}

// offset to send initial blocking transaction
offset := 1

mkTransactions := func() { // txnGenerator
// fund the start address
sendTxn(state0, initialBalance, bankSecret, depositAddresses[0], ecPrice)
WaitMinutes(state0, 1)
waitForDeposit(0, initialBalance)
transactions, finalBalance, finalAddress := prepareTransactions(initialBalance)

var randomSeed int64 = time.Now().Unix()
var i int
var sent []int

r := rand.New(rand.NewSource(randomSeed))
for _, i = range r.Perm(len(transactions)) {
for i:=1; i<len(transactions); i++ {
sent = append(sent, i)
//fmt.Printf("offset: %v <=> i:%v", offset, i)
if i == offset {
fmt.Printf("\n==>TXN offset%v\n", offset)
transactions[0]() // unblock the transactions
}
transactions[i]()
}
fmt.Printf("send chained transations ordered by randomSeed : %v \n", randomSeed)
offset++ // next time start further in the future
fmt.Printf("send chained transations")
waitForDeposit(finalAddress, finalBalance)

// empty final address returning remaining funds to bank
Expand All @@ -2039,7 +2044,7 @@ func TestProcessedBlockFailure(t *testing.T) {
}
_ = mkTransactions

for i:= 0; i< 80; i++ {
for x:= 1; x<= 120; x++ {
mkTransactions()
WaitBlocks(state0, 1)
}
Expand Down

0 comments on commit 1d53e45

Please sign in to comment.