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

Fixed the URL parameter for hint epoch #466

Open
wants to merge 2 commits into
base: rc/v1.7.next1
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion api/groups/urlParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func parseAccountQueryOptions(c *gin.Context, address string) (common.AccountQue
return common.AccountQueryOptions{}, err
}

hintEpoch, err := parseUint32UrlParam(c, common.UrlParameterOnStartOfEpoch)
hintEpoch, err := parseUint32UrlParam(c, common.UrlParameterHintEpoch)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, UrlParameterOnStartOfEpoch was handled above. Good catch!

if err != nil {
return common.AccountQueryOptions{}, err
}
Expand Down
17 changes: 17 additions & 0 deletions api/groups/urlParams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import (
"testing"

"github.com/gin-gonic/gin"
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-proxy-go/common"
"github.com/stretchr/testify/require"
)

func TestParseBlockQueryOptions(t *testing.T) {
t.Parallel()

options, err := parseBlockQueryOptions(createDummyGinContextWithQuery("withTxs=true&withLogs=true"))
require.Nil(t, err)
require.Equal(t, common.BlockQueryOptions{WithTransactions: true, WithLogs: true}, options)
Expand All @@ -25,6 +28,20 @@ func TestParseBlockQueryOptions(t *testing.T) {
require.Empty(t, options)
}

func TestParseAccountOptions(t *testing.T) {
t.Parallel()

expectedOptions := common.AccountQueryOptions{
HintEpoch: core.OptionalUint32{
Value: 3737,
HasValue: true,
},
}
options, err := parseAccountQueryOptions(createDummyGinContextWithQuery("hintEpoch=3737"), "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

require.Nil(t, err)
require.Equal(t, expectedOptions, options)
}

func TestParseHyperblockQueryOptions(t *testing.T) {
t.Parallel()

Expand Down
Loading