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

Add derivation path to api address #2598

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -82,6 +82,7 @@ import Web.HttpApiData
( ToHttpApiData (..) )

import qualified Cardano.Wallet.Api.Link as Link
import qualified Data.List.NonEmpty as NE
import qualified Network.HTTP.Types.Status as HTTP

spec :: forall n.
Expand All @@ -93,8 +94,8 @@ spec :: forall n.
) => SpecWith Context
spec = do
describe "BYRON_ADDRESSES" $ do
scenario_ADDRESS_LIST_01 @n emptyRandomWallet
scenario_ADDRESS_LIST_01 @n emptyIcarusWallet
scenario_ADDRESS_LIST_01 @n emptyRandomWallet 2
scenario_ADDRESS_LIST_01 @n emptyIcarusWallet 5

scenario_ADDRESS_LIST_02 @n fixtureRandomWallet
scenario_ADDRESS_LIST_02 @n fixtureIcarusWallet
Expand Down Expand Up @@ -122,14 +123,16 @@ scenario_ADDRESS_LIST_01
, EncodeAddress n
)
=> (Context -> ResourceT IO ApiByronWallet)
-> Int
-> SpecWith Context
scenario_ADDRESS_LIST_01 fixture = it title $ \ctx -> runResourceT $ do
scenario_ADDRESS_LIST_01 fixture derPathSize = it title $ \ctx -> runResourceT $ do
w <- fixture ctx
r <- request @[ApiAddress n] ctx (Link.listAddresses @'Byron w) Default Empty
verify r [ expectResponseCode HTTP.status200 ]
let n = length $ getFromResponse id r
forM_ [0..n-1] $ \addrIx -> do
expectListField addrIx #state (`shouldBe` ApiT Unused) r
expectListField addrIx #derivationPath (\derPath -> NE.length derPath `shouldBe` derPathSize) r
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

where
title = "ADDRESS_LIST_01 - Can list known addresses on a default wallet"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import Test.Integration.Framework.TestData
import qualified Cardano.Wallet.Api.Link as Link
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Lens as Aeson
import qualified Data.List.NonEmpty as NE
import qualified Data.Text as T
import qualified Network.HTTP.Types.Status as HTTP
import qualified Test.Hspec.Expectations.Lifted as Expectations
Expand Down Expand Up @@ -110,6 +111,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do
expectListSize g r
forM_ [0..(g-1)] $ \addrNum -> do
expectListField addrNum (#state . #getApiT) (`shouldBe` Unused) r
expectListField addrNum #derivationPath (\derPath -> NE.length derPath `shouldBe` 5) r

it "ADDRESS_LIST_01 - Can list addresses with non-default pool gap" $ \ctx -> runResourceT $ do
let g = 15
Expand Down
4 changes: 2 additions & 2 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1423,11 +1423,11 @@ components:
required:
- id
- state
- path_derivation
- derivation_path
properties:
id: *addressId
state: *addressState
path_derivation: *derivationPath
derivation_path: *derivationPath

ApiAddressInspect: &ApiAddressInspect
type: object
Expand Down