Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt CompatibilitySpec goldens to use & test singleAddressFromKey #435

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module Cardano.Wallet.Jormungandr.CompatibilitySpec

import Prelude


import Cardano.Crypto.Wallet
( ChainCode (..), XPub (..) )
import Cardano.Wallet.Jormungandr.Binary
( singleAddressFromKey )
import Cardano.Wallet.Jormungandr.Compatibility
( Jormungandr )
import Cardano.Wallet.Jormungandr.Environment
Expand Down Expand Up @@ -165,15 +170,18 @@ goldenTest
goldenTest proxy pubkeys expected = it ("golden test: " <> T.unpack expected) $ do
case traverse (convertFromBase Base16) pubkeys of
Right [spending] -> do
let payload = BS.pack [single @n] <> spending
let addr = encodeAddress proxy (Address payload)
let xpub = XPub spending chainCode
let rawAddr = singleAddressFromKey (Proxy @n) xpub
let addr = encodeAddress proxy rawAddr
addr `shouldBe` expected
Right [spending, delegation] -> do
let payload = BS.pack [grouped @n] <> spending <> delegation
let addr = encodeAddress proxy (Address payload)
addr `shouldBe` expected
_ ->
expectationFailure "goldenTest: provided invalid inputs public keys"
where
chainCode = ChainCode "<ChainCode is not used by singleAddressFromKey>"

{-------------------------------------------------------------------------------
Arbitrary Instances
Expand Down