summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-07-16 23:07:59 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-07-16 23:07:59 +0200
commit1986e8f51b992edcc675e76edd5d1f85522b8e6d (patch)
tree23665421220b966c577c961a3cf3e5f919faaddc
parentcfdbb5b70abcede5e9ed980db5dd12a6764bb3f0 (diff)
Test: stored-roots command
-rw-r--r--src/Test.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Test.hs b/src/Test.hs
index 2a8e0df..df36556 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -33,6 +33,7 @@ import Service
import State
import Storage
import Storage.Internal (unsafeStoreRawBytes)
+import Storage.Merge
import Sync
@@ -177,6 +178,7 @@ type Command = CommandM ()
commands :: [(Text, Command)]
commands = map (T.pack *** id)
[ ("store", cmdStore)
+ , ("stored-roots", cmdStoredRoots)
, ("create-identity", cmdCreateIdentity)
, ("start-server", cmdStartServer)
, ("watch-local-identity", cmdWatchLocalIdentity)
@@ -198,6 +200,13 @@ cmdStore = do
ref <- liftIO $ unsafeStoreRawBytes st $ BL.fromChunks [encodeUtf8 otype, BC.singleton ' ', BC.pack (show $ B.length cnt), BC.singleton '\n', cnt]
cmdOut $ "store-done " ++ show (refDigest ref)
+cmdStoredRoots :: Command
+cmdStoredRoots = do
+ st <- asks tiStorage
+ [tref] <- asks tiParams
+ Just ref <- liftIO $ readRef st (encodeUtf8 tref)
+ cmdOut $ "stored-roots" ++ concatMap ((' ':) . show . refDigest . storedRef) (storedRoots $ wrappedLoad @Object ref)
+
cmdCreateIdentity :: Command
cmdCreateIdentity = do
st <- asks tiStorage