diff --git a/services/horizon/internal/integration/invokehostfunction_test.go b/services/horizon/internal/integration/invokehostfunction_test.go index bbf4c0e016..60b5f5c9a7 100644 --- a/services/horizon/internal/integration/invokehostfunction_test.go +++ b/services/horizon/internal/integration/invokehostfunction_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/stellar/go/clients/horizonclient" + "github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon/operations" "github.com/stellar/go/services/horizon/internal/test/integration" "github.com/stellar/go/txnbuild" @@ -35,7 +36,7 @@ func TestInvokeHostFns(t *testing.T) { } func runAllTests(t *testing.T) { - t.Run("Soroabn Processing Enbabled", func(t *testing.T) { + t.Run(fmt.Sprintf("Soroban Processing Disabled = %v", DisabledSoroban), func(t *testing.T) { CaseContractInvokeHostFunctionInstallContract(t) CaseContractInvokeHostFunctionCreateContractByAddress(t) CaseContractInvokeHostFunctionInvokeStatelessContractFn(t) @@ -127,6 +128,10 @@ func CaseContractInvokeHostFunctionCreateContractByAddress(t *testing.T) { clientTx, err := itest.Client().TransactionDetail(tx.Hash) require.NoError(t, err) + if DisabledSoroban { + verifyEmptySorobanMeta(t, clientTx) + } + assert.Equal(t, tx.Hash, clientTx.Hash) var txResult xdr.TransactionResult err = xdr.SafeUnmarshalBase64(clientTx.ResultXdr, &txResult) @@ -241,6 +246,8 @@ func CaseContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) { var transactionMeta xdr.TransactionMeta assert.NoError(t, xdr.SafeUnmarshalBase64(tx.ResultMetaXdr, &transactionMeta)) assert.True(t, expectedScVal.Equals(transactionMeta.V3.SorobanMeta.ReturnValue)) + } else { + verifyEmptySorobanMeta(t, clientTx) } clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{ @@ -341,6 +348,8 @@ func CaseContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) { var transactionMeta xdr.TransactionMeta assert.NoError(t, xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &transactionMeta)) assert.True(t, expectedScVal.Equals(transactionMeta.V3.SorobanMeta.ReturnValue)) + } else { + verifyEmptySorobanMeta(t, clientTx) } clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{ @@ -415,3 +424,19 @@ func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName s SourceAccount: sourceAccount, } } + +func verifyEmptySorobanMeta(t *testing.T, clientTx horizon.Transaction) { + if !DisabledSoroban { + return + } + + var txMeta xdr.TransactionMeta + err := xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &txMeta) + require.NoError(t, err) + + require.NotNil(t, txMeta.V3) + require.Empty(t, txMeta.V3.Operations) + require.Empty(t, txMeta.V3.TxChangesAfter) + require.Empty(t, txMeta.V3.TxChangesBefore) + require.Nil(t, txMeta.V3.SorobanMeta) +} diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index 9f9c0217a4..8cf3fb1382 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -37,7 +37,7 @@ var ( func TestSAC(t *testing.T) { // first test contracts when soroban processing is enabled - DisabledSoroban = true + DisabledSoroban = false runAllSACTests(t) // now test same contracts when soroban processing is disabled DisabledSoroban = true @@ -45,7 +45,7 @@ func TestSAC(t *testing.T) { } func runAllSACTests(t *testing.T) { - t.Run("Soroabn Processing Enbabled", func(t *testing.T) { + t.Run(fmt.Sprintf("Soroban Processing Disabled = %v", DisabledSoroban), func(t *testing.T) { CaseContractMintToAccount(t) CaseContractMintToContract(t) CaseExpirationAndRestoration(t) @@ -1514,16 +1514,18 @@ func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, o assert.True(itest.CurrentTest(), ok) assert.Equal(itest.CurrentTest(), invokeHostFunctionResult.Code, xdr.InvokeHostFunctionResultCodeInvokeHostFunctionSuccess) - var returnValue xdr.ScVal + var returnValue *xdr.ScVal if !DisabledSoroban { var txMetaResult xdr.TransactionMeta err = xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &txMetaResult) require.NoError(itest.CurrentTest(), err) - returnValue = txMetaResult.MustV3().SorobanMeta.ReturnValue + returnValue = &txMetaResult.MustV3().SorobanMeta.ReturnValue + } else { + verifyEmptySorobanMeta(itest.CurrentTest(), clientTx) } - return &returnValue, clientTx.Hash, &preFlightOp + return returnValue, clientTx.Hash, &preFlightOp } func stellarAssetContractID(itest *integration.Test, asset xdr.Asset) xdr.Hash {