Prathamesh Musale
fd755d1c27
All checks were successful
Integration Tests / test-integration (pull_request) Successful in 2m1s
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
package auction
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
|
|
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
|
)
|
|
|
|
const (
|
|
randomAuctionID = "randomAuctionID"
|
|
randomBidderAddress = "randomBidderAddress"
|
|
randomOwnerAddress = "randomOwnerAddress"
|
|
)
|
|
|
|
func (ets *E2ETestSuite) TestQueryParamsGrpc() {
|
|
val := ets.network.Validators[0]
|
|
sr := ets.Require()
|
|
reqURL := fmt.Sprintf("%s/cerc/auction/v1/params", val.APIAddress)
|
|
|
|
ets.Run("valid request to get auction params", func() {
|
|
resp, err := testutil.GetRequest(reqURL)
|
|
ets.Require().NoError(err)
|
|
|
|
var params auctiontypes.QueryParamsResponse
|
|
err = val.ClientCtx.Codec.UnmarshalJSON(resp, ¶ms)
|
|
|
|
sr.NoError(err)
|
|
sr.Equal(*params.GetParams(), auctiontypes.DefaultParams())
|
|
})
|
|
}
|
|
|
|
func (ets *E2ETestSuite) TestGetAllAuctionsGrpc() {
|
|
val := ets.network.Validators[0]
|
|
sr := ets.Require()
|
|
reqURL := fmt.Sprintf("%s/cerc/auction/v1/auctions", val.APIAddress)
|
|
|
|
testCases := []struct {
|
|
msg string
|
|
url string
|
|
errorMsg string
|
|
isErrorExpected bool
|
|
}{
|
|
{
|
|
"invalid request to get all auctions",
|
|
reqURL + randomAuctionID,
|
|
"",
|
|
true,
|
|
},
|
|
{
|
|
"valid request to get all auctions",
|
|
reqURL,
|
|
"",
|
|
false,
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
ets.Run(tc.msg, func() {
|
|
resp, err := testutil.GetRequest(tc.url)
|
|
if tc.isErrorExpected {
|
|
sr.Contains(string(resp), tc.errorMsg)
|
|
} else {
|
|
sr.NoError(err)
|
|
var auctions auctiontypes.QueryAuctionsResponse
|
|
err = val.ClientCtx.Codec.UnmarshalJSON(resp, &auctions)
|
|
sr.NoError(err)
|
|
sr.NotZero(len(auctions.Auctions.Auctions))
|
|
}
|
|
})
|
|
}
|
|
}
|