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

Finish integration tests awaiting signTransaction endpoint #2950

Merged
merged 3 commits into from
Oct 8, 2021

Conversation

sevanspowell
Copy link
Contributor

@sevanspowell sevanspowell commented Oct 6, 2021

ADP-1185

  • A number of integration tests have TODO blocks detailing conditions to check once the signTransaction endpoint has been implemented. Now that it has been implemented, this PR works to fill out those TODO blocks with tests.

@sevanspowell sevanspowell self-assigned this Oct 6, 2021
@sevanspowell sevanspowell force-pushed the sevanspowell/adp-919/address-todo-tests branch from 08e094d to 5bc7aff Compare October 6, 2021 08:21
-- check that reward account is 0,
-- make sure wallet balance is increased by withdrawalAmt - fee

-- TODO check that reward account is 0 (??)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Piotr, do you know what this means/how I could check it is true?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I believe it means just to assert that reward balance on the rewardWallet is 0 after withdrawal.

expectField  (#balance . #reward . #getQuantity) (`shouldBe` 0)

(or smth)

-- make sure balance is updated accordingly on src and dst wallets
-- make sure delegation cerificates are inserted

-- TODO: make sure delegation cerificates are inserted
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you can see, I've left two TODO items. I'm not sure how to check that delegation certificates are inserted, and that the metadata made it to the chain.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that:

  • for metadata it should be enough to check that tx status is eventually "in_ledger" and that it contains "metadata" field with the content as expected.
  • for delegation it should be enough to check that wallet has delegation -> next active with the pool_id

(I think however that delegation is not working, I've tried it on testnet and with e2e tests yesterday (#2949) - it seems that creating this kind of tx with construct ep does not trigger wallet to delegate)

request @ApiSignedTransaction ctx signEndpoint Default toSign

-- Submit tx
submitTx ctx signedTx [ expectResponseCode HTTP.status202 ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one fails with:

The submitted transaction was rejected by the local node. Here's an error message that may help with debugging: TxValidationErrorInMode (ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [DelegsFailure (WithdrawalsNotInRewardsDELEGS (fromList [(RewardAcnt {getRwdNetwork = Mainnet, getRwdCred = KeyHashObj (KeyHash "89fc61d21ddfcbd4d43652bf05c40c346fa794871423b65052d7614c")},Coin 1000000000000)]))])) AlonzoEraInCardanoMode

I think that means it's a bug in the implementation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that withdrawal from external wallet may not be supported on construct tx ep (https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/constructTransaction) it used to be a thing for old tx ep (https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction -> redemption) as a feature to allow users to withdraw funds from ITN wallets.

But if that's the case the construct ep should not allow mnemonics in the first place, so yeah it is a bug in implementation.

@sevanspowell
Copy link
Contributor Author

sevanspowell commented Oct 8, 2021

Implementing the signing and submission causes the following two tests to fail, indicating a bug/actual issue in the current implementation:

  src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs:343:40: 
  1) API Specifications, NEW_SHELLEY_TRANSACTIONS, TRANS_NEW_CREATE_03b - Withdrawal from external wallet
       From the following response: Left
           ( ClientError
               ( Object
                   ( fromList
                       [
                           ( "code"
                           , String "created_invalid_transaction"
                           )
                       ,
                           ( "message"
                           , String "The submitted transaction was rejected by the local node. Here's an error message that may help with debugging: TxValidationErrorInMode (ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [DelegsFailure (WithdrawalsNotInRewardsDELEGS (fromList [(RewardAcnt {getRwdNetwork = Mainnet, getRwdCred = KeyHashObj (KeyHash "b0d4a8312a679abf89ed1acadd0164064765712d608aa90f1756385c")},Coin 1000000000000)]))])) AlonzoEraInCardanoMode"
                           )
                       ]
                   )
               )
           )
       While verifying value:
         ( Status
             { statusCode = 500
             , statusMessage = "Internal Server Error"
             }
         , Left
             ( ClientError
                 ( Object
                     ( fromList
                         [
                             ( "code"
                             , String "created_invalid_transaction"
                             )
                         ,
                             ( "message"
                             , String "The submitted transaction was rejected by the local node. Here's an error message that may help with debugging: TxValidationErrorInMode (ShelleyTxValidationError ShelleyBasedEraAlonzo (ApplyTxError [DelegsFailure (WithdrawalsNotInRewardsDELEGS (fromList [(RewardAcnt {getRwdNetwork = Mainnet, getRwdCred = KeyHashObj (KeyHash "b0d4a8312a679abf89ed1acadd0164064765712d608aa90f1756385c")},Coin 1000000000000)]))])) AlonzoEraInCardanoMode"
                             )
                         ]
                     )
                 )
             )
         )
       expected: Status {statusCode = 202, statusMessage = "Accepted"}
        but got: Status {statusCode = 500, statusMessage = "Internal Server Error"}

  To rerun use: --match "/API Specifications/NEW_SHELLEY_TRANSACTIONS/TRANS_NEW_CREATE_03b - Withdrawal from external wallet/"

and

  src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs:954:26: 
  2) API Specifications, NEW_SHELLEY_TRANSACTIONS, TRANS_NEW_CREATE_MULTI_TX - Tx including payments, delegation, metadata, withdrawals, validity_interval
       While verifying value:
         ( Status
             { statusCode = 200
             , statusMessage = "OK"
             }
         , Right
             ( ApiWallet
                 { id = ApiT
                     ( WalletId { getWalletId = d6f3ea2d2907e9193e89190dc53f37d4777d33bf } )
                 , addressPoolGap = ApiT
                     ( AddressPoolGap
                         { getAddressPoolGap = 20 }
                     )
                 , balance = ApiWalletBalance
                     { available = Quantity 999997851244
                     , total = Quantity 999997851244
                     , reward = Quantity 0
                     }
                 , assets = ApiWalletAssetsBalance
                     { available = ApiT
                         ( TokenMap
                             ( fromList [] )
                         )
                     , total = ApiT
                         ( TokenMap
                             ( fromList [] )
                         )
                     }
                 , delegation = ApiWalletDelegation
                     { active = ApiWalletDelegationNext
                         { status = NotDelegating
                         , target = Nothing
                         , changesAt = Nothing
                         }
                     , next = []
                     }
                 , name = ApiT
                     ( WalletName
                         { getWalletName = "Faucet Wallet" }
                     )
                 , passphrase = Just
                     ( ApiWalletPassphraseInfo 2021 - 10 - 08 04 : 45 : 43.640352958 UTC )
                 , state = ApiT Ready
                 , tip = ApiBlockReference
                     { absoluteSlotNumber = ApiT
                         ( SlotNo 839 )
                     , slotId = ApiSlotId
                         { epochNumber = ApiT
                             ( EpochNo
                                 { unEpochNo = 8 }
                             )
                         , slotNumber = ApiT
                             ( SlotInEpoch
                                 { unSlotInEpoch = 39 }
                             )
                         }
                     , time = 2021 - 10 - 08 04 : 47 : 15.8 UTC
                     , block = ApiBlockInfo
                         ( Quantity 341 )
                     }
                 }
             )
         )
       
       Waited longer than 90s to resolve action: "Delegation certificates are inserted".
       expected: ApiWalletDelegation {active = ApiWalletDelegationNext {status = Delegating, target = Just (ApiT (PoolId {getPoolId = "\236(\243=\203\230\214@\n\RS^3\155\208d|\ts\202l\f\249\194\187\230\131\141\198"})), changesAt = Nothing}, next = []}
        but got: ApiWalletDelegation {active = ApiWalletDelegationNext {status = NotDelegating, target = Nothing, changesAt = Nothing}, next = []}

  To rerun use: --match "/API Specifications/NEW_SHELLEY_TRANSACTIONS/TRANS_NEW_CREATE_MULTI_TX - Tx including payments, delegation, metadata, withdrawals, validity_interval/"

These items are tracked in https://input-output.atlassian.net/browse/ADP-1189, and so I will make these tests "pending".

@sevanspowell sevanspowell force-pushed the sevanspowell/adp-919/address-todo-tests branch from d78e10f to 0f29964 Compare October 8, 2021 06:00
@sevanspowell sevanspowell marked this pull request as ready for review October 8, 2021 06:07
- We'll be adding tests for signing and submission of transactions, so provide
  helpers to make that easier.
- Fill out TODO items on non-pending tests related to signing and submission.
- Make tests that aren't working atm PENDING. These failures are tracked in
  ADP-1189.
@sevanspowell sevanspowell force-pushed the sevanspowell/adp-919/address-todo-tests branch from c53f4fc to f5a786d Compare October 8, 2021 06:08
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!

@piotr-iohk
Copy link
Contributor

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 8, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit ff59ff7 into master Oct 8, 2021
@iohk-bors iohk-bors bot deleted the sevanspowell/adp-919/address-todo-tests branch October 8, 2021 08: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.

2 participants