Skip to content

Commit

Permalink
core/chains/evm/txmgr: fix race by waiting for goroutines to complete (
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Dec 14, 2023
1 parent 7773d03 commit e12a38c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions core/chains/evm/txmgr/confirmer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2984,13 +2984,19 @@ func TestEthConfirmer_ResumePendingRuns(t *testing.T) {

pgtest.MustExec(t, db, `UPDATE evm.txes SET pipeline_task_run_id = $1, min_confirmations = $2, signal_callback = TRUE WHERE id = $3`, &tr.ID, minConfirmations, etx.ID)

done := make(chan struct{})
t.Cleanup(func() { <-done })
go func() {
defer close(done)
err2 := ec.ResumePendingTaskRuns(testutils.Context(t), &head)
require.NoError(t, err2)
if !assert.NoError(t, err2) {
return
}
// Retrieve Tx to check if callback completed flag was set to true
updateTx, err3 := txStore.FindTxWithSequence(testutils.Context(t), fromAddress, nonce)
require.NoError(t, err3)
require.Equal(t, true, updateTx.CallbackCompleted)
if assert.NoError(t, err3) {
assert.Equal(t, true, updateTx.CallbackCompleted)
}
}()

select {
Expand Down Expand Up @@ -3032,13 +3038,19 @@ func TestEthConfirmer_ResumePendingRuns(t *testing.T) {

pgtest.MustExec(t, db, `UPDATE evm.txes SET pipeline_task_run_id = $1, min_confirmations = $2, signal_callback = TRUE WHERE id = $3`, &tr.ID, minConfirmations, etx.ID)

done := make(chan struct{})
t.Cleanup(func() { <-done })
go func() {
defer close(done)
err2 := ec.ResumePendingTaskRuns(testutils.Context(t), &head)
require.NoError(t, err2)
if !assert.NoError(t, err2) {
return
}
// Retrieve Tx to check if callback completed flag was set to true
updateTx, err3 := txStore.FindTxWithSequence(testutils.Context(t), fromAddress, nonce)
require.NoError(t, err3)
require.Equal(t, true, updateTx.CallbackCompleted)
if assert.NoError(t, err3) {
assert.Equal(t, true, updateTx.CallbackCompleted)
}
}()

select {
Expand Down

0 comments on commit e12a38c

Please sign in to comment.