summaryrefslogtreecommitdiff
path: root/src/Test.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-04-05 22:03:43 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-04-05 22:03:43 +0200
commit7a9ef992afa96ed177ae9a4a67d302017ab73852 (patch)
tree4c53058ce2ae8015db653326996bfc17a906e72e /src/Test.hs
parenta8893fbcfa06044e7f999916c4dcc6a2dc907f75 (diff)
Fix non-exhaustive pattern match warnings
Diffstat (limited to 'src/Test.hs')
-rw-r--r--src/Test.hs26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/Test.hs b/src/Test.hs
index 8ea8925..7b06831 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -375,8 +375,8 @@ cmdUpdateLocalIdentity :: Command
cmdUpdateLocalIdentity = do
[name] <- asks tiParams
updateLocalState_ $ \ls -> liftIO $ do
- let Just identity = validateIdentity $ lsIdentity $ fromStored ls
- st = storedStorage ls
+ Just identity <- return $ validateIdentity $ lsIdentity $ fromStored ls
+ let st = storedStorage ls
public = idKeyIdentity identity
Just secret <- loadKey public
@@ -390,16 +390,18 @@ cmdUpdateLocalIdentity = do
cmdUpdateSharedIdentity :: Command
cmdUpdateSharedIdentity = do
[name] <- asks tiParams
- updateSharedState_ $ \(Just identity) -> liftIO $ do
- let st = storedStorage $ head $ idDataF identity
- public = idKeyIdentity identity
-
- Just secret <- loadKey public
- maybe (error "created invalid identity") (return . Just . toComposedIdentity) . validateIdentity =<<
- wrappedStore st =<< sign secret =<< wrappedStore st (emptyIdentityData public)
- { iddPrev = toList $ idDataF identity
- , iddName = Just name
- }
+ updateSharedState_ $ \case
+ Nothing -> throwError "no existing shared identity"
+ Just identity -> liftIO $ do
+ let st = storedStorage $ head $ idDataF identity
+ public = idKeyIdentity identity
+
+ Just secret <- loadKey public
+ maybe (error "created invalid identity") (return . Just . toComposedIdentity) . validateIdentity =<<
+ wrappedStore st =<< sign secret =<< wrappedStore st (emptyIdentityData public)
+ { iddPrev = toList $ idDataF identity
+ , iddName = Just name
+ }
cmdAttachTo :: Command
cmdAttachTo = do