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 era-specific integration test assertions #2483

Merged
merged 3 commits into from
Feb 2, 2021

Conversation

Anviking
Copy link
Collaborator

@Anviking Anviking commented Feb 1, 2021

Issue Number

ADP-681

Overview

  • Add a _mainEra :: ApiEra to the test Context
  • GET /network/parameters eras object should be non-Nothing for byron .. mainEra, and Nothing for the rest.
  • GET /network/information node_era shouldBe mainEra
  • Remove redundant eventually

Comments

  • Do these tests actually cover a faulty implementation? -> Yes (if run manually on all eras)
    • When replacing QueryIfCurrentMary with QueryIfCurrentAllegra
      • LOCAL_CLUSTER_ERA=mary -> uncaught
      • LOCAL_CLUSTER_ERA=allegra caught (error below)
      • LOCAL_CLUSTER_ERA=shelley uncaught
       For era: ApiMary
       While verifying (Status {statusCode = 200, statusMessage = "OK"},Right (ApiNetworkParameters {genesisBlockHash = ApiT {getApiT = Hash "G\204\242\&0\STXQ\253D\STX&9\254\200\134\230\207\207\222\DC1\206\177B\201\175>\SUB\b\244\EMr/?"}, blockchainStartTime = ApiT {getApiT = StartTime 2021-02-01 13:07:11 UTC}, slotLength = Quantity {getQuantity = 0.2s}, epochLength = Quantity {getQuantity = 50}, securityParameter = Quantity {getQuantity = 5}, activeSlotCoefficient = Quantity {getQuantity = 50.0}, decentralizationLevel = Quantity {getQuantity = Percentage {getPercentage = 3 % 4}}, desiredPoolNumber = 3, minimumUtxoValue = Quantity {getQuantity = 1000000}, eras = ApiEraInfo {byron = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC}), shelley = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC}), allegra = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC}), mary = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC})}}))
       expected: Nothing
        but got: Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC})

@Anviking Anviking self-assigned this Feb 1, 2021
<$> poolConfigsFromEnv
<*> clusterEraFromEnv defaultEra
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this was intended for running the integration tests on multiple eras on the same run.

Now I want to retrieve the clusterEra independently.

Arguably, a localClusterConfigFromEnv :: ClusterEra -> IO LocalClusterConfig that doesn't use clusterEraFromEnv internally might be neater in that case, but 🤷‍♂️

@@ -416,9 +418,17 @@ data ClusterEra
| MaryHardFork
deriving (Show, Read, Eq, Ord, Bounded, Enum)

-- | Convert @ClusterEra@ to a @ApiEra@.
clusterToApiEra :: ClusterEra -> ApiEra
clusterToApiEra = \case
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could replace ClusterEra with ApiEra, but I think this is fine. Maybe they diverge sometime.

@Anviking Anviking force-pushed the anviking/ADP-681/era-specific-tests branch from 78c06ab to dd07b54 Compare February 1, 2021 13:28
@Anviking
Copy link
Collaborator Author

Anviking commented Feb 1, 2021

bors try

iohk-bors bot added a commit that referenced this pull request Feb 1, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 1, 2021

try

Build failed:

@Anviking Anviking force-pushed the anviking/ADP-681/era-specific-tests branch from dd07b54 to ed34ad0 Compare February 1, 2021 16:01
@Anviking
Copy link
Collaborator Author

Anviking commented Feb 1, 2021

bors try

iohk-bors bot added a commit that referenced this pull request Feb 1, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 1, 2021

try

Build failed:

Failures:

  src/Test/Integration/Scenario/API/Shelley/StakePools.hs:344:26:
  1) API Specifications, SHELLEY_STAKE_POOLS, STAKE_POOLS_JOIN_01rewards - Can join a pool, earn rewards and collect them
       While verifying (Status {statusCode = 200, statusMessage = "OK"},Right (ApiWallet {id = ApiT {getApiT = WalletId {getWalletId = 784e7fa829281cf1a6d4e9460f0d94b62e8e3af5}}, addressPoolGap = ApiT {getApiT = AddressPoolGap {getAddressPoolGap = 20}}, balance = ApiWalletBalance {available = Quantity {getQuantity = 999998086118}, total = Quantity {getQuantity = 1000004147054}, reward = Quantity {getQuantity = 6060936}}, assets = ApiWalletAssetsBalance {available = ApiT {getApiT = TokenMap (fromList [])}, total = ApiT {getApiT = TokenMap (fromList [])}}, delegation = ApiWalletDelegation {active = ApiWalletDelegationNext {status = Delegating, target = Just (ApiT {getApiT = PoolId {getPoolId = "\ESC=\193\156j\184\158\175\252\133\SOH\243u\187\ETX\193\ESC\248\237]\CAN76\177\216\EOT\DC3\214"}}), changesAt = Nothing}, next = []}, name = ApiT {getApiT = WalletName {getWalletName = "Faucet Wallet"}}, passphrase = Just (ApiWalletPassphraseInfo {lastUpdatedAt = 2021-02-01 17:26:02.683979 UTC}), state = ApiT {getApiT = Ready}, tip = ApiBlockReference {absoluteSlotNumber = ApiT {getApiT = SlotNo 5150}, slotId = ApiSlotId {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 103}}, slotNumber = ApiT {getApiT = SlotInEpoch {unSlotInEpoch = 0}}}, time = 2021-02-01 17:28:24 UTC, block = ApiBlockInfo {height = Quantity {getQuantity = 2547}}}}))
       Waited longer than 90s to resolve action: "Wallet has consumed rewards".
       expected: Quantity {getQuantity = 0}
        but got: Quantity {getQuantity = 6060936}

  To rerun use: --match "/API Specifications/SHELLEY_STAKE_POOLS/STAKE_POOLS_JOIN_01rewards - Can join a pool, earn rewards and collect them/"

The fork is at genesis. If the node has synced anything (which we should
be able to expect), then we shouldn't need the eventually.

A recent change in the NetworkLayer also causes the wallet to block
until it can retrieve the node's PParams, further decreasing the risk of
something unexpected being returned here.
@Anviking Anviking force-pushed the anviking/ADP-681/era-specific-tests branch from ed34ad0 to 78bef42 Compare February 1, 2021 18:11
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

@Anviking
Copy link
Collaborator Author

Anviking commented Feb 2, 2021

bors r+

iohk-bors bot added a commit that referenced this pull request Feb 2, 2021
2483: Add era-specific integration test assertions r=Anviking a=Anviking

# Issue Number

ADP-681


# Overview

- [x] Add a `_mainEra :: ApiEra` to the test `Context`
- [x] GET /network/parameters `eras` object should be non-Nothing for `byron .. mainEra`, and Nothing for the rest.
- [x] GET /network/information `node_era` `shouldBe` `mainEra`
- [x] Remove redundant eventually


# Comments

- [x] Do these tests _actually_ cover a faulty implementation? -> Yes (if run manually on all eras)
    - When replacing `QueryIfCurrentMary` with `QueryIfCurrentAllegra`
        - `LOCAL_CLUSTER_ERA=mary` -> uncaught
        - `LOCAL_CLUSTER_ERA=allegra` caught (error below)
        - `LOCAL_CLUSTER_ERA=shelley` uncaught 

```
       For era: ApiMary
       While verifying (Status {statusCode = 200, statusMessage = "OK"},Right (ApiNetworkParameters {genesisBlockHash = ApiT {getApiT = Hash "G\204\242\&0\STXQ\253D\STX&9\254\200\134\230\207\207\222\DC1\206\177B\201\175>\SUB\b\244\EMr/?"}, blockchainStartTime = ApiT {getApiT = StartTime 2021-02-01 13:07:11 UTC}, slotLength = Quantity {getQuantity = 0.2s}, epochLength = Quantity {getQuantity = 50}, securityParameter = Quantity {getQuantity = 5}, activeSlotCoefficient = Quantity {getQuantity = 50.0}, decentralizationLevel = Quantity {getQuantity = Percentage {getPercentage = 3 % 4}}, desiredPoolNumber = 3, minimumUtxoValue = Quantity {getQuantity = 1000000}, eras = ApiEraInfo {byron = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC}), shelley = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC}), allegra = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC}), mary = Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC})}}))
       expected: Nothing
        but got: Just (ApiEpochInfo {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, epochStartTime = 2021-02-01 13:07:11 UTC})
```

<!-- 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.
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 2, 2021

Build failed:


src/Test/Integration/Framework/DSL.hs:1814:7:
--
  | 1) API Specifications, SHELLEY_STAKE_POOLS, STAKE_POOLS_JOIN_01rewards - Can join a pool, earn rewards and collect them
  | expected a successful response but got an error: DecodeFailure "{\"code\":\"created_invalid_transaction\",\"message\":\"That's embarrassing. It looks like I've created an invalid transaction that could not be parsed by the node. Here's an error message that may help with debugging: HardForkApplyTxErrFromEra S (S (S (Z (WrapApplyTxErr {unwrapApplyTxErr = ApplyTxError [LedgerFailure (DelegsFailure (WithdrawalsNotInRewardsDELEGS (fromList [(RewardAcnt {getRwdNetwork = Mainnet, getRwdCred = KeyHashObj (KeyHash \\\"6fa896e9c13d4934e5f61559158569445d0f0326d13a528ba704bf75\\\")},Coin 683876449)])))]}))))\"}"
  | While verifying (Status {statusCode = 500, statusMessage = "Internal Server Error"},Left (DecodeFailure "{\"code\":\"created_invalid_transaction\",\"message\":\"That's embarrassing. It looks like I've created an invalid transaction that could not be parsed by the node. Here's an error message that may help with debugging: HardForkApplyTxErrFromEra S (S (S (Z (WrapApplyTxErr {unwrapApplyTxErr = ApplyTxError [LedgerFailure (DelegsFailure (WithdrawalsNotInRewardsDELEGS (fromList [(RewardAcnt {getRwdNetwork = Mainnet, getRwdCred = KeyHashObj (KeyHash \\\"6fa896e9c13d4934e5f61559158569445d0f0326d13a528ba704bf75\\\")},Coin 683876449)])))]}))))\"}"))
  |  
  | To rerun use: --match "/API Specifications/SHELLEY_STAKE_POOLS/STAKE_POOLS_JOIN_01rewards - Can join a pool, earn rewards and collect them/"

#2467

@Anviking
Copy link
Collaborator Author

Anviking commented Feb 2, 2021

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 2, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit 290bde5 into master Feb 2, 2021
@iohk-bors iohk-bors bot deleted the anviking/ADP-681/era-specific-tests branch February 2, 2021 10:23
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