Skip to content

Commit

Permalink
algod: Don't return a top level array from algod (#5404)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Warehime authored May 19, 2023
1 parent b684243 commit a497df0
Show file tree
Hide file tree
Showing 11 changed files with 956 additions and 914 deletions.
18 changes: 13 additions & 5 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@
],
"responses": {
"200": {
"$ref": "#/responses/TransactionGroupLedgerStateDeltaForRoundResponse"
"$ref": "#/responses/TransactionGroupLedgerStateDeltasForRoundResponse"
},
"401": {
"description": "Invalid API Token",
Expand Down Expand Up @@ -4040,12 +4040,20 @@
"$ref": "#/definitions/LedgerStateDelta"
}
},
"TransactionGroupLedgerStateDeltaForRoundResponse": {
"TransactionGroupLedgerStateDeltasForRoundResponse": {
"description": "Response containing all ledger state deltas for transaction groups, with their associated Ids, in a single round.",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/LedgerStateDeltaForTransactionGroup"
"type": "object",
"required": [
"deltas"
],
"properties": {
"deltas": {
"type": "array",
"items": {
"$ref": "#/definitions/LedgerStateDeltaForTransactionGroup"
}
}
}
}
},
Expand Down
44 changes: 34 additions & 10 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -857,14 +857,22 @@
},
"description": "Supply represents the current supply of MicroAlgos in the system."
},
"TransactionGroupLedgerStateDeltaForRoundResponse": {
"TransactionGroupLedgerStateDeltasForRoundResponse": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/LedgerStateDeltaForTransactionGroup"
"properties": {
"deltas": {
"items": {
"$ref": "#/components/schemas/LedgerStateDeltaForTransactionGroup"
},
"type": "array"
}
},
"type": "array"
"required": [
"deltas"
],
"type": "object"
}
}
},
Expand Down Expand Up @@ -4143,18 +4151,34 @@
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/LedgerStateDeltaForTransactionGroup"
"properties": {
"deltas": {
"items": {
"$ref": "#/components/schemas/LedgerStateDeltaForTransactionGroup"
},
"type": "array"
}
},
"type": "array"
"required": [
"deltas"
],
"type": "object"
}
},
"application/msgpack": {
"schema": {
"items": {
"$ref": "#/components/schemas/LedgerStateDeltaForTransactionGroup"
"properties": {
"deltas": {
"items": {
"$ref": "#/components/schemas/LedgerStateDeltaForTransactionGroup"
},
"type": "array"
}
},
"type": "array"
"required": [
"deltas"
],
"type": "object"
}
}
},
Expand Down
232 changes: 116 additions & 116 deletions daemon/algod/api/server/v2/generated/data/routes.go

Large diffs are not rendered by default.

336 changes: 168 additions & 168 deletions daemon/algod/api/server/v2/generated/experimental/routes.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions daemon/algod/api/server/v2/generated/model/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

233 changes: 117 additions & 116 deletions daemon/algod/api/server/v2/generated/nonparticipating/private/routes.go

Large diffs are not rendered by default.

493 changes: 247 additions & 246 deletions daemon/algod/api/server/v2/generated/nonparticipating/public/routes.go

Large diffs are not rendered by default.

238 changes: 119 additions & 119 deletions daemon/algod/api/server/v2/generated/participating/private/routes.go

Large diffs are not rendered by default.

255 changes: 128 additions & 127 deletions daemon/algod/api/server/v2/generated/participating/public/routes.go

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,12 @@ func (v2 *Handlers) GetTransactionGroupLedgerStateDeltasForRound(ctx echo.Contex
if err != nil {
return notFound(ctx, err, errFailedRetrievingStateDelta, v2.Log)
}
data, err := encode(handle, deltas)
response := struct {
Deltas []eval.TxnGroupDeltaWithIds
}{
Deltas: deltas,
}
data, err := encode(handle, response)
if err != nil {
return internalError(ctx, err, errFailedToEncodeResponse, v2.Log)
}
Expand Down
8 changes: 4 additions & 4 deletions daemon/algod/api/server/v2/test/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2114,12 +2114,12 @@ func TestDeltasForTxnGroup(t *testing.T) {
)
require.NoError(t, err)

var roundResponse model.TransactionGroupLedgerStateDeltaForRoundResponse
var roundResponse model.TransactionGroupLedgerStateDeltasForRoundResponse
err = json.Unmarshal(rec.Body.Bytes(), &roundResponse)
require.NoError(t, err)
require.Equal(t, 1, len(roundResponse))
require.Equal(t, []string{txn1.ID().String()}, roundResponse[0].Ids)
hdr, ok := roundResponse[0].Delta["Hdr"].(map[string]interface{})
require.Equal(t, 1, len(roundResponse.Deltas))
require.Equal(t, []string{txn1.ID().String()}, roundResponse.Deltas[0].Ids)
hdr, ok := roundResponse.Deltas[0].Delta["Hdr"].(map[string]interface{})
require.True(t, ok)
require.Equal(t, delta1.Hdr.Round, basics.Round(hdr["rnd"].(float64)))

Expand Down

0 comments on commit a497df0

Please sign in to comment.