try reduce stack size in test

This commit is contained in:
Etan Kissling 2024-06-21 18:36:54 +02:00
parent 0d89dcd363
commit c0d07e1b24
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
1 changed files with 33 additions and 29 deletions

View File

@ -146,22 +146,35 @@ suite "Light client processor" & preset():
proc applyPeriodWithoutSupermajority( proc applyPeriodWithoutSupermajority(
period: SyncCommitteePeriod, update: ref ForkedLightClientUpdate) = period: SyncCommitteePeriod, update: ref ForkedLightClientUpdate) =
for i in 0 ..< 2: for i in 0 ..< 2:
res = processor[].storeObject( # Reduce stack size by making this a `proc`
MsgSource.gossip, getBeaconTime(), update[]) proc applyInitial(update: ref ForkedLightClientUpdate) =
check update[].kind <= store[].kind res = processor[].storeObject(
if finalizationMode == LightClientFinalizationMode.Optimistic or MsgSource.gossip, getBeaconTime(), update[])
period == lastPeriodWithSupermajority + 1: check update[].kind <= store[].kind
if finalizationMode == LightClientFinalizationMode.Optimistic or if finalizationMode == LightClientFinalizationMode.Optimistic or
i == 0: period == lastPeriodWithSupermajority + 1:
withForkyStore(store[]): if finalizationMode == LightClientFinalizationMode.Optimistic or
when lcDataFork > LightClientDataFork.None: i == 0:
let upgraded = newClone( withForkyStore(store[]):
update[].migratingToDataFork(lcDataFork)) when lcDataFork > LightClientDataFork.None:
template forkyUpdate: untyped = upgraded[].forky(lcDataFork) let upgraded = newClone(
check: update[].migratingToDataFork(lcDataFork))
res.isOk template forkyUpdate: untyped = upgraded[].forky(lcDataFork)
forkyStore.best_valid_update.isSome check:
forkyStore.best_valid_update.get.matches(forkyUpdate) 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: else:
withForkyStore(store[]): withForkyStore(store[]):
when lcDataFork > LightClientDataFork.None: when lcDataFork > LightClientDataFork.None:
@ -170,20 +183,11 @@ suite "Light client processor" & preset():
template forkyUpdate: untyped = upgraded[].forky(lcDataFork) template forkyUpdate: untyped = upgraded[].forky(lcDataFork)
check: check:
res.isErr res.isErr
res.error == VerifierError.Duplicate res.error == VerifierError.MissingParent
forkyStore.best_valid_update.isSome forkyStore.best_valid_update.isSome
forkyStore.best_valid_update.get.matches(forkyUpdate) not forkyStore.best_valid_update.get.matches(forkyUpdate)
else:
withForkyStore(store[]): applyInitial(update)
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)
# Reduce stack size by making this a `proc` # Reduce stack size by making this a `proc`
proc applyDuplicate(update: ref ForkedLightClientUpdate) = proc applyDuplicate(update: ref ForkedLightClientUpdate) =