Skip to content

Commit

Permalink
plan out testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornkihlberg committed Mar 17, 2023
1 parent ffb4c62 commit ae812df
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
Expand Up @@ -2,21 +2,50 @@ module Language.Marlowe.Runtime.Transaction.ApiSpec
( spec
) where

-- import Language.Marlowe.Runtime.Transaction.Api (mkCIP25Metadata)

import Test.Hspec (Spec, describe, it, shouldBe)
import Test.Hspec (Spec, it)
import qualified Test.Hspec as Hspec

{-
TODO Ensure CIP-25 version 2 is supported
DOING Ensure CIP-25 version 2 is supported
- version 1 may be supported but don't waste effort on this
- ignore <other_properties> for now
TODO ensure that ToJSON and FromJSON are inverses of each other
DONE plan out test suite
DOING write tests
TODO piggy back on existing tests to check that FromJSON and ToJSON are inverses
TODO piggy back on existing tests to check serialization forms correct structure
TODO CIP25Metadata -> Metadata procedure
TODO Organize strings such that they are no longer than 64 characters long
TODO Reorganizes strings into lists of strings such that they are each no longer than 64 characters long
-}

spec :: Spec
spec = do
describe "mkCIP25Metadata" do
it "yo yo hey ho" do
5 `shouldBe` (4 :: Int)
Hspec.fdescribe "CIP-25 Metadata" do
Hspec.describe "version 1" do
it "Parses PolicyId as UTF-8 string" Hspec.pending
it "Parses TokenName as UTF-8 string" Hspec.pending
it "Interprets lack of version as version 1" Hspec.pending
it "Interprets version 1 as version 1" Hspec.pending
it "Rejects PolicyId longer than 64 characters" Hspec.pending
it "Rejects TokenName longer than 64 characters" Hspec.pending
Hspec.describe "version 2" do
it "Parses PolicyId as raw byte string" Hspec.pending
it "Parses TokenName as raw byte string" Hspec.pending
it "Interprets version 2 as version 2" Hspec.pending
it "Rejects PolicyId longer than 64 bytes" Hspec.pending
it "Rejects TokenName longer than 64 bytes" Hspec.pending
Hspec.describe "version 1 & 2 common" do
it "Ignores <other_properties>" Hspec.pending
it "Reorganizes strings into maximum 64 length strings" Hspec.pending
it "Rejects invalid version values" Hspec.pending
it "Serializes 0 files_details.src into [] representation" Hspec.pending
it "Serializes 1 files_details.src into 1 representation" Hspec.pending
it "Serializes * files_details.src into [*] representation" Hspec.pending
it "Serializes 0 metadata_details.image into [] representation" Hspec.pending
it "Serializes 1 metadata_details.image into 1 representation" Hspec.pending
it "Serializes * metadata_details.image into [*] representation" Hspec.pending
it "Serializes 0 metadata_details.description into no representation" Hspec.pending
it "Serializes 1 metadata_details.description into 1 compact representation" Hspec.pending
it "Serializes * metadata_details.description into * compact representation" Hspec.pending
it "Serializes 0 metadata_details.files into compact no representation" Hspec.pending
it "Serializes 1 metadata_details.files into compact 1 representation" Hspec.pending
it "Serializes * metadata_details.files into compact * representation" Hspec.pending
Expand Up @@ -162,10 +162,8 @@ instance Aeson.ToJSON CIP25MetadataLabel where
toJSON = \case
CIP25MetadataLabel {version = Nothing, policyIds} -> toJSON policyIds
CIP25MetadataLabel {version = Just 1, policyIds = toJSON -> Aeson.Object policyIds} ->
-- // TODO test this to make sure it's correct!
Aeson.Object (policyIds <> [("version", Aeson.Number 1)])
CIP25MetadataLabel {version = Just 2, policyIds = toJSON -> Aeson.Object policyIds} ->
-- // TODO test this to make sure it's correct!
Aeson.Object (policyIds <> [("version", Aeson.Number 2)])
CIP25MetadataLabel {version = Just n} -> error $ "Unknown version " <> show n

Expand All @@ -177,7 +175,6 @@ instance Aeson.FromJSON CIP25MetadataLabel where
fail $ "Unknown version " <> (show $ Maybe.fromJust version)
pure $ CIP25MetadataLabel policyIds version

-- // TODO test this to make sure it's correct!
newtype CIP25Metadata = CIP25Metadata
{ transactionMetadatumLabel :: CIP25MetadataLabel
}
Expand Down

0 comments on commit ae812df

Please sign in to comment.