-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ff76fa
commit dc299e9
Showing
7 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package types | ||
|
||
import ( | ||
"crypto/rand" | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewQueryDepositRequest(t *testing.T) { | ||
var ( | ||
address []byte | ||
) | ||
|
||
for i := 0; i < 40; i++ { | ||
address = make([]byte, i) | ||
_, _ = rand.Read(address) | ||
|
||
require.Equal( | ||
t, | ||
&QueryDepositRequest{ | ||
Address: sdk.AccAddress(address).String(), | ||
}, | ||
NewQueryDepositRequest(address), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryDepositsRequest(t *testing.T) { | ||
var ( | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 20; i++ { | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
_, _ = rand.Read(pagination.Key) | ||
|
||
require.Equal( | ||
t, | ||
&QueryDepositsRequest{ | ||
Pagination: pagination, | ||
}, | ||
NewQueryDepositsRequest(pagination), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package types | ||
|
||
import ( | ||
"crypto/rand" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/stretchr/testify/require" | ||
|
||
hubtypes "github.com/sentinel-official/hub/types" | ||
) | ||
|
||
func TestNewQueryNodeRequest(t *testing.T) { | ||
var ( | ||
address []byte | ||
) | ||
|
||
for i := 0; i < 40; i++ { | ||
address = make([]byte, i) | ||
_, _ = rand.Read(address) | ||
|
||
require.Equal( | ||
t, | ||
&QueryNodeRequest{ | ||
Address: hubtypes.NodeAddress(address).String(), | ||
}, | ||
NewQueryNodeRequest(address), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryNodesForProviderRequest(t *testing.T) { | ||
var ( | ||
address []byte | ||
status hubtypes.Status | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 40; i++ { | ||
address = make([]byte, i) | ||
status = hubtypes.Status(i % 4) | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
|
||
_, _ = rand.Read(address) | ||
_, _ = rand.Read(pagination.Key) | ||
|
||
require.Equal( | ||
t, | ||
&QueryNodesForProviderRequest{ | ||
Address: hubtypes.ProvAddress(address).String(), | ||
Status: status, | ||
Pagination: pagination, | ||
}, | ||
NewQueryNodesForProviderRequest(address, status, pagination), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryNodesRequest(t *testing.T) { | ||
var ( | ||
status hubtypes.Status | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 20; i++ { | ||
status = hubtypes.Status(i % 4) | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
|
||
_, _ = rand.Read(pagination.Key) | ||
|
||
require.Equal( | ||
t, | ||
&QueryNodesRequest{ | ||
Status: status, | ||
Pagination: pagination, | ||
}, | ||
NewQueryNodesRequest(status, pagination), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryParamsRequest(t *testing.T) { | ||
require.Equal(t, | ||
&QueryParamsRequest{}, | ||
NewQueryParamsRequest(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package types | ||
|
||
import ( | ||
"crypto/rand" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/stretchr/testify/require" | ||
|
||
hubtypes "github.com/sentinel-official/hub/types" | ||
) | ||
|
||
func TestNewQueryNodesForPlanRequest(t *testing.T) { | ||
var ( | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 20; i++ { | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
|
||
require.Equal( | ||
t, | ||
&QueryNodesForPlanRequest{ | ||
Id: uint64(i), | ||
Pagination: pagination, | ||
}, | ||
NewQueryNodesForPlanRequest(uint64(i), pagination), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryPlanRequest(t *testing.T) { | ||
for i := 0; i < 20; i++ { | ||
require.Equal( | ||
t, | ||
&QueryPlanRequest{ | ||
Id: uint64(i), | ||
}, | ||
NewQueryPlanRequest(uint64(i)), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryPlansForProviderRequest(t *testing.T) { | ||
var ( | ||
address []byte | ||
status hubtypes.Status | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 40; i++ { | ||
address = make([]byte, i) | ||
status = hubtypes.Status(i % 4) | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
|
||
_, _ = rand.Read(address) | ||
_, _ = rand.Read(pagination.Key) | ||
|
||
require.Equal( | ||
t, | ||
&QueryPlansForProviderRequest{ | ||
Address: hubtypes.ProvAddress(address).String(), | ||
Status: status, | ||
Pagination: pagination, | ||
}, | ||
NewQueryPlansForProviderRequest(address, status, pagination), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryPlansRequest(t *testing.T) { | ||
var ( | ||
status hubtypes.Status | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 20; i++ { | ||
status = hubtypes.Status(i % 4) | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
|
||
_, _ = rand.Read(pagination.Key) | ||
|
||
require.Equal( | ||
t, | ||
&QueryPlansRequest{ | ||
Status: status, | ||
Pagination: pagination, | ||
}, | ||
NewQueryPlansRequest(status, pagination), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package types | ||
|
||
import ( | ||
"crypto/rand" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/stretchr/testify/require" | ||
|
||
hubtypes "github.com/sentinel-official/hub/types" | ||
) | ||
|
||
func TestNewQueryParamsRequest(t *testing.T) { | ||
require.Equal(t, | ||
&QueryParamsRequest{}, | ||
NewQueryParamsRequest(), | ||
) | ||
} | ||
|
||
func TestNewQueryProviderRequest(t *testing.T) { | ||
var ( | ||
address []byte | ||
) | ||
|
||
for i := 0; i < 40; i++ { | ||
address = make([]byte, i) | ||
_, _ = rand.Read(address) | ||
|
||
require.Equal( | ||
t, | ||
&QueryProviderRequest{ | ||
Address: hubtypes.ProvAddress(address).String(), | ||
}, | ||
NewQueryProviderRequest(address), | ||
) | ||
} | ||
} | ||
|
||
func TestNewQueryProvidersRequest(t *testing.T) { | ||
var ( | ||
pagination *query.PageRequest | ||
) | ||
|
||
for i := 0; i < 20; i++ { | ||
pagination = &query.PageRequest{ | ||
Key: make([]byte, i), | ||
Offset: uint64(i), | ||
Limit: uint64(i), | ||
CountTotal: i/2 == 0, | ||
} | ||
|
||
_, _ = rand.Read(pagination.Key) | ||
|
||
require.Equal( | ||
t, | ||
&QueryProvidersRequest{ | ||
Pagination: pagination, | ||
}, | ||
NewQueryProvidersRequest(pagination), | ||
) | ||
} | ||
} |
Oops, something went wrong.