Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stackdump committed Oct 25, 2018
1 parent 9882586 commit c58c48e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions engine/factomd_test.go
Expand Up @@ -1575,7 +1575,7 @@ func TestProcessedBlockFailure(t *testing.T) {
"FA3TXHciP5BuuHXpK1q2RU8RRjvVWtFirqbbfwiNmuemz6k4s9GC",
}

var maxBlocks = 30
var maxBlocks = 15
var depositCount int = 0

waitForDeposit := func(i int, amt uint64) uint64 {
Expand All @@ -1591,6 +1591,10 @@ func TestProcessedBlockFailure(t *testing.T) {
return uint64(balance)
}

// REVIEW: test seems to fail reliably when this delay is set to 100ms - goes away at 300ms
// meaning both addresses show a balance > 0 at the same time
interval := time.Duration(100*time.Millisecond) // ms

mkTransactions := func(waitBlock int, waitMinute int) { // txnGenerator
WaitForBlock(state0, waitBlock)
WaitForMinute(state0, waitMinute)
Expand All @@ -1604,7 +1608,7 @@ func TestProcessedBlockFailure(t *testing.T) {

println("->ping-pong<-")

for state0.LLeaderHeight < uint32(maxBlocks-10) && bal > oneFct {
for state0.LLeaderHeight < uint32(maxBlocks-5) && bal > oneFct {

bal = bal - fee
pingBal := bal
Expand All @@ -1614,9 +1618,7 @@ func TestProcessedBlockFailure(t *testing.T) {
ping := func() { sendTxn(state0, pingBal, depositSecrets[0], depositAddresses[1], ecPrice) }
pong := func() { sendTxn(state0, pongBal, depositSecrets[1], depositAddresses[0], ecPrice) }

// REVIEW: test fails when this timeout is set too low
// meaning both addresses show a balance > 0 at the same time
delay := func() { time.Sleep(time.Millisecond * 300) }
delay := func() { time.Sleep(interval) }

if random.RandInt()%2 == 0 {
// in order
Expand All @@ -1638,13 +1640,18 @@ func TestProcessedBlockFailure(t *testing.T) {

bal0 := getBalance(state0, depositAddresses[0])
bal1 := getBalance(state0, depositAddresses[1])
fmt.Printf(" %v => %v\n", depositAddresses[0], bal0)
fmt.Printf(" %v => %v\n", depositAddresses[1], bal1)

if bal0 > bal1 {
AssertEquals(t, bal1, int64(0))
} else {
AssertEquals(t, bal0, int64(0))
}

// TODO: try to read journal or other source of txn data
// test to see which txn started the problem

WaitForAllNodes(state0)
shutDownEverything(t)
}
Expand Down

0 comments on commit c58c48e

Please sign in to comment.