summaryrefslogtreecommitdiff
path: root/test/e2e-go/restAPI/restClient_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/e2e-go/restAPI/restClient_test.go')
-rw-r--r--test/e2e-go/restAPI/restClient_test.go155
1 files changed, 149 insertions, 6 deletions
diff --git a/test/e2e-go/restAPI/restClient_test.go b/test/e2e-go/restAPI/restClient_test.go
index 69db074c8..49d05ae4a 100644
--- a/test/e2e-go/restAPI/restClient_test.go
+++ b/test/e2e-go/restAPI/restClient_test.go
@@ -18,7 +18,7 @@ package restapi
import (
"context"
- "encoding/base64"
+ "encoding/hex"
"errors"
"flag"
"math"
@@ -191,6 +191,7 @@ func waitForTransaction(t *testing.T, testClient libgoal.Client, fromAddress, tx
func TestClientCanGetStatus(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -207,6 +208,7 @@ func TestClientCanGetStatus(t *testing.T) {
func TestClientCanGetStatusAfterBlock(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -222,6 +224,7 @@ func TestClientCanGetStatusAfterBlock(t *testing.T) {
func TestTransactionsByAddr(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
@@ -270,6 +273,7 @@ func TestTransactionsByAddr(t *testing.T) {
func TestClientCanGetVersion(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -281,6 +285,7 @@ func TestClientCanGetVersion(t *testing.T) {
func TestClientCanGetSuggestedFee(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -292,6 +297,7 @@ func TestClientCanGetSuggestedFee(t *testing.T) {
func TestClientCanGetMinTxnFee(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -303,6 +309,7 @@ func TestClientCanGetMinTxnFee(t *testing.T) {
func TestClientCanGetBlockInfo(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -315,6 +322,7 @@ func TestClientCanGetBlockInfo(t *testing.T) {
func TestClientRejectsBadFromAddressWhenSending(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -331,6 +339,7 @@ func TestClientRejectsBadFromAddressWhenSending(t *testing.T) {
func TestClientRejectsBadToAddressWhenSending(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -347,6 +356,7 @@ func TestClientRejectsBadToAddressWhenSending(t *testing.T) {
func TestClientRejectsMutatedFromAddressWhenSending(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -370,6 +380,7 @@ func TestClientRejectsMutatedFromAddressWhenSending(t *testing.T) {
func TestClientRejectsMutatedToAddressWhenSending(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -393,6 +404,7 @@ func TestClientRejectsMutatedToAddressWhenSending(t *testing.T) {
func TestClientRejectsSendingMoneyFromAccountForWhichItHasNoKey(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -409,6 +421,7 @@ func TestClientRejectsSendingMoneyFromAccountForWhichItHasNoKey(t *testing.T) {
func TestClientOversizedNote(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -434,6 +447,7 @@ func TestClientOversizedNote(t *testing.T) {
func TestClientCanSendAndGetNote(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -459,6 +473,7 @@ func TestClientCanSendAndGetNote(t *testing.T) {
func TestClientCanGetTransactionStatus(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -483,6 +498,7 @@ func TestClientCanGetTransactionStatus(t *testing.T) {
func TestAccountBalance(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -512,6 +528,7 @@ func TestAccountBalance(t *testing.T) {
func TestAccountParticipationInfo(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -575,6 +592,7 @@ func TestAccountParticipationInfo(t *testing.T) {
func TestSupply(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -588,6 +606,7 @@ func TestSupply(t *testing.T) {
func TestClientCanGetGoRoutines(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -602,6 +621,7 @@ func TestClientCanGetGoRoutines(t *testing.T) {
func TestSendingTooMuchFails(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -643,6 +663,7 @@ func TestSendingTooMuchFails(t *testing.T) {
func TestSendingFromEmptyAccountFails(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -682,6 +703,7 @@ func TestSendingFromEmptyAccountFails(t *testing.T) {
func TestSendingTooLittleToEmptyAccountFails(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -714,6 +736,7 @@ func TestSendingTooLittleToEmptyAccountFails(t *testing.T) {
func TestSendingLowFeeFails(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
defer fixture.SetTestContext(t)()
@@ -749,6 +772,7 @@ func TestSendingLowFeeFails(t *testing.T) {
func TestSendingNotClosingAccountFails(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
// use a local fixture because we might really mess with the balances
@@ -795,6 +819,7 @@ func TestSendingNotClosingAccountFails(t *testing.T) {
func TestClientCanGetPendingTransactions(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
@@ -828,6 +853,7 @@ func TestClientCanGetPendingTransactions(t *testing.T) {
func TestClientTruncatesPendingTransactions(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
@@ -868,6 +894,7 @@ func TestClientTruncatesPendingTransactions(t *testing.T) {
func TestClientPrioritizesPendingTransactions(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
t.Skip("new FIFO pool does not have prioritization")
a := require.New(fixtures.SynchronizedTest(t))
@@ -910,6 +937,7 @@ func TestClientPrioritizesPendingTransactions(t *testing.T) {
func TestClientCanGetPendingTransactionInfo(t *testing.T) {
partitiontest.PartitionTest(t)
+ defer fixtures.ShutdownSynchronizedTest(t)
a := require.New(fixtures.SynchronizedTest(t))
var localFixture fixtures.RestClientFixture
@@ -990,12 +1018,10 @@ return
a.NotNil(txn.Logs)
a.Equal(32, len(*txn.Logs))
for i, l := range *txn.Logs {
- a.Equal(*txn.ApplicationIndex, l.Id)
- assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(string(rune('B'+i)))), l.Value)
+ assert.Equal(t, []byte(string(rune('B'+i))), l)
}
//check non-create app call
- expectedAppID := *txn.ApplicationIndex
wh, err = testClient.GetUnencryptedWalletHandle()
a.NoError(err)
addresses, err = testClient.ListAddresses(wh)
@@ -1029,8 +1055,125 @@ return
a.NotNil(txn.Logs)
a.Equal(32, len(*txn.Logs))
for i, l := range *txn.Logs {
- a.Equal(expectedAppID, l.Id)
- assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(string(rune('B'+i)))), l.Value)
+ assert.Equal(t, []byte(string(rune('B'+i))), l)
}
}
+
+func TestPendingTransactionInfoInnerTxnAssetCreate(t *testing.T) {
+ partitiontest.PartitionTest(t)
+
+ a := require.New(fixtures.SynchronizedTest(t))
+ var localFixture fixtures.RestClientFixture
+ localFixture.Setup(t, filepath.Join("nettemplates", "TwoNodes50EachFuture.json"))
+ defer localFixture.Shutdown()
+
+ testClient := localFixture.LibGoalClient
+
+ testClient.WaitForRound(1)
+
+ testClient.SetAPIVersionAffinity(algodclient.APIVersionV2, kmdclient.APIVersionV1)
+
+ wh, err := testClient.GetUnencryptedWalletHandle()
+ a.NoError(err)
+ addresses, err := testClient.ListAddresses(wh)
+ a.NoError(err)
+ _, someAddress := getMaxBalAddr(t, testClient, addresses)
+ if someAddress == "" {
+ t.Error("no addr with funds")
+ }
+ a.NoError(err)
+
+ prog := `#pragma version 5
+txn ApplicationID
+bz end
+itxn_begin
+int acfg
+itxn_field TypeEnum
+int 1000000
+itxn_field ConfigAssetTotal
+int 3
+itxn_field ConfigAssetDecimals
+byte "oz"
+itxn_field ConfigAssetUnitName
+byte "Gold"
+itxn_field ConfigAssetName
+byte "https://gold.rush/"
+itxn_field ConfigAssetURL
+byte 0x67f0cd61653bd34316160bc3f5cd3763c85b114d50d38e1f4e72c3b994411e7b
+itxn_field ConfigAssetMetadataHash
+itxn_submit
+end:
+int 1
+return
+`
+ ops, err := logic.AssembleString(prog)
+ approv := ops.Program
+ ops, err = logic.AssembleString("#pragma version 5 \nint 1")
+ clst := ops.Program
+
+ gl := basics.StateSchema{}
+ lc := basics.StateSchema{}
+
+ // create app
+ appCreateTxn, err := testClient.MakeUnsignedApplicationCallTx(0, nil, nil, nil, nil, transactions.NoOpOC, approv, clst, gl, lc, 0)
+ a.NoError(err)
+ appCreateTxn, err = testClient.FillUnsignedTxTemplate(someAddress, 0, 0, 0, appCreateTxn)
+ a.NoError(err)
+ appCreateTxID, err := testClient.SignAndBroadcastTransaction(wh, nil, appCreateTxn)
+ a.NoError(err)
+ _, err = waitForTransaction(t, testClient, someAddress, appCreateTxID, 30*time.Second)
+ a.NoError(err)
+
+ // get app ID
+ submittedAppCreateTxn, err := testClient.PendingTransactionInformationV2(appCreateTxID)
+ a.NoError(err)
+ a.NotNil(submittedAppCreateTxn.ApplicationIndex)
+ createdAppID := basics.AppIndex(*submittedAppCreateTxn.ApplicationIndex)
+ a.Greater(uint64(createdAppID), uint64(0))
+
+ // fund app account
+ appFundTxn, err := testClient.SendPaymentFromWallet(wh, nil, someAddress, createdAppID.Address().String(), 0, 1_000_000, nil, "", 0, 0)
+ a.NoError(err)
+ appFundTxID := appFundTxn.ID()
+ _, err = waitForTransaction(t, testClient, someAddress, appFundTxID.String(), 30*time.Second)
+ a.NoError(err)
+
+ // call app, which will issue an ASA create inner txn
+ appCallTxn, err := testClient.MakeUnsignedAppNoOpTx(uint64(createdAppID), nil, nil, nil, nil)
+ a.NoError(err)
+ appCallTxn, err = testClient.FillUnsignedTxTemplate(someAddress, 0, 0, 0, appCallTxn)
+ a.NoError(err)
+ appCallTxnTxID, err := testClient.SignAndBroadcastTransaction(wh, nil, appCallTxn)
+ a.NoError(err)
+ _, err = waitForTransaction(t, testClient, someAddress, appCallTxnTxID, 30*time.Second)
+ a.NoError(err)
+
+ // verify pending txn info of outer txn
+ submittedAppCallTxn, err := testClient.PendingTransactionInformationV2(appCallTxnTxID)
+ a.NoError(err)
+ a.Nil(submittedAppCallTxn.ApplicationIndex)
+ a.Nil(submittedAppCallTxn.AssetIndex)
+ a.NotNil(submittedAppCallTxn.InnerTxns)
+ a.Len(*submittedAppCallTxn.InnerTxns, 1)
+
+ // verify pending txn info of inner txn
+ innerTxn := (*submittedAppCallTxn.InnerTxns)[0]
+ a.Nil(innerTxn.ApplicationIndex)
+ a.NotNil(innerTxn.AssetIndex)
+ createdAssetID := *innerTxn.AssetIndex
+ a.Greater(createdAssetID, uint64(0))
+
+ createdAssetInfo, err := testClient.AssetInformationV2(createdAssetID)
+ a.NoError(err)
+ a.Equal(createdAssetID, createdAssetInfo.Index)
+ a.Equal(createdAppID.Address().String(), createdAssetInfo.Params.Creator)
+ a.Equal(uint64(1000000), createdAssetInfo.Params.Total)
+ a.Equal(uint64(3), createdAssetInfo.Params.Decimals)
+ a.Equal("oz", *createdAssetInfo.Params.UnitName)
+ a.Equal("Gold", *createdAssetInfo.Params.Name)
+ a.Equal("https://gold.rush/", *createdAssetInfo.Params.Url)
+ expectedMetadata, err := hex.DecodeString("67f0cd61653bd34316160bc3f5cd3763c85b114d50d38e1f4e72c3b994411e7b")
+ a.NoError(err)
+ a.Equal(expectedMetadata, *createdAssetInfo.Params.MetadataHash)
+}