Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoxesResponse: Fold names into top-level object #4249

Merged
merged 2 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,20 @@
}
}
},
"BoxDescriptor": {
"description": "Box descriptor describes a Box.",
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"description": "Base64 encoded box name",
"type": "string",
"format": "byte"
}
}
},
"Version": {
"description": "algod version information.",
"type": "object",
Expand Down Expand Up @@ -3259,10 +3273,17 @@
"BoxesResponse": {
"description": "Box names of an application",
algochoi marked this conversation as resolved.
Show resolved Hide resolved
"schema": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
"type": "object",
"required": [
"boxes"
],
"properties": {
"boxes": {
"type": "array",
"items": {
"$ref": "#/definitions/BoxDescriptor"
}
}
}
}
},
Expand Down
47 changes: 37 additions & 10 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,18 @@
"content": {
"application/json": {
"schema": {
"items": {
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
"properties": {
"boxes": {
"items": {
"$ref": "#/components/schemas/BoxDescriptor"
},
"type": "array"
}
},
"type": "array"
"required": [
"boxes"
],
"type": "object"
}
}
},
Expand Down Expand Up @@ -1208,6 +1214,21 @@
],
"type": "object"
},
"BoxDescriptor": {
"description": "Box descriptor describes a Box.",
"properties": {
"name": {
"description": "Base64 encoded box name",
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
},
"BuildVersion": {
"properties": {
"branch": {
Expand Down Expand Up @@ -2535,12 +2556,18 @@
"content": {
"application/json": {
"schema": {
"items": {
"format": "byte",
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$",
"type": "string"
"properties": {
"boxes": {
"items": {
"$ref": "#/components/schemas/BoxDescriptor"
},
"type": "array"
}
},
"type": "array"
"required": [
"boxes"
],
"type": "object"
}
}
},
Expand Down
303 changes: 152 additions & 151 deletions daemon/algod/api/server/v2/generated/private/routes.go

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion daemon/algod/api/server/v2/generated/private/types.go

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

415 changes: 208 additions & 207 deletions daemon/algod/api/server/v2/generated/routes.go

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion daemon/algod/api/server/v2/generated/types.go

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

8 changes: 5 additions & 3 deletions daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1164,11 +1164,13 @@ func (v2 *Handlers) GetApplicationBoxes(ctx echo.Context, applicationID uint64,
}

prefixLen := len(keyPrefix)
responseBoxes := make([][]byte, len(boxKeys))
responseBoxes := make([]generated.BoxDescriptor, len(boxKeys))
for i, boxKey := range boxKeys {
responseBoxes[i] = []byte(boxKey[prefixLen:])
responseBoxes[i] = generated.BoxDescriptor{
Name: []byte(boxKey[prefixLen:]),
}
}
response := generated.BoxesResponse(responseBoxes)
response := generated.BoxesResponse{Boxes: responseBoxes}
return ctx.JSON(http.StatusOK, response)
}

Expand Down
10 changes: 5 additions & 5 deletions test/e2e-go/restAPI/restClient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1417,9 +1417,9 @@ end:
var resp generated.BoxesResponse
resp, err = testClient.ApplicationBoxes(uint64(createdAppID))
a.NoError(err)
a.Equal(createdBoxCount, uint64(len(resp)))
for _, byteName := range resp {
a.True(createdBoxName[string(byteName)])
a.Equal(createdBoxCount, uint64(len(resp.Boxes)))
for _, b := range resp.Boxes {
a.True(createdBoxName[string(b.Name)])
}
}

Expand Down Expand Up @@ -1463,7 +1463,7 @@ end:

resp, err := testClient.ApplicationBoxes(uint64(createdAppID))
a.NoError(err)
a.Empty(resp)
a.Empty(resp.Boxes)

for i := 0; i < len(testingBoxNames); i += 16 {
var strSliceTest []string
Expand All @@ -1489,7 +1489,7 @@ end:

resp, err = testClient.ApplicationBoxes(uint64(createdAppID))
a.NoError(err)
a.Empty(resp)
a.Empty(resp.Boxes)

// Get Box value from box name
encodeInt := func(n uint64) []byte {
Expand Down