Skip to content

Commit

Permalink
stellar#5174: started integration test changes to handle blank meta
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Jan 22, 2024
1 parent 15e44b0 commit a742b08
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions services/horizon/internal/integration/invokehostfunction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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"
Expand Down Expand Up @@ -56,6 +57,8 @@ func TestContractInvokeHostFunctionInstallContract(t *testing.T) {
err = xdr.SafeUnmarshalBase64(clientTx.EnvelopeXdr, &txEnv)
require.NoError(t, err)

verifyEmptySorobanMeta(t, clientTx)

opResults, ok := txResult.OperationResults()
assert.True(t, ok)
assert.Equal(t, len(opResults), 1)
Expand Down Expand Up @@ -103,6 +106,7 @@ func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) {

clientTx, err := itest.Client().TransactionDetail(tx.Hash)
require.NoError(t, err)
verifyEmptySorobanMeta(t, clientTx)

assert.Equal(t, tx.Hash, clientTx.Hash)
var txResult xdr.TransactionResult
Expand Down Expand Up @@ -196,6 +200,7 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) {

clientTx, err := itest.Client().TransactionDetail(tx.Hash)
require.NoError(t, err)
verifyEmptySorobanMeta(t, clientTx)

assert.Equal(t, tx.Hash, clientTx.Hash)
var txResult xdr.TransactionResult
Expand Down Expand Up @@ -292,6 +297,7 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) {

clientTx, err := itest.Client().TransactionDetail(tx.Hash)
require.NoError(t, err)
verifyEmptySorobanMeta(t, clientTx)

assert.Equal(t, tx.Hash, clientTx.Hash)
var txResult xdr.TransactionResult
Expand Down Expand Up @@ -346,6 +352,18 @@ func assembleInstallContractCodeOp(t *testing.T, sourceAccount string, wasmFileN
}
}

func verifyEmptySorobanMeta(t *testing.T, clientTx horizon.Transaction) {
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)
}

func assembleCreateContractOp(t *testing.T, sourceAccount string, wasmFileName string, contractSalt string, passPhrase string) *txnbuild.InvokeHostFunction {
// Assemble the InvokeHostFunction CreateContract operation:
// CAP-0047 - https://github.com/stellar/stellar-protocol/blob/master/core/cap-0047.md#creating-a-contract-using-invokehostfunctionop
Expand Down
1 change: 1 addition & 0 deletions services/horizon/internal/integration/sac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, o
preFlightOp, minFee := itest.PreflightHostFunctions(&acc, *op)
clientTx, err := itest.SubmitOperationsWithFee(&acc, signer, minFee+txnbuild.MinBaseFee, &preFlightOp)
require.NoError(itest.CurrentTest(), err)
verifyEmptySorobanMeta(itest.CurrentTest(), clientTx)

var txResult xdr.TransactionResult
err = xdr.SafeUnmarshalBase64(clientTx.ResultXdr, &txResult)
Expand Down

0 comments on commit a742b08

Please sign in to comment.