Skip to content

Commit

Permalink
Ensure that we always apply the base fee on toip of the preflight fee
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Oct 17, 2023
1 parent 0a09d69 commit 64fa0e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions services/horizon/internal/integration/invokehostfunction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Check failure on line 155 in services/horizon/internal/integration/invokehostfunction_test.go

View workflow job for this annotation

GitHub Actions / golangci

ineffectual assignment to tx (ineffassign)
require.NoError(t, err)

// contract has been deployed, now invoke a simple 'add' fn on the contract
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Check failure on line 266 in services/horizon/internal/integration/invokehostfunction_test.go

View workflow job for this annotation

GitHub Actions / golangci

ineffectual assignment to tx (ineffassign)
require.NoError(t, err)

// contract has been deployed, now invoke a simple 'add' fn on the contract
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/integration/txsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
}

0 comments on commit 64fa0e2

Please sign in to comment.