-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fingerprint to all asset models next to the policy_id and asset_name
Motivation, design and rationale explained in: cardano-foundation/CIPs#64
- Loading branch information
Showing
7 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
lib/core/test/unit/Cardano/Wallet/Primitive/Types/TokenPolicySpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
|
||
module Cardano.Wallet.Primitive.Types.TokenPolicySpec | ||
( spec | ||
) where | ||
|
||
import Prelude | ||
|
||
import Cardano.Wallet.Primitive.Types.Hash | ||
( Hash (..) ) | ||
import Cardano.Wallet.Primitive.Types.TokenPolicy | ||
( TokenFingerprint (..) | ||
, TokenName (..) | ||
, TokenPolicyId (..) | ||
, mkTokenFingerprint | ||
) | ||
import Cardano.Wallet.Unsafe | ||
( unsafeFromHex ) | ||
import Data.ByteString | ||
( ByteString ) | ||
import Data.Text | ||
( Text ) | ||
import Test.Hspec | ||
( Spec, SpecWith, describe, it, parallel, shouldBe ) | ||
|
||
import qualified Data.Text as T | ||
|
||
spec :: Spec | ||
spec = parallel $ describe "mkAssetFingerprint" $ do | ||
goldenTestCIP14 | ||
"7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373" | ||
"" | ||
"asset1rjklcrnsdzqp65wjgrg55sy9723kw09mlgvlc3" | ||
|
||
goldenTestCIP14 | ||
"7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc37e" | ||
"" | ||
"asset1nl0puwxmhas8fawxp8nx4e2q3wekg969n2auw3" | ||
|
||
goldenTestCIP14 | ||
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209" | ||
"" | ||
"asset1uyuxku60yqe57nusqzjx38aan3f2wq6s93f6ea" | ||
|
||
goldenTestCIP14 | ||
"7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373" | ||
"504154415445" | ||
"asset13n25uv0yaf5kus35fm2k86cqy60z58d9xmde92" | ||
|
||
goldenTestCIP14 | ||
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209" | ||
"504154415445" | ||
"asset1hv4p5tv2a837mzqrst04d0dcptdjmluqvdx9k3" | ||
|
||
goldenTestCIP14 | ||
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209" | ||
"7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373" | ||
"asset1aqrdypg669jgazruv5ah07nuyqe0wxjhe2el6f" | ||
|
||
goldenTestCIP14 | ||
"7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373" | ||
"1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209" | ||
"asset17jd78wukhtrnmjh3fngzasxm8rck0l2r4hhyyt" | ||
|
||
goldenTestCIP14 | ||
"7eae28af2208be856f7a119668ae52a49b73725e326dc16579dcc373" | ||
"0000000000000000000000000000000000000000000000000000000000000000" | ||
"asset1pkpwyknlvul7az0xx8czhl60pyel45rpje4z8w" | ||
|
||
goldenTestCIP14 | ||
:: ByteString -- Base16-encoded PolicyId | ||
-> ByteString -- Base16-encoded AssetName | ||
-> Text -- Bech32-encoded TokenFingerprint | ||
-> SpecWith () | ||
goldenTestCIP14 rawPolicyId rawAssetName rawFingerprint = | ||
it ("golden test CIP-0014 - " <> T.unpack rawFingerprint) $ do | ||
let policyId = UnsafeTokenPolicyId $ Hash $ unsafeFromHex rawPolicyId | ||
let assetName = UnsafeTokenName $ unsafeFromHex rawAssetName | ||
let fingerprint = UnsafeTokenFingerprint rawFingerprint | ||
mkTokenFingerprint policyId assetName `shouldBe` fingerprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks like the example doesn't match the pattern?