From d2a7162217e2c429600ff583690caeebc07e28a2 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 5 Mar 2024 17:46:00 +0300 Subject: [PATCH 1/2] notary: fix "Condition never satisfied" in Notary test, fix #2422 The theory is: * we add a block * it triggers notary * which can process the fallback before we're to setFinalizeWithError * it'll fail and require an additional block to enter, but it's never added * FAIL The solution is: * always add an additional block, but treat the first fb specially Signed-off-by: Roman Khimov --- pkg/services/notary/core_test.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/pkg/services/notary/core_test.go b/pkg/services/notary/core_test.go index 2a00651da..510eb45b5 100644 --- a/pkg/services/notary/core_test.go +++ b/pkg/services/notary/core_test.go @@ -600,22 +600,14 @@ func TestNotary(t *testing.T) { // Add block before allowing tx to finalize to exclude race condition when // main transaction is finalized between `finalizeWithError` restore and adding new block. e.AddNewBlock(t) - mtx.RLock() - start := len(completedTxes) - mtx.RUnlock() setFinalizeWithError(false) - for i := range requests { - if i != 0 { - e.AddNewBlock(t) - } - require.Eventually(t, func() bool { - mtx.RLock() - defer mtx.RUnlock() - return len(completedTxes)-start >= i+1 - }, time.Second*3, time.Millisecond) + for i := range requests[1:] { + e.AddNewBlock(t) + + _ = getCompletedTx(t, true, requests[i+1].FallbackTransaction.Hash()) checkMainTx(t, requesters, requests, len(requests), false) - checkFallbackTxs(t, requests[:i+1], true) - checkFallbackTxs(t, requests[i+1:], false) + checkFallbackTxs(t, requests[:i+2], true) + checkFallbackTxs(t, requests[i+2:], false) } // OnRequestRemoval: missing account From b2936e602c86d057ee45410aee92ee06b5468f56 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 5 Mar 2024 19:00:29 +0300 Subject: [PATCH 2/2] notary: fix getCompletedTx error It checks for any transaction given (like fb), not exactly the main one. Signed-off-by: Roman Khimov --- pkg/services/notary/core_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/notary/core_test.go b/pkg/services/notary/core_test.go index 510eb45b5..802cd4149 100644 --- a/pkg/services/notary/core_test.go +++ b/pkg/services/notary/core_test.go @@ -133,7 +133,7 @@ func TestNotary(t *testing.T) { defer mtx.RUnlock() completedTx = completedTxes[h] return completedTx != nil - }, time.Second*3, time.Millisecond*50, errors.New("main transaction expected to be completed")) + }, time.Second*3, time.Millisecond*50, errors.New("transaction expected to be completed")) return completedTx }