diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs index 2054d8ce2a8..4df700b89bd 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs @@ -688,14 +688,19 @@ balanceTransactionWithSelectionStrategyAndNoZeroAdaAdjustment ) externalSelectedUtxo <- extractExternallySelectedUTxO ptx + let utxoSelection = + UTxOSelection.fromIndexPair + (internalUtxoAvailable, externalSelectedUtxo) + + when (UTxOSelection.availableSize utxoSelection == 0) $ + throwE ErrBalanceTxUnableToCreateInput let mSel = selectAssets pp utxoAssumptions (F.toList $ partialTx ^. bodyTxL . outputsTxBodyL) redeemers - (UTxOSelection.fromIndexPair - (internalUtxoAvailable, externalSelectedUtxo)) + utxoSelection balance0 (Convert.toWalletCoin minfee0) randomSeed diff --git a/lib/wallet/integration/src/Test/Integration/Framework/DSL.hs b/lib/wallet/integration/src/Test/Integration/Framework/DSL.hs index 139326e30ec..cfa5d01e8a9 100644 --- a/lib/wallet/integration/src/Test/Integration/Framework/DSL.hs +++ b/lib/wallet/integration/src/Test/Integration/Framework/DSL.hs @@ -693,7 +693,7 @@ expectErrorMessage -> m () expectErrorMessage want = either expectation wantedErrorButSuccess . snd where - expectation msg = fmt msg `shouldContain` want + expectation exception = fmt exception `shouldContain` want fmt = \case DecodeFailure res msg -> msg ++ "\n" ++ BL8.unpack res ClientError val -> BL8.unpack $ Aeson.encode val diff --git a/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs index d8dba128610..ae550427493 100644 --- a/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -159,6 +159,7 @@ import Test.Integration.Framework.DSL , emptyWallet , eventually , eventuallyUsingDelay + , expectErrorInfo , expectErrorMessage , expectField , expectListField @@ -534,6 +535,16 @@ spec = describe "SHELLEY_STAKE_POOLS" $ do expectResponseCode HTTP.status404 r expectErrorMessage (errMsg404NoSuchPool (toText retiredPoolId)) r + it "STAKE_POOLS_JOIN_EMPTY - Empty wallet cannot join a pool" $ \ctx -> + runResourceT $ do + w <- emptyWallet ctx + pool : _ <- map (view #id) <$> notRetiringPools ctx + r <- joinStakePool @n ctx (SpecificPool pool) (w, fixturePassphrase) + verify r + [ expectResponseCode HTTP.status403 + , expectErrorInfo (`shouldBe` NoUtxosAvailable) + ] + it "STAKE_POOLS_QUIT_02 - Passphrase must be correct to quit" $ \ctx -> runResourceT $ do w <- fixtureWallet ctx pool : _ <- map (view #id) <$> notRetiringPools ctx diff --git a/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index c638adc5ab0..8a0f001f8ad 100644 --- a/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/wallet/integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -276,6 +276,7 @@ import Test.Integration.Framework.DSL , emptyRandomWallet , emptyWallet , eventually + , expectErrorInfo , expectErrorMessage , expectField , expectListField @@ -917,18 +918,18 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do NotEnoughMoney {} -> True _someOtherError -> False - it "TRANS_NEW_CREATE_04d - Not enough money emptyWallet" $ \ctx -> runResourceT $ do + it "TRANS_NEW_CREATE_04d - No UTxOs available" $ \ctx -> runResourceT $ do wa <- emptyWallet ctx wb <- emptyWallet ctx payload <- liftIO $ mkTxPayload ctx wb (minUTxOValue (_mainEra ctx)) 1 - rTx <- request @(ApiConstructTransaction n) ctx + request @(ApiConstructTransaction n) ctx (Link.createUnsignedTransaction @'Shelley wa) Default payload - verify rTx [expectResponseCode HTTP.status403] - decodeErrorInfo rTx `shouldSatisfy` \case - NotEnoughMoney {} -> True - _someOtherError -> False + >>= flip verify + [ expectResponseCode HTTP.status403 + , expectErrorInfo (`shouldBe` NoUtxosAvailable) + ] it "TRANS_NEW_CREATE_04e- Multiple Output Tx to single wallet" $ \ctx -> runResourceT $ do wa <- fixtureWallet ctx @@ -2368,12 +2369,12 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do \ctx -> runResourceT $ do wa <- emptyWallet ctx let balancePayload = Json PlutusScenario.pingPong_1 - rTx <- request @ApiSerialisedTransaction ctx - (Link.balanceTransaction @'Shelley wa) Default balancePayload - verify rTx [expectResponseCode HTTP.status403] - decodeErrorInfo rTx `shouldSatisfy` \case - NotEnoughMoney {} -> True - _someOtherError -> False + request @ApiSerialisedTransaction + ctx (Link.balanceTransaction @'Shelley wa) Default balancePayload + >>= flip verify + [ expectResponseCode HTTP.status403 + , expectErrorInfo (`shouldBe` NoUtxosAvailable) + ] it "TRANS_NEW_BALANCE_02b - Cannot balance when I cannot afford fee" $ \ctx -> runResourceT $ do diff --git a/nix/haskell.nix b/nix/haskell.nix index 4ac85ca7773..45a7a0a6e5f 100644 --- a/nix/haskell.nix +++ b/nix/haskell.nix @@ -138,6 +138,7 @@ CHaP: haskell-nix: nixpkgs-recent: nodePkgs: haskell-nix.cabalProject' [ pkgconfig nixpkgs-recent.python3Packages.openapi-spec-validator (ruby_3_1.withPackages (ps: [ ps.rake ps.thor ])) + rubyPackages_3_1.rubocop sqlite-interactive curlFull jq diff --git a/test/e2e/README.md b/test/e2e/README.md index 6b7fd90d33a..bba3f73adf4 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -125,13 +125,13 @@ One can run specific tests using by providing `SPEC` or `SPEC_OPTS` arguments to ``` - run only `non-e2e` tests on downloaded binaries and don't wait for node to be synced ```ruby - $ rake run_on[preprod,bins,no-sync] SPEC_OPTS="-t ~e2e" + $ rake run_on[preprod,no-sync] SPEC_OPTS="-t ~e2e" ``` - run only tests matching specific string ```ruby $ rake run_on[preprod] SPEC_OPTS="-e 'CardanoWallet::Shelley::Wallets'" ``` - - run only specific test identified by line of test code against node and wallet from the `$PATH` (skips downloading from Hydra) + - run only specific test identified by line of test code against node and wallet from the `$PATH` (skips downloading from CI) ```ruby $ TESTS_E2E_BINDIR="" rake run_on[preprod] SPEC=spec/shelley_spec.rb:9 ``` diff --git a/test/e2e/Rakefile b/test/e2e/Rakefile index 8ec03400cb6..c8b4694a3ca 100644 --- a/test/e2e/Rakefile +++ b/test/e2e/Rakefile @@ -367,30 +367,34 @@ end ## # Setup utility task getting node and wallet binaries, configs and decoding fixtures # so it is ready to start -task :setup, [:env, :branch, :skip_configs] do |_task, args| +task :setup, [:env, :branch, :skip_bins, :skip_configs] do |_task, args| log '>> Getting latest binaries and configs and decoding fixtures...' env = args[:env] branch = args[:branch] || 'master' - skip_configs = args[:skip_configs] || nil - if BINS == '' + if args[:skip_bins] log '>> Skipping getting latest binaries. Will test wallet and node from $PATH.' else Rake::Task[:get_latest_bins].invoke(branch) end - Rake::Task[:get_latest_configs].invoke(env) unless skip_configs + + if args[:skip_configs] + log '>> Skipping getting latest configs.' + else + Rake::Task[:get_latest_configs].invoke(env) + end + Rake::Task[:secrets_decode].invoke end -task :run_on, [:env, :sync_strategy, :skip_configs, :branch] do |_task, args| +task :run_on, [:env, :sync_strategy, :skip_bins, :skip_configs, :branch] do |_task, args| log '>> Setting up env and running tests...' log "TESTS_E2E_STATEDIR=#{STATE}" env = args[:env] - skip_configs = args[:skip_configs] sync_strategy = args[:sync_strategy] || :sync branch = args[:branch] || nil - Rake::Task[:setup].invoke(env, branch, skip_configs) + Rake::Task[:setup].invoke(env, branch, args[:skip_bins], args[:skip_configs]) Rake::Task[:display_versions].invoke Rake::Task[:start_node_and_wallet].invoke(env) diff --git a/test/e2e/spec/e2e_spec.rb b/test/e2e/spec/e2e_spec.rb index e576df40e8d..5c48ed43b99 100644 --- a/test/e2e/spec/e2e_spec.rb +++ b/test/e2e/spec/e2e_spec.rb @@ -2880,16 +2880,6 @@ def script_hash expect(fees.to_s).to include 'no_utxos_available' end - it 'I could join Stake Pool - if I had enough to cover fee' do - id = create_shelley_wallet - pools = SHELLEY.stake_pools - pool_id = pools.list({ stake: 1000 })[0]['id'] - - join = pools.join(pool_id, id, PASS) - expect(join).to be_correct_and_respond 403 - expect(join.to_s).to include 'no_utxos_available' - end - it 'Can list stake pools only when stake is provided' do pools = SHELLEY.stake_pools l = pools.list({ stake: 1000 })