Skip to content

Commit f84ce1f

Browse files
tbagrel1agustinmistaamesgengeo2anbacquey
committed
More refined precondition on PerasCertDB StateModel tests
Co-authored-by: Agustin Mista <agustin.mista@moduscreate.com> Co-authored-by: Alexander Esgen <alexander.esgen@iohk.io> Co-authored-by: Georgy Lukyanov <georgy.lukyanov@iohk.io> Co-authored-by: Thomas BAGREL <thomas.bagrel@tweag.io> Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io> Co-authored-by: Nicolas "Niols" Jeannerod <nicolas.jeannerod@moduscreate.com>
1 parent a15fda7 commit f84ce1f

File tree

1 file changed

+12
-1
lines changed
  • ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/PerasCertDB

1 file changed

+12
-1
lines changed

ouroboros-consensus/test/storage-test/Test/Ouroboros/Storage/PerasCertDB/StateMachine.hs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ instance StateModel Model where
113113

114114
precondition (Model model) = \case
115115
OpenDB -> not model.open
116-
_ -> model.open
116+
action ->
117+
model.open && case action of
118+
CloseDB -> True
119+
-- Equivocating certificates are not possible by construction,
120+
-- so we should ensure that adding a certificate with the same round
121+
-- number but different content is rejected.
122+
-- See https://tweag.github.io/cardano-peras/peras-design.pdf#subsection.2.2.2
123+
AddCert cert -> all p model.certs
124+
where
125+
p cert' = getPerasCertRound cert /= getPerasCertRound cert' || cert == cert'
126+
GetWeightSnapshot -> True
127+
GarbageCollect _slot -> True
117128

118129
deriving stock instance Show (Action Model a)
119130
deriving stock instance Eq (Action Model a)

0 commit comments

Comments
 (0)