Skip to content

Commit

Permalink
use sentinel error
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jul 23, 2024
1 parent 0b18c92 commit dec172d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
// if all tests pass, cancel txs priority monitoring and check if tx priority is not correct in some blocks
logger.Print("⏳ e2e tests passed,checking tx priority")
monitorPriorityCancel()
if err := <-txPriorityErrCh; err != nil && !errors.Is(err, context.Canceled) {
if err := <-txPriorityErrCh; err != nil && errors.Is(err, errWrongTxPriority) {
logger.Print("❌ %v", err)
logger.Print("❌ e2e tests failed after %s", time.Since(testStartTime).String())
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion cmd/zetae2e/local/monitor_priority_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/zeta-chain/zetacore/e2e/config"
)

var errWrongTxPriority = errors.New("wrong tx priority, system tx not on top")

// monitorTxPriorityInBlocks checks for transaction priorities in blocks and reports errors
func monitorTxPriorityInBlocks(ctx context.Context, conf config.Config, errCh chan error) {
rpcClient, err := rpchttp.New(conf.RPCs.ZetaCoreRPC, "/websocket")
Expand Down Expand Up @@ -71,7 +73,7 @@ func processTx(txResult *coretypes.ResultTx, nonSystemTxFound *bool, errCh chan
if isMsgTypeURLSystemTx(attr) {
// a non system tx has been found in the block before a system tx
if *nonSystemTxFound {
errCh <- errors.New("wrong tx priority, system tx not on top")
errCh <- errWrongTxPriority
return
}
} else {
Expand Down

0 comments on commit dec172d

Please sign in to comment.