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

Tx metadata API integration tests #2096

Merged
merged 3 commits into from
Sep 2, 2020
Merged

Tx metadata API integration tests #2096

merged 3 commits into from
Sep 2, 2020

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Sep 1, 2020

Issue Number

ADP-307 / #2074 / #2073.

Overview

  • API test case for posting a transaction with metadata.
  • Test creating a transaction with invalid metadata.
  • Test creating a transaction that's too large due to metadata.
  • Test that the transaction fee estimate is higher when there's metadata in the transaction.

Comments

@rvl rvl added the ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG label Sep 1, 2020
@rvl rvl added this to the (ADP-307) Transaction metadata milestone Sep 1, 2020
@rvl rvl self-assigned this Sep 1, 2020
@rvl rvl force-pushed the rvl/2074/tx-metadata-tests branch 2 times, most recently from cc515c5 to 57297c4 Compare September 1, 2020 14:17
@rvl rvl added this to In Progress in Adrestia Sep 1, 2020
@rvl rvl requested a review from piotr-iohk September 1, 2020 14:20
@rvl rvl force-pushed the rvl/2074/tx-metadata-tests branch from 57297c4 to a4a6d6a Compare September 1, 2020 14:21
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.

LGTM

@@ -229,6 +241,7 @@ spec = do
between (feeMin + amt, feeMax + amt)
, expectField (#direction . #getApiT) (`shouldBe` Outgoing)
, expectField (#status . #getApiT) (`shouldBe` Pending)
, expectField (#metadata . #getApiTxMetadata) (`shouldBe` Nothing)
Copy link
Member

Choose a reason for hiding this comment

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

👍

, expectListField 0
(#metadata . #getApiTxMetadata)
(`shouldBe` Just (ApiT expected))
]
Copy link
Member

Choose a reason for hiding this comment

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

👍


basePayload <- mkTxPayload ctx wb amt fixturePassphrase

let txMeta = Aeson.object ["1" .= T.replicate 65 "a"]
Copy link
Member

Choose a reason for hiding this comment

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

👍

let txMeta = Aeson.object
[ (toText @Int i, Aeson.String (T.replicate 64 "a"))
| i <- [0..1023] ]
let payload = addTxMetadata txMeta basePayload
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

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

lgtm.

There are few other cases come to my mind, pertaining to invalid metadata but maybe a bit more subtle:

  • top-level index > 2^64-1
{ 999999999999999999999999999999999999999999999999999999999999999999999999999999999: "ziemniak" }
  • hex that is not hex
{ 1: { "hex": "ąćó" } }
  • map that is not map
{ "1": [ [ "k1", "v1", "v2" ] ] }

I wonder would that produce invalid metadata error?

(Link.createTransaction @'Shelley wa) Default payload

expectResponseCode @IO HTTP.status400 r
expectErrorMessage "fixme: api validation error message" r
Copy link
Contributor

Choose a reason for hiding this comment

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

This message is unhappy, it's crying "fixme" ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I needed to run the tests first to find out what error message to expect. 🙂
Fixed now.

(Link.createTransaction @'Shelley wa) Default payload

expectResponseCode @IO HTTP.status400 r
expectErrorMessage "fixme: transaction rejected message" r
Copy link
Contributor

Choose a reason for hiding this comment

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

so does this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See latest update of the branch.
Turns out the error message for oversized transactions is not very good.
I think we should fix the error message - but in another PR.

Copy link
Member

Choose a reason for hiding this comment

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

Too late. I've done it in this PR 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks

@rvl rvl force-pushed the rvl/2074/tx-metadata-tests branch from d27f70e to dabe9e2 Compare September 2, 2020 11:19
@rvl rvl changed the base branch from rvl/2073/api-tx-metadata to rvl/2075/fee September 2, 2020 11:26
@rvl rvl marked this pull request as ready for review September 2, 2020 11:26
@KtorZ KtorZ force-pushed the rvl/2075/fee branch 2 times, most recently from c78df67 to b8ae9ca Compare September 2, 2020 14:38
@KtorZ KtorZ force-pushed the rvl/2074/tx-metadata-tests branch 2 times, most recently from 0a7665a to 01be0de Compare September 2, 2020 16:04
@KtorZ KtorZ changed the base branch from rvl/2075/fee to master September 2, 2020 16:06
@KtorZ
Copy link
Member

KtorZ commented Sep 2, 2020

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

iohk-bors bot added a commit that referenced this pull request Sep 2, 2020
2096: Tx metadata API integration tests r=KtorZ a=rvl

### Issue Number

ADP-307 / #2074 / #2073.

### Overview

- API test case for posting a transaction with metadata.
- Test creating a transaction with invalid metadata.
- Test creating a transaction that's too large due to metadata.
- Test that the transaction fee estimate is higher when there's metadata in the transaction.

### Comments

- Based on PR #2104 branch.

Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

22 similar comments
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

This PR was included in a batch with a merge conflict, it will be automatically retried

@rvl
Copy link
Contributor Author

rvl commented Sep 2, 2020

bors r-

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 2, 2020

Canceled

@rvl
Copy link
Contributor Author

rvl commented Sep 3, 2020

@piotr-iohk Thanks for the suggestions about test coverage for invalid metadata cases. I added a note to the QA section of #2073 about this.

These cases are covered in cardano-node/cardano-api/test/Test/Cardano/Api/MetaData.hs by property tests. So we only need one invalid metadata test (I chose one with a string that was too long) to test the API error path.

@piotr-iohk piotr-iohk moved this from In Progress to Closed in Adrestia Oct 6, 2020
@CharlesMorgan-IOHK CharlesMorgan-IOHK removed this from Closed in Adrestia Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants