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

Fix user facing encoding of stake pool ids (from base16 to bech32). #2055

Conversation

hasufell
Copy link
Contributor

@hasufell hasufell commented Aug 21, 2020

So I kept the legacy parsing for both json and the query params to not break API for existing users.

@hasufell hasufell requested a review from KtorZ August 21, 2020 15:38
@hasufell hasufell force-pushed the hasufell/2023/fix-user-facing-encoding branch 2 times, most recently from ca0f2bb to f563f17 Compare August 21, 2020 15:42
Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

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

Hi @hasufell.

Looks pretty good so far!

General comments:

  1. I'm not sure whether using MonadThrow in decodePoolIdBech32 gives us much advantage over Either TextDecodingError. It's harder for callers to see how the function will fail, as the type signature no longer includes TextDecodingError. But perhaps you have a good reason for using MonadThrow here?

  2. I couldn't find a roundtrip encoding/decoding test specifically for {decode,encode}PoolIdBech32. Did you intend to write one? I think it would be worth adding such a test. For inspiration, have a look at the various textRoundtrip tests.

  3. There are a few small issues with coding style. It's worth taking a look at our coding standards. These should hopefully be easy to fix. 👍

lib/core/src/Cardano/Wallet/Api/Types.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Wallet/Api/Types.hs Outdated Show resolved Hide resolved
lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs Outdated Show resolved Hide resolved
lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs Outdated Show resolved Hide resolved
lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Wallet/Primitive/Types.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Wallet/Primitive/Types.hs Outdated Show resolved Hide resolved
@jonathanknowles
Copy link
Member

Could you be more specific?

Sure! I was referring to the comments on the review. 👍

AFAIK, all the issues are mentioned in these comments.

@hasufell
Copy link
Contributor Author

Wrt the build failure... I cannot reproduce it.

Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

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

Hi @hasufell

Thanks for your changes. I see that you've converted decodePoolIdBech32 from using MonadThrow to returning an ordinary Either value, which I think makes the failure modes a bit clearer.

There are still a couple of issues I think we should fix:

  1. Roundtrip encoding tests: as mentioned in the previous review, I couldn't find a roundtrip property test for decodePoolIdBech32 and encodePoolIdBech32. Would it be okay to add one?

    I'm guessing that the following property should hold:

    decodePoolIdBech32 (encodePoolIdBech32 p) == Right p

    Note that we do have similar tests from which you can draw inspiration: have a search for textRoundtrip, and lots of stuff should pop up. Feel free to ask me if you need any assistance.

  2. Formatting: There are still a couple of formatting issues to sort out (see review comments).

Comment on lines +1102 to +1103
. bimap ShowFmt ApiT
. decodePoolIdBech32
Copy link
Member

Choose a reason for hiding this comment

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

Request: use 4-space indents.

See #2055 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please provide a formatter or an editor config that works. Otherwise these issues will pop up over and over again. I'm not counting spaces while I code.

Copy link
Member

Choose a reason for hiding this comment

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

@hasufell wrote:

Please provide a formatter or an editor config that works. Otherwise these issues will pop up over and over again.

Regarding automated formatting: Unfortunately our team doesn't use an automated formatter besides stylish-haskell (for imports), but if you feel strongly that we should do, then you could start a discussion in our team channel, and try to convince the team of the benefits. 👍

Regarding an editor config: We do provide one here.

@hasufell wrote:

I'm not counting spaces while I code.

Our team coding standard is actually rather simple in this respect: we just indent each level by 4 spaces. (We make an exception for where clauses, which are indented by 2 spaces.)

Are you facing an issue that makes it hard to indent in this way? If so, we can discuss ways to fix the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding automated formatting: Unfortunately our team doesn't use an automated formatter besides stylish-haskell (for imports), but if you feel strongly that we should do, then you could start a discussion in our team channel, and try to convince the team of the benefits. +1

I don't have a strong opinion, except that I avoid formatting discussions as much as possible. I'm just saying these things will pop up again if the tooling (formatter or config) doesn't work consistently. I don't think about indentation while coding and I am not counting spaces while doing so.

I also believe developers time is too valuable to count spaces in pull requests (your time and my time). I'll do whatever formatting you want, as long as I'm provided with the tools to do so.

Regarding an editor config: We do provide one here.

I'm using that one and it seems it doesn't work consistently. Help appreciated. Here is my editor config https://gogs.hasufell.de/hasufell/vim-config/src/branch/workman

Are you facing an issue that makes it hard to indent in this way? If so, we can discuss ways to fix the issue.

See above.

Copy link
Member

@jonathanknowles jonathanknowles Aug 25, 2020

Choose a reason for hiding this comment

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

@hasufell wrote:

I'll do whatever formatting you want, as long as I'm provided with the tools to do so.

I'm sorry, I don't have an automated tool to provide you with, otherwise I would. As I mentioned before, if there is a tool that you think we could use, then feel free to discuss it in the team channel. I would happy to help with the discussion!

I don't think about indentation while coding and I am not counting spaces while doing so.
I also believe developers time is too valuable to count spaces in pull requests (your time and my time).

The reason for having a team standard is so that we don't have to waste time during PR reviews debating code style. If we have to discuss this in every PR, it would certainly waste time.

As far as I know, most people in our team just configure their tab key to emit 4 spaces. Then no counting is required. Would that work for you?

Copy link
Member

Choose a reason for hiding this comment

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

@hasufell Just in case there's any doubt, we generally indent code with:

  • 4 spaces per level of nesting.
  • 2 spaces for a where clause.

Example:

launchMissiles trace a b c = do
    missiles <- prepareMissiles
    forM_ missiles $ \missile -> do
        log trace Warning $ MsgMissileLaunch missile        
        launchMissile missile
    pure missiles    
  where
    launchMissile m =
        inializeLauncherModule m
        lightFuse m
    prepareMissiles = do
        missiles <- enumerateMissiles
        verifyMissilesIntact missiles
        pure missiles

Copy link
Contributor Author

@hasufell hasufell Aug 26, 2020

Choose a reason for hiding this comment

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

Which constructs?

As was in my link to the haskell-vim readme.

So my configuration for haskell-vim now is

let g:haskell_indent_if = 0
let g:haskell_indent_case = 4
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 4
let g:haskell_indent_in = 0
let g:haskell_indent_guard = 2

This doesn't play nicely with do I believe. See below.


  • do
foo :: IO Int
foo = do
    x <- pure 1
    do
        pure (2 + x)
  • if
foo :: IO Int
foo =
    if True
    then pure 3
    else pure 2
  • case
foo :: IO Int
foo =
    case True of
        True -> 3
        False -> 2
  • let
foo :: IO Int
foo =
    let x = 3 in
        x + 1

foo :: IO Int
foo =
    let x = 1
    in x + 1
  • guard
foo :: IO Int
foo
  | otherwise = 2
  • where
foo :: IO Int
foo = x + 1
  where
    x = 3

So please either confirm this configuration or suggest an alternative.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any problem with do above ? Also, guards should be 4-space indented like the rest

let g:haskell_indent_guard = 4

Copy link
Contributor Author

@hasufell hasufell Aug 26, 2020

Choose a reason for hiding this comment

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

The problem with do is if you write something on the same line as do:

foo :: IO Int
foo = do
    x <- pure 1
    do y <- pure 2
        pure (x + y)

This will cause a compile error.

Copy link
Member

@KtorZ KtorZ Aug 26, 2020

Choose a reason for hiding this comment

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

That is arguably a horrible choice of formatting and It's perhaps much better that the compiler fails to parse this :)

@hasufell
Copy link
Contributor Author

1. As mentioned in the [previous review](https://github.com/input-output-hk/cardano-wallet/pull/2055#pullrequestreview-473111599), I couldn't find a roundtrip property test for `decodePoolIdBech32` and `encodePoolIdBech32`. Would it be okay to add one?

That has been done: b52ee3f

Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@hasufell hasufell force-pushed the hasufell/2023/fix-user-facing-encoding branch from 6ce8e9e to 433ea9b Compare August 27, 2020 09:43
@hasufell
Copy link
Contributor Author

bors r+

@hasufell
Copy link
Contributor Author

hasufell commented Aug 27, 2020

Can't reproduce the build failure, even with the given seed...

iohk-bors bot added a commit that referenced this pull request Aug 27, 2020
2055: Fix user facing encoding wrt #2023 r=hasufell a=hasufell

So I kept the legacy parsing for both json and the query params to not break API for existing users.

Co-authored-by: Julian Ospald <julian.ospald@iohk.io>
Co-authored-by: Julian Ospald <hasufell@posteo.de>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Aug 27, 2020

Build failed

@hasufell hasufell force-pushed the hasufell/2023/fix-user-facing-encoding branch from 433ea9b to e96b26b Compare August 27, 2020 11:53
@hasufell
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Aug 27, 2020
2055: Fix user facing encoding wrt #2023 r=hasufell a=hasufell

So I kept the legacy parsing for both json and the query params to not break API for existing users.

Co-authored-by: Julian Ospald <julian.ospald@iohk.io>
@KtorZ KtorZ changed the title Fix user facing encoding wrt #2023 Fix user facing encoding of stake pool ids (from base16 to bech32). Aug 27, 2020
Copy link
Member

@KtorZ KtorZ left a comment

Choose a reason for hiding this comment

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

actually, on second thoughts. I didn't see any tests that shows that:

a) hex-encoded pool ids are still accepted in path parameters
b) bech32 encoded pool ids are accepted in path parameters

@hasufell
Copy link
Contributor Author

a) hex-encoded pool ids are still accepted in path parameters

These are the tests that fail if hex encoding for path is disabled:

Failing tests

Failures:

  test/unit/Cardano/Wallet/ApiSpec.hs:137:42:
  1) Cardano.Wallet.Api, Malformed PathParam, (ApiT WalletId) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/śśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśśś
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"wallet id should be a hex-encoded string of 40 characters\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed PathParam/(ApiT WalletId) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347\347/"

  test/unit/Cardano/Wallet/ApiSpec.hs:137:42:
  2) Cardano.Wallet.Api, Malformed PathParam, (ApiT WalletId) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/111111111111111111111111111111111111111
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"wallet id should be a hex-encoded string of 40 characters\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed PathParam/(ApiT WalletId) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/111111111111111111111111111111111111111/"

  test/unit/Cardano/Wallet/ApiSpec.hs:137:42:
  3) Cardano.Wallet.Api, Malformed PathParam, (ApiT WalletId) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/11111111111111111111111111111111111111111
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"wallet id should be a hex-encoded string of 40 characters\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed PathParam/(ApiT WalletId) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/11111111111111111111111111111111111111111/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  4) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Error in $.passphrase: passphrase is too long: expected at most 255 characters\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  5) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Error in $.passphrase: parsing Text failed, expected String, but encountered Number\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  6) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Error in $.passphrase: parsing Text failed, expected String, but encountered Array\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  7) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Error in $.passphrase: parsing Text failed, expected String, but encountered Number\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  8) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Error in $: parsing Cardano.Wallet.Api.Types.ApiWalletPassphrase(ApiWalletPassphrase) failed, expected Object, but encountered Number\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  9) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Error in $: parsing Cardano.Wallet.Api.Types.ApiWalletPassphrase(ApiWalletPassphrase) failed, expected Object, but encountered String\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  10) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"trailing junk after valid JSON: endOfInput\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:142:42:
  11) Cardano.Wallet.Api, Malformed BodyParam, (ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected response body \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"I couldn't understand the content of your message. If your message is intended to be in JSON format, please check that the JSON is valid.\\\"}\", but received \"{\\\"code\\\":\\\"bad_request\\\",\\\"message\\\":\\\"Invalid stake pool id: expecting a Bech32 encoded value with human readable part of 'pool'.\\\"}\""

  To rerun use: --match "/Cardano.Wallet.Api/Malformed BodyParam/(ApiWalletPassphrase) PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:148:46:
  12) Cardano.Wallet.Api, Malformed Headers, ("Accept") PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 406, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Malformed Headers/(\"Accept\") PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:155:46:
  13) Cardano.Wallet.Api, Malformed Headers, ("Content-Type") PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 415, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Malformed Headers/(\"Content-Type\") PUT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  14) Cardano.Wallet.Api, Not Allowed Methods,  GET /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ GET /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  15) Cardano.Wallet.Api, Not Allowed Methods,  POST /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ POST /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  16) Cardano.Wallet.Api, Not Allowed Methods,  PATCH /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ PATCH /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  17) Cardano.Wallet.Api, Not Allowed Methods,  DELETE /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ DELETE /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  18) Cardano.Wallet.Api, Not Allowed Methods,  CONNECT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ CONNECT /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  19) Cardano.Wallet.Api, Not Allowed Methods,  TRACE /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ TRACE /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

  test/unit/Cardano/Wallet/ApiSpec.hs:162:42:
  20) Cardano.Wallet.Api, Not Allowed Methods,  OPTIONS /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000
       uncaught exception: WaiTestFailure
       WaiTestFailure "Expected status code 405, but received 400"

  To rerun use: --match "/Cardano.Wallet.Api/Not Allowed Methods/ OPTIONS /stake-pools/0000000000000000000000000000000000000000000000000000000000000000/wallets/0000000000000000000000000000000000000000/"

b) bech32 encoded pool ids are accepted in path parameters

I believe we just have to adjust this:

instance Wellformed (PathParam ApiPoolId) where
    wellformed = PathParam $ T.replicate 64 "0"

And add a bech32 param there.

@KtorZ
Copy link
Member

KtorZ commented Aug 27, 2020

I believe we just have to adjust this:

I don't think you can provide multiple well-formed data in here. But okay, pretty convincing for the hex backward-compability.
And I assume that the bech32 encoding is already covered by the integration tests using what's the API outputs.

@hasufell
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Aug 27, 2020

Build succeeded

@iohk-bors iohk-bors bot merged commit 7ddb43c into cardano-foundation:master Aug 27, 2020
iohk-bors bot added a commit that referenced this pull request Sep 1, 2020
2085: [ADP-416] Allow multiple well-formed values in "/Cardano.Wallet.Api/"… r=KtorZ a=hasufell

Related: #2055 (comment)

[Test log](https://gist.github.com/hasufell/c07ead1a20824bea6c20b2dc9b315bd4) shows that it tries both variants of pool id encodings when combined with #2055 

Co-authored-by: Julian Ospald <julian.ospald@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
hasufell added a commit to hasufell/cardano-wallet that referenced this pull request Sep 2, 2020
hasufell added a commit to hasufell/cardano-wallet that referenced this pull request Sep 2, 2020
iohk-bors bot added a commit that referenced this pull request Sep 3, 2020
2106: Add bech32 Pool id variant to Wellformed test r=KtorZ a=hasufell

Wrt #2085 and #2055

Co-authored-by: Julian Ospald <julian.ospald@iohk.io>
iohk-bors bot added a commit that referenced this pull request Sep 5, 2020
2105: Add test case for importing invalid addresses for Byron r=Anviking a=hasufell

#2011 

2106: Add bech32 Pool id variant to Wellformed test r=Anviking a=hasufell

Wrt #2085 and #2055

Co-authored-by: Julian Ospald <julian.ospald@iohk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants