diff options
Diffstat (limited to 'daemon/algod/api/server/v2/test/handlers_test.go')
-rw-r--r-- | daemon/algod/api/server/v2/test/handlers_test.go | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index b5930e28a..dd89a23ef 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -41,7 +41,9 @@ import ( "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/node" "github.com/algorand/go-algorand/protocol" + "github.com/algorand/go-algorand/test/partitiontest" "github.com/algorand/go-algorand/util/execpool" + "github.com/algorand/go-codec/codec" ) func setupTestForMethodGet(t *testing.T) (v2.Handlers, echo.Context, *httptest.ResponseRecorder, []account.Root, []transactions.SignedTxn, func()) { @@ -64,6 +66,7 @@ func setupTestForMethodGet(t *testing.T) (v2.Handlers, echo.Context, *httptest.R } func TestSimpleMockBuilding(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() handler, _, _, _, _, releasefunc := setupTestForMethodGet(t) @@ -87,6 +90,7 @@ func accountInformationTest(t *testing.T, address string, expectedCode int) { } func TestAccountInformation(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() accountInformationTest(t, poolAddr.String(), 200) @@ -102,6 +106,7 @@ func getBlockTest(t *testing.T, blockNum uint64, format string, expectedCode int } func TestGetBlock(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() getBlockTest(t, 0, "json", 200) @@ -111,6 +116,7 @@ func TestGetBlock(t *testing.T) { } func TestGetBlockJsonEncoding(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t) @@ -146,7 +152,7 @@ func TestGetBlockJsonEncoding(t *testing.T) { Lsig: lsig, } ad := transactions.ApplyData{ - EvalDelta: basics.EvalDelta{ + EvalDelta: transactions.EvalDelta{ LocalDeltas: map[uint64]basics.StateDelta{ 1: {"key": basics.ValueDelta{Action: 1}}, }, @@ -206,6 +212,7 @@ func TestGetBlockJsonEncoding(t *testing.T) { } func TestGetSupply(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() handler, c, _, _, _, releasefunc := setupTestForMethodGet(t) @@ -215,6 +222,7 @@ func TestGetSupply(t *testing.T) { } func TestGetStatus(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t) @@ -246,6 +254,7 @@ func TestGetStatus(t *testing.T) { } func TestGetStatusAfterBlock(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t) @@ -258,6 +267,7 @@ func TestGetStatusAfterBlock(t *testing.T) { } func TestGetTransactionParams(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() handler, c, rec, _, _, releasefunc := setupTestForMethodGet(t) @@ -281,6 +291,7 @@ func pendingTransactionInformationTest(t *testing.T, txidToUse int, format strin } func TestPendingTransactionInformation(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() pendingTransactionInformationTest(t, 0, "json", 200) @@ -316,7 +327,45 @@ func getPendingTransactionsTest(t *testing.T, format string, max uint64, expecte } } +func TestPendingTransactionLogsEncoding(t *testing.T) { + partitiontest.PartitionTest(t) + + response := generated.PendingTransactionResponse{ + Logs: &[][]byte{ + {}, + []byte(string("a")), + []byte(string("test")), + {0}, + {0, 1, 2}, + }, + } + + // log messages should be base64 encoded + expected := `{ + "logs": [ + "", + "YQ==", + "dGVzdA==", + "AA==", + "AAEC" + ], + "pool-error": "", + "txn": null +}` + + for _, handle := range []codec.Handle{protocol.JSONHandle, protocol.JSONStrictHandle} { + var output []byte + enc := codec.NewEncoderBytes(&output, handle) + + err := enc.Encode(response) + require.NoError(t, err) + + require.Equal(t, expected, string(output)) + } +} + func TestPendingTransactions(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() getPendingTransactionsTest(t, "json", 0, 200) @@ -344,6 +393,7 @@ func pendingTransactionsByAddressTest(t *testing.T, rootkeyToUse int, format str } func TestPendingTransactionsByAddress(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() pendingTransactionsByAddressTest(t, 0, "json", 200) @@ -381,6 +431,7 @@ func postTransactionTest(t *testing.T, txnToUse, expectedCode int) { } func TestPostTransaction(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() postTransactionTest(t, -1, 400) @@ -410,6 +461,7 @@ func startCatchupTest(t *testing.T, catchpoint string, nodeError error, expected } func TestStartCatchup(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() goodCatchPoint := "5894690#DVFRZUYHEFKRLK5N6DNJRR4IABEVN2D6H76F3ZSEPIE6MKXMQWQA" @@ -450,6 +502,7 @@ func abortCatchupTest(t *testing.T, catchpoint string, expectedCode int) { } func TestAbortCatchup(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() goodCatchPoint := "5894690#DVFRZUYHEFKRLK5N6DNJRR4IABEVN2D6H76F3ZSEPIE6MKXMQWQA" @@ -482,6 +535,7 @@ func tealCompileTest(t *testing.T, bytesToUse []byte, expectedCode int, enableDe } func TestTealCompile(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() tealCompileTest(t, nil, 200, true) // nil program should work @@ -543,6 +597,7 @@ func tealDryrunTest( } func TestTealDryrun(t *testing.T) { + partitiontest.PartitionTest(t) t.Parallel() var gdr generated.DryrunRequest |