From 62727b8d02100802cd3539e0bb13a29081a5bd42 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 8 Feb 2023 16:00:23 +0100 Subject: [PATCH] Fix address parameter --- .../horizon/internal/integration/sac_test.go | 42 ++++--------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/services/horizon/internal/integration/sac_test.go b/services/horizon/internal/integration/sac_test.go index b0c8edf77d..0180ea35bc 100644 --- a/services/horizon/internal/integration/sac_test.go +++ b/services/horizon/internal/integration/sac_test.go @@ -48,7 +48,7 @@ func TestContractMintToAccount(t *testing.T) { assertInvokeHostFnSucceeds( itest, itest.Master(), - mint(itest, issuer, asset, "20", accountIDEnumParam(recipient.GetAccountID())), + mint(itest, issuer, asset, "20", accountAddressParam(recipient.GetAccountID())), ) assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("20")) @@ -61,7 +61,7 @@ func TestContractMintToAccount(t *testing.T) { assertInvokeHostFnSucceeds( itest, itest.Master(), - xfer(itest, issuer, asset, "30", accountIDEnumParam(otherRecipient.GetAccountID())), + xfer(itest, issuer, asset, "30", accountAddressParam(otherRecipient.GetAccountID())), ) assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("20")) assertContainsBalance(itest, otherRecipientKp, issuer, code, amount.MustParse("30")) @@ -165,7 +165,7 @@ func TestContractTransferBetweenAccounts(t *testing.T) { assertInvokeHostFnSucceeds( itest, recipientKp, - xfer(itest, recipientKp.Address(), asset, "30", accountIDEnumParam(otherRecipient.GetAccountID())), + xfer(itest, recipientKp.Address(), asset, "30", accountAddressParam(otherRecipient.GetAccountID())), ) assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("970")) @@ -231,7 +231,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) { assertInvokeHostFnSucceeds( itest, recipientKp, - xferFromContract(itest, recipientKp.Address(), recipientContractID, asset, "500", accountIDEnumParam(recipient.GetAccountID())), + xferFromContract(itest, recipientKp.Address(), recipientContractID, asset, "500", accountAddressParam(recipient.GetAccountID())), ) assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("1470")) assertAssetStats(itest, issuer, code, 1, amount.MustParse("1470")) @@ -441,7 +441,7 @@ func TestContractClawbackFromAccount(t *testing.T) { assertInvokeHostFnSucceeds( itest, itest.Master(), - clawback(itest, issuer, asset, "1000", accountIDEnumParam(recipientKp.Address())), + clawback(itest, issuer, asset, "1000", accountAddressParam(recipientKp.Address())), ) assertContainsBalance(itest, recipientKp, issuer, code, amount.MustParse("0")) @@ -534,7 +534,7 @@ func assertAssetStats(itest *integration.Test, issuer, code string, numAccounts func masterAccountIDEnumParam(itest *integration.Test) xdr.ScVal { root := keypair.Root(itest.GetPassPhrase()) - return accountIDEnumParam(root.Address()) + return accountAddressParam(root.Address()) } func functionNameParam(name string) xdr.ScVal { @@ -557,19 +557,7 @@ func contractIDParam(contractID xdr.Hash) xdr.ScVal { } } -// TODO: this shouldn't be an enumerate -// It should be of type Address -// -// #[derive(Clone)] -// -// pub struct Address { -// host: Host, -// object: Object, -// } -// -// See https://github.com/stellar/rs-soroban-env/blob/main/soroban-env-host/src/native_contract/base_types.rs#L401-L405 -// However, I am not sure how to create it since it contains the Host :S -func accountIDEnumParam(accountID string) xdr.ScVal { +func accountAddressParam(accountID string) xdr.ScVal { accountObj := &xdr.ScObject{ Type: xdr.ScObjectTypeScoAddress, Address: &xdr.ScAddress{ @@ -577,23 +565,9 @@ func accountIDEnumParam(accountID string) xdr.ScVal { AccountId: xdr.MustAddressPtr(accountID), }, } - addressSym := xdr.ScSymbol("Address") - addressEnum := &xdr.ScObject{ - Type: xdr.ScObjectTypeScoVec, - Vec: &xdr.ScVec{ - xdr.ScVal{ - Type: xdr.ScValTypeScvSymbol, - Sym: &addressSym, - }, - xdr.ScVal{ - Type: xdr.ScValTypeScvObject, - Obj: &accountObj, - }, - }, - } return xdr.ScVal{ Type: xdr.ScValTypeScvObject, - Obj: &addressEnum, + Obj: &accountObj, } }