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 property test for UTxOIndex.selectRandomWithPriority. #2667

Merged
merged 3 commits into from
May 26, 2021

Conversation

jonathanknowles
Copy link
Member

@jonathanknowles jonathanknowles commented May 25, 2021

Issue Number

ADP-890

Overview

This PR adds a property test for UTxOIndex.selectRandomWithPriority.

The selectRandomWithPriority function is designed to:

  • select an entry at random from a UTxO index according to a specified list of filter conditions;
  • traverse the specified list of filter conditions in order of priority from left to right.

The test added in this PR provides a basic sanity check to verify that priority order is respected.

Sample Output

Cardano.Wallet.Primitive.Types.UTxOIndex
  Indexed UTxO set properties
    Index Selection
      prop_selectRandomWithPriority
        +++ OK, passed 1600 tests:
        59.69% have match for neither asset 1 nor asset 2
        17.12% have match for asset 1 but not for asset 2
        16.31% have match for asset 2 but not for asset 1
         6.88% have match for both asset 1 and asset 2

Finished in 1.0870 seconds
1 example, 0 failures

QA Due Diligence

I ran this test 500 times to increase confidence that it will not fail spuriously. No failures were encountered.

@jonathanknowles jonathanknowles self-assigned this May 25, 2021
This test provides a basic sanity check to verify that priority order is
respected when searching through a UTxO index with more than one filter.
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/test-selectRandomWithPriority branch from 29c6070 to c33245a Compare May 25, 2021 09:29
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/test-selectRandomWithPriority branch from 853a030 to fda37ca Compare May 25, 2021 09:40
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

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

👌

--
prop_selectRandomWithPriority :: UTxOIndex -> Property
prop_selectRandomWithPriority u =
forAll (genAssetIdSmallRange) $ \a1 ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering, are the two levels of forAll essential, or can one AssetId be a function parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, the first level could be replaced with a function parameter.

However, by using forAll for both, it's easy to see (at a glance) that both asset ids come from the same generator.

@jonathanknowles
Copy link
Member Author

bors r+

iohk-bors bot added a commit that referenced this pull request May 25, 2021
2665: Add basic latency benchmarks for migrations r=piotr-iohk a=piotr-iohk

# Issue Number

ADP-680


# Overview

- 2c31861
  Add basic latency benchmarks for migrations


# Comments

[Migration Plan](http://cardano-wallet-benchmarks.herokuapp.com/latency?latency_category=4&latency_benchmark=all&latency_measurement=postMigrationPlan)
[Migration](http://cardano-wallet-benchmarks.herokuapp.com/latency?latency_category=4&latency_benchmark=all&latency_measurement=postMigration)


2667: Add property test for `UTxOIndex.selectRandomWithPriority`. r=jonathanknowles a=jonathanknowles

# Issue Number

ADP-890

# Overview

This PR adds a property test for `UTxOIndex.selectRandomWithPriority`.

The `selectRandomWithPriority`  function is designed to:
- select an entry at random from a UTxO index according to a specified list of filter conditions;
- traverse the specified list of filter conditions in order of priority **_from left to right_**.

The test added in this PR provides a basic sanity check to verify that priority order is respected.

# Sample Output

```hs
Cardano.Wallet.Primitive.Types.UTxOIndex
  Indexed UTxO set properties
    Index Selection
      prop_selectRandomWithPriority
        +++ OK, passed 1600 tests:
        59.69% have match for neither asset 1 nor asset 2
        17.12% have match for asset 1 but not for asset 2
        16.31% have match for asset 2 but not for asset 1
         6.88% have match for both asset 1 and asset 2

Finished in 1.0870 seconds
1 example, 0 failures
```

# QA Due Diligence

I ran this test 500 times to increase confidence that it will not fail spuriously. No failures were encountered.


Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 25, 2021

Build failed (retrying...):

Timed out here: (https://hydra.iohk.io/build/6471029/nixlog/6/tail)

     CONNECT /wallets/0000000000000000000000000000000000000000/signatures/utxo_internal/2147483647
     TRACE /wallets/0000000000000000000000000000000000000000/signatures/utxo_internal/2147483647
     OPTIONS /wallets/0000000000000000000000000000000000000000/signatures/utxo_internal/2147483647
     PUT /wallets/0000000000000000000000000000000000000000/statistics/utxos
     POST /wallets/0000000000000000000000000000000000000000/statistics/utxos
     PATCH /wallets/0000000000000000000000000000000000000000/statistics/utxos
     DELETE /wallets/0000000000000000000000000000000000000000/statistics/utxos
     CONNECT /wallets/0000000000000000000000000000000000000000/statistics/utxos
     TRACE /wallets/0000000000000000000000000000000000000000/statistics/utxos
     OPTIONS /wallets/0000000000000000000000000000000000000000/statistics/utxos
     PUT /wallets/0000000000000000000000000000000000000000/transactions
     PATCH /wallets/0000000000000000000000000000000000000000/transactions
     DELETE /wallets/0000000000000000000000000000000000000000/transactions
     CONNECT /wallets/0000000000000000000000000000000000000000/transactions
     TRACE /wallets/0000000000000000000000000000000000000000/transactions
     OPTIONS /wallets/0000000000000000000000000000000000000000/transactions
     PUT /wallets/0000000000000000000000000000000000000000/transactions/0000000000000000000000000000000000000000000000000000000000000000
     POST /wallets/0000000000000000000000000000000000000000/transactions/0000000000000000000000000000000000000000000000000000000000000000
building of '/nix/store/9a0r43q276bai4psmncksjxkfyl3ably-cardano-wallet-core-test-unit-2021.4.28-check' timed out after 900 seconds of silence

#2472

iohk-bors bot added a commit that referenced this pull request May 25, 2021
2663: Improve shared wallets r=paweljakubas a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. -->
adp-934

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Adding "incomplete" to status for pending shared wallets
- [x] comprehensive validation of script templates when posting them
- [x] integration testing of validation of script templates
- [x] add GET /shared-wallets/wid/keys and whole infrastructure
- [x] add GET /wallets/wid/keys
- [x] unite ApiVerificationKeyShelley and ApiVerificationKeyShared and hence enable with/without hashing capability for shelley style
- [x] better reuse of code in Api.Link
- [x] test new endpoints

# Comments
Prerequisite : IntersectMBO/cardano-addresses#131

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


2667: Add property test for `UTxOIndex.selectRandomWithPriority`. r=jonathanknowles a=jonathanknowles

# Issue Number

ADP-890

# Overview

This PR adds a property test for `UTxOIndex.selectRandomWithPriority`.

The `selectRandomWithPriority`  function is designed to:
- select an entry at random from a UTxO index according to a specified list of filter conditions;
- traverse the specified list of filter conditions in order of priority **_from left to right_**.

The test added in this PR provides a basic sanity check to verify that priority order is respected.

# Sample Output

```hs
Cardano.Wallet.Primitive.Types.UTxOIndex
  Indexed UTxO set properties
    Index Selection
      prop_selectRandomWithPriority
        +++ OK, passed 1600 tests:
        59.69% have match for neither asset 1 nor asset 2
        17.12% have match for asset 1 but not for asset 2
        16.31% have match for asset 2 but not for asset 1
         6.88% have match for both asset 1 and asset 2

Finished in 1.0870 seconds
1 example, 0 failures
```

# QA Due Diligence

I ran this test 500 times to increase confidence that it will not fail spuriously. No failures were encountered.


Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
Co-authored-by: IOHK <devops+stack-project@iohk.io>
Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 25, 2021

Build failed (retrying...):

Failures:

Failures:
cardano-wallet
  src/Cardano/Wallet/Api/Link.hs:805:22:
  1) API Specifications, SHELLEY_ADDRESSES, ANY_ADDRESS_POST_12 - Delegating addresses API roundtrip
       uncaught exception: ErrorCall
       Endpoint not supported for Byron style
       CallStack (from HasCallStack):
         error, called at src/Cardano/Wallet/Api/Link.hs:805:22 in cardano-wallet-core-2021.4.28-LwkizIwcg0kGnSbU2S7JK:Cardano.Wallet.Api.Link
cardano-wallet
  To rerun use: --match "/API Specifications/SHELLEY_ADDRESSES/ANY_ADDRESS_POST_12 - Delegating addresses API roundtrip/"
cardano-wallet
  src/Cardano/Wallet/Api/Link.hs:805:22:
  2) API Specifications, SHELLEY_ADDRESSES, POST_ACCOUNT_01 - Can retrieve account public keys
       uncaught exception: ErrorCall
       Endpoint not supported for Byron style
       CallStack (from HasCallStack):
         error, called at src/Cardano/Wallet/Api/Link.hs:805:22 in cardano-wallet-core-2021.4.28-LwkizIwcg0kGnSbU2S7JK:Cardano.Wallet.Api.Link
cardano-wallet
  To rerun use: --match "/API Specifications/SHELLEY_ADDRESSES/POST_ACCOUNT_01 - Can retrieve account public keys/"
cardano-wallet
  src/Cardano/Wallet/Api/Link.hs:805:22:
  3) API Specifications, SHELLEY_WALLETS, WALLETS_GET_KEY_01 - golden tests for verification key
       uncaught exception: ErrorCall
       Endpoint not supported for Byron style
       CallStack (from HasCallStack):
         error, called at src/Cardano/Wallet/Api/Link.hs:805:22 in cardano-wallet-core-2021.4.28-LwkizIwcg0kGnSbU2S7JK:Cardano.Wallet.Api.Link
cardano-wallet
  To rerun use: --match "/API Specifications/SHELLEY_WALLETS/WALLETS_GET_KEY_01 - golden tests for verification key/"
cardano-wallet
  src/Cardano/Wallet/Api/Link.hs:805:22:
  4) API Specifications, SHELLEY_WALLETS, WALLETS_GET_KEY_02 - invalid index for verification key
       uncaught exception: ErrorCall
       Endpoint not supported for Byron style
       CallStack (from HasCallStack):
         error, called at src/Cardano/Wallet/Api/Link.hs:805:22 in cardano-wallet-core-2021.4.28-LwkizIwcg0kGnSbU2S7JK:Cardano.Wallet.Api.Link
cardano-wallet
  To rerun use: --match "/API Specifications/SHELLEY_WALLETS/WALLETS_GET_KEY_02 - invalid index for verification key/"
cardano-wallet
  src/Cardano/Wallet/Api/Link.hs:805:22:
  5) API Specifications, SHELLEY_WALLETS, WALLETS_GET_KEY_03 - unknown wallet
       uncaught exception: ErrorCall
       Endpoint not supported for Byron style
       CallStack (from HasCallStack):
         error, called at src/Cardano/Wallet/Api/Link.hs:805:22 in cardano-wallet-core-2021.4.28-LwkizIwcg0kGnSbU2S7JK:Cardano.Wallet.Api.Link
cardano-wallet
  To rerun use: --match "/API Specifications/SHELLEY_WALLETS/WALLETS_GET_KEY_03 - unknown wallet/"
cardano-wallet
  src/Cardano/Wallet/Api/Link.hs:805:22:
  6) API Specifications, SHELLEY_WALLETS, WALLETS_SIGNATURES_01 - can verify signature
       uncaught exception: ErrorCall
       Endpoint not supported for Byron style
       CallStack (from HasCallStack):
         error, called at src/Cardano/Wallet/Api/Link.hs:805:22 in cardano-wallet-core-2021.4.28-LwkizIwcg0kGnSbU2S7JK:Cardano.Wallet.Api.Link
cardano-wallet
  To rerun use: --match "/API Specifications/SHELLEY_WALLETS/WALLETS_SIGNATURES_01 - can verify signature/"
cardano-wallet
Randomized with seed 439611906
cardano-wallet
Finished in 1956.7943 seconds
796 examples, 6 failures, 12 pending

iohk-bors bot added a commit that referenced this pull request May 25, 2021
2667: Add property test for `UTxOIndex.selectRandomWithPriority`. r=jonathanknowles a=jonathanknowles

# Issue Number

ADP-890

# Overview

This PR adds a property test for `UTxOIndex.selectRandomWithPriority`.

The `selectRandomWithPriority`  function is designed to:
- select an entry at random from a UTxO index according to a specified list of filter conditions;
- traverse the specified list of filter conditions in order of priority **_from left to right_**.

The test added in this PR provides a basic sanity check to verify that priority order is respected.

# Sample Output

```hs
Cardano.Wallet.Primitive.Types.UTxOIndex
  Indexed UTxO set properties
    Index Selection
      prop_selectRandomWithPriority
        +++ OK, passed 1600 tests:
        59.69% have match for neither asset 1 nor asset 2
        17.12% have match for asset 1 but not for asset 2
        16.31% have match for asset 2 but not for asset 1
         6.88% have match for both asset 1 and asset 2

Finished in 1.0870 seconds
1 example, 0 failures
```

# QA Due Diligence

I ran this test 500 times to increase confidence that it will not fail spuriously. No failures were encountered.


Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 25, 2021

Build failed:

Timed out here: (https://hydra.iohk.io/build/6480715/nixlog/1/tail)

     TRACE /wallets/0000000000000000000000000000000000000000/signatures/utxo_internal/2147483647
     OPTIONS /wallets/0000000000000000000000000000000000000000/signatures/utxo_internal/2147483647
     PUT /wallets/0000000000000000000000000000000000000000/statistics/utxos
     POST /wallets/0000000000000000000000000000000000000000/statistics/utxos
     PATCH /wallets/0000000000000000000000000000000000000000/statistics/utxos
     DELETE /wallets/0000000000000000000000000000000000000000/statistics/utxos
     CONNECT /wallets/0000000000000000000000000000000000000000/statistics/utxos
     TRACE /wallets/0000000000000000000000000000000000000000/statistics/utxos
     OPTIONS /wallets/0000000000000000000000000000000000000000/statistics/utxos
     PUT /wallets/0000000000000000000000000000000000000000/transactions
     PATCH /wallets/0000000000000000000000000000000000000000/transactions
     DELETE /wallets/0000000000000000000000000000000000000000/transactions
     CONNECT /wallets/0000000000000000000000000000000000000000/transactions
     TRACE /wallets/0000000000000000000000000000000000000000/transactions
     OPTIONS /wallets/0000000000000000000000000000000000000000/transactions
     PUT /wallets/0000000000000000000000000000000000000000/transactions/0000000000000000000000000000000000000000000000000000000000000000
     POST /wallets/0000000000000000000000000000000000000000/transactions/0000000000000000000000000000000000000000000000000000000000000000
building of '/nix/store/39gkgp6y6mj2w08vasqdq8bq0lyvafwq-cardano-wallet-core-test-unit-2021.4.28-check' timed out after 900 seconds of silence

#2472

@jonathanknowles
Copy link
Member Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented May 26, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 76e9e94 into master May 26, 2021
@iohk-bors iohk-bors bot deleted the jonathanknowles/test-selectRandomWithPriority branch May 26, 2021 03:45
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

2 participants