Skip to content

Commit

Permalink
Remove IsOwned class from specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
paolino committed May 30, 2023
1 parent 70cb7fa commit 9e98bdf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
Expand Up @@ -35,12 +35,15 @@ import Cardano.Wallet.Address.Derivation.Byron
import Cardano.Wallet.Address.DerivationSpec
()
import Cardano.Wallet.Address.Discovery
( GenChange (..), IsOurs (..), IsOwned (..), KnownAddresses (..) )
( GenChange (..), IsOurs (..), KnownAddresses (..) )
import Cardano.Wallet.Address.Discovery.Random
( RndState (..), findUnusedPath, mkRndState )
import Cardano.Wallet.Address.Keys.WalletKey
( publicKey )
import Cardano.Wallet.Address.States.IsOwned
( isOwned )
import Cardano.Wallet.Flavor
( KeyFlavorS (ByronKeyS), WalletFlavorS (ByronWallet) )
import Cardano.Wallet.Gen
( genMnemonic )
import Cardano.Wallet.Primitive.Passphrase
Expand Down Expand Up @@ -238,7 +241,7 @@ checkIsOurs GoldenTest{..} = do

checkIsOwned :: GoldenTest -> Expectation
checkIsOwned GoldenTest{..} = do
isOwned st (rndKey, pwd) addr' `shouldBe` expectation
isOwned ByronWallet st (rndKey, pwd) addr' `shouldBe` expectation
where
pwd = Passphrase ""
Right addr' = Address <$> convertFromBase Base16 addr
Expand Down Expand Up @@ -295,9 +298,9 @@ prop_derivedKeysAreOwned
-> Index 'WholeDomain 'CredFromKeyK
-> Property
prop_derivedKeysAreOwned (Rnd st rk pwd) (Rnd st' rk' pwd') addrIx =
isOwned @_ @_ @'CredFromKeyK st (rk, pwd) addr === Just (addrKey, pwd)
isOwned ByronWallet st (rk, pwd) addr === Just (addrKey, pwd)
.&&.
isOwned @_ @_ @'CredFromKeyK st' (rk', pwd') addr === Nothing
isOwned ByronWallet st' (rk', pwd') addr === Nothing
where
addr = paymentAddress SMainnet (publicKey ByronKeyS addrKey)
addrKey = deriveAddressPrivateKey pwd acctKey addrIx
Expand Down
Expand Up @@ -50,7 +50,6 @@ import Cardano.Wallet.Address.Discovery
, GenChange (..)
, GetPurpose
, IsOurs (..)
, IsOwned (..)
, KnownAddresses (..)
, emptyPendingIxs
, genChange
Expand All @@ -76,8 +75,10 @@ import Cardano.Wallet.Address.Keys.WalletKey
( publicKey )
import Cardano.Wallet.Address.PoolSpec
( genPool, shrinkPool )
import Cardano.Wallet.Address.States.IsOwned
( isOwned )
import Cardano.Wallet.Flavor
( KeyFlavorS (..) )
( KeyFlavorS (..), WalletFlavorS (ShelleyWallet) )
import Cardano.Wallet.Primitive.Types.Address
( Address (..), AddressState (..) )
import Cardano.Wallet.Read.NetworkId
Expand Down Expand Up @@ -309,7 +310,7 @@ prop_lookupDiscovered (s0, addr) =
mw = someDummyMnemonic (Proxy @12)
key = Shelley.unsafeGenerateKeyFromSeed (mw, Nothing) mempty
prop s = monadicIO $ liftIO $ do
unless (isJust $ isOwned @_ @_ @'CredFromKeyK s (key, mempty) addr) $ do
unless (isJust $ isOwned ShelleyWallet s (key, mempty) addr) $ do
expectationFailure "couldn't find private key corresponding to addr"

{-------------------------------------------------------------------------------
Expand Down
20 changes: 2 additions & 18 deletions lib/wallet/test/unit/Cardano/WalletSpec.hs
Expand Up @@ -46,24 +46,16 @@ import Cardano.Wallet
import Cardano.Wallet.Address.Derivation
( Depth (..)
, DerivationIndex (..)
, DerivationIndex (..)
, DerivationType (..)
, HardDerivation (..)
, HardDerivation (..)
, Index (..)
, Index (..)
, Role (..)
, Role (..)
, deriveAccountPrivateKey
)
import Cardano.Wallet.Address.Derivation.Shelley
( ShelleyKey (..), generateKeyFromSeed )
import Cardano.Wallet.Address.Discovery
( CompareDiscovery (..)
, GenChange (..)
, IsOurs (..)
, IsOwned (..)
, KnownAddresses (..)
)
( CompareDiscovery (..), GenChange (..), IsOurs (..), KnownAddresses (..) )
import Cardano.Wallet.Address.Keys.WalletKey
( publicKey )
import Cardano.Wallet.Address.States.Features
Expand Down Expand Up @@ -1379,14 +1371,6 @@ instance IsOurs DummyState Address where

instance IsOurs DummyState RewardAccount where
isOurs _ s = (Nothing, s)

instance IsOwned DummyState ShelleyKey 'CredFromKeyK where
isOwned (TestState m) (rootK, pwd) addr = do
ix <- Map.lookup addr m
let accXPrv = deriveAccountPrivateKey pwd rootK minBound
let addrXPrv = deriveAddressPrivateKey pwd accXPrv UtxoExternal ix
return (addrXPrv, pwd)

instance GenChange DummyState where
type ArgGenChange DummyState = ()
genChange _ s = (Address "dummy", s)
Expand Down

0 comments on commit 9e98bdf

Please sign in to comment.