From c0d07e1b241679e0df7d9c824d11a79d3b65e9a1 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 21 Jun 2024 18:36:54 +0200 Subject: [PATCH] try reduce stack size in test --- tests/test_light_client_processor.nim | 62 ++++++++++++++------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/tests/test_light_client_processor.nim b/tests/test_light_client_processor.nim index 6d70c7bf7..308160325 100644 --- a/tests/test_light_client_processor.nim +++ b/tests/test_light_client_processor.nim @@ -146,22 +146,35 @@ suite "Light client processor" & preset(): proc applyPeriodWithoutSupermajority( period: SyncCommitteePeriod, update: ref ForkedLightClientUpdate) = for i in 0 ..< 2: - res = processor[].storeObject( - MsgSource.gossip, getBeaconTime(), update[]) - check update[].kind <= store[].kind - if finalizationMode == LightClientFinalizationMode.Optimistic or - period == lastPeriodWithSupermajority + 1: + # Reduce stack size by making this a `proc` + proc applyInitial(update: ref ForkedLightClientUpdate) = + res = processor[].storeObject( + MsgSource.gossip, getBeaconTime(), update[]) + check update[].kind <= store[].kind if finalizationMode == LightClientFinalizationMode.Optimistic or - i == 0: - withForkyStore(store[]): - when lcDataFork > LightClientDataFork.None: - let upgraded = newClone( - update[].migratingToDataFork(lcDataFork)) - template forkyUpdate: untyped = upgraded[].forky(lcDataFork) - check: - res.isOk - forkyStore.best_valid_update.isSome - forkyStore.best_valid_update.get.matches(forkyUpdate) + period == lastPeriodWithSupermajority + 1: + if finalizationMode == LightClientFinalizationMode.Optimistic or + i == 0: + withForkyStore(store[]): + when lcDataFork > LightClientDataFork.None: + let upgraded = newClone( + update[].migratingToDataFork(lcDataFork)) + template forkyUpdate: untyped = upgraded[].forky(lcDataFork) + check: + res.isOk + forkyStore.best_valid_update.isSome + forkyStore.best_valid_update.get.matches(forkyUpdate) + else: + withForkyStore(store[]): + when lcDataFork > LightClientDataFork.None: + let upgraded = newClone( + update[].migratingToDataFork(lcDataFork)) + template forkyUpdate: untyped = upgraded[].forky(lcDataFork) + check: + res.isErr + res.error == VerifierError.Duplicate + forkyStore.best_valid_update.isSome + forkyStore.best_valid_update.get.matches(forkyUpdate) else: withForkyStore(store[]): when lcDataFork > LightClientDataFork.None: @@ -170,20 +183,11 @@ suite "Light client processor" & preset(): template forkyUpdate: untyped = upgraded[].forky(lcDataFork) check: res.isErr - res.error == VerifierError.Duplicate + res.error == VerifierError.MissingParent forkyStore.best_valid_update.isSome - forkyStore.best_valid_update.get.matches(forkyUpdate) - else: - withForkyStore(store[]): - when lcDataFork > LightClientDataFork.None: - let upgraded = newClone( - update[].migratingToDataFork(lcDataFork)) - template forkyUpdate: untyped = upgraded[].forky(lcDataFork) - check: - res.isErr - res.error == VerifierError.MissingParent - forkyStore.best_valid_update.isSome - not forkyStore.best_valid_update.get.matches(forkyUpdate) + not forkyStore.best_valid_update.get.matches(forkyUpdate) + + applyInitial(update) # Reduce stack size by making this a `proc` proc applyDuplicate(update: ref ForkedLightClientUpdate) = @@ -387,4 +391,4 @@ suite "Light client processor" & preset(): check: res.isErr res.error == VerifierError.MissingParent - numOnStoreInitializedCalls == 0 \ No newline at end of file + numOnStoreInitializedCalls == 0