From 64fa0e287576dfd3a2ec6a47cd23e0abced7f43d Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 17 Oct 2023 18:52:50 +0200 Subject: [PATCH] Ensure that we always apply the base fee on toip of the preflight fee --- .../integration/invokehostfunction_test.go | 16 ++++++++-------- .../horizon/internal/integration/txsub_test.go | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/horizon/internal/integration/invokehostfunction_test.go b/services/horizon/internal/integration/invokehostfunction_test.go index f7a4adabe1..275f0de23b 100644 --- a/services/horizon/internal/integration/invokehostfunction_test.go +++ b/services/horizon/internal/integration/invokehostfunction_test.go @@ -93,12 +93,12 @@ func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) { // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -147,12 +147,12 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { // Install the contract installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), add_u64_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), add_u64_contract, "a1", itest.GetPassPhrase()) preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) // contract has been deployed, now invoke a simple 'add' fn on the contract @@ -191,7 +191,7 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { } preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *invokeHostFunctionOp) - tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) @@ -257,13 +257,13 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), increment_contract) preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + itest.MustSubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) // Create the contract createContractOp := assembleCreateContractOp(t, itest.Master().Address(), increment_contract, "a1", itest.GetPassPhrase()) preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *createContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) // contract has been deployed, now invoke a simple 'add' fn on the contract @@ -287,7 +287,7 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { } preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *invokeHostFunctionOp) - tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) clientTx, err := itest.Client().TransactionDetail(tx.Hash) diff --git a/services/horizon/internal/integration/txsub_test.go b/services/horizon/internal/integration/txsub_test.go index 90266768ee..2f6b98e905 100644 --- a/services/horizon/internal/integration/txsub_test.go +++ b/services/horizon/internal/integration/txsub_test.go @@ -75,7 +75,7 @@ func TestTxSubLimitsBodySize(t *testing.T) { installContractOp := assembleInstallContractCodeOp(t, itest.Master().Address(), "soroban_sac_test.wasm") preFlightOp, minFee := itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - _, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + _, err = itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) assert.EqualError( t, err, "horizon error: \"Transaction Malformed\" - check horizon.Error.Problem for more information", @@ -88,7 +88,7 @@ func TestTxSubLimitsBodySize(t *testing.T) { installContractOp = assembleInstallContractCodeOp(t, itest.Master().Address(), "soroban_add_u64.wasm") preFlightOp, minFee = itest.PreflightHostFunctions(&sourceAccount, *installContractOp) - tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee, &preFlightOp) + tx, err := itest.SubmitOperationsWithFee(&sourceAccount, itest.Master(), minFee+txnbuild.MinBaseFee, &preFlightOp) require.NoError(t, err) require.True(t, tx.Successful) }