cli: fix TestAwaitUtilCancelTx failing

Occasionally the block is being accepted right after main transaction
submission. Added two branches into this TestAwaitUtilCancelTx. One
branch handles the case of original transaction acceptance, the
other branch handles the conflicting transaction acceptance.

Close #3365

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-03-20 14:16:04 +03:00
parent b028c772f2
commit d80e14dcbb

View file

@ -3,6 +3,7 @@ package util_test
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"strings"
"testing" "testing"
"time" "time"
@ -169,11 +170,22 @@ func TestAwaitUtilCancelTx(t *testing.T) {
e.In.WriteString("one\r") e.In.WriteString("one\r")
e.Run(t, append(args, txHash.StringLE())...) e.Run(t, append(args, txHash.StringLE())...)
e.CheckNextLine(t, "Conflicting transaction accepted")
resHash, _ := e.CheckAwaitableTxPersisted(t)
require.Eventually(t, func() bool { response := e.GetNextLine(t)
_, aerErr := e.Chain.GetAppExecResults(resHash.Hash(), trigger.Application) if strings.Contains(response, "Conflicting transaction accepted") {
return aerErr == nil resHash, _ := e.CheckAwaitableTxPersisted(t)
}, time.Second*2, time.Millisecond*50) require.Eventually(t, func() bool {
_, aerErr := e.Chain.GetAppExecResults(resHash.Hash(), trigger.Application)
return aerErr == nil
}, time.Second*2, time.Millisecond*50)
} else if strings.Contains(response, "Target transaction accepted") {
require.Eventually(t, func() bool {
_, _, err := e.Chain.GetTransaction(txHash)
require.NoError(t, err, "original transaction should be on chain")
_, aerErr := e.Chain.GetAppExecResults(txHash, trigger.Application)
return aerErr == nil
}, time.Second*2, time.Millisecond*50)
} else {
t.Fatalf("unexpected response: %s", response)
}
} }