Skip to content

Commit

Permalink
Added tests for few keys related functions in subscription module
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Aug 8, 2023
1 parent 34d1c89 commit f79d223
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
3 changes: 1 addition & 2 deletions x/node/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestActiveNodeKey(t *testing.T) {

func TestAddressFromNodeForInactiveAtKey(t *testing.T) {
var (
at = time.Now()
addr []byte
key []byte
)
Expand All @@ -48,7 +47,7 @@ func TestAddressFromNodeForInactiveAtKey(t *testing.T) {
addr = make([]byte, i)
_, _ = rand.Read(addr)

key = NodeForInactiveAtKey(at, addr)
key = NodeForInactiveAtKey(time.Now(), addr)
require.Equal(
t,
hubtypes.NodeAddress(addr),
Expand Down
38 changes: 38 additions & 0 deletions x/subscription/types/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,41 @@ func TestPayoutKey(t *testing.T) {
)
}
}

func TestIDFromPayoutForAccountByNodeKey(t *testing.T) {
var (
accAddr []byte
nodeAddr []byte
key []byte
)

for i := 1; i <= 256; i += 64 {
accAddr = make([]byte, i)
_, _ = rand.Read(accAddr)

nodeAddr = make([]byte, i)
_, _ = rand.Read(nodeAddr)

key = PayoutForAccountByNodeKey(accAddr, nodeAddr, uint64(i))
require.Equal(
t,
uint64(i),
IDFromPayoutForAccountByNodeKey(key),
)
}
}

func TestIDFromPayoutForNextAtKey(t *testing.T) {
var (
key []byte
)

for i := 1; i <= 256; i += 64 {
key = PayoutForNextAtKey(time.Now(), uint64(i))
require.Equal(
t,
uint64(i),
IDFromPayoutForNextAtKey(key),
)
}
}

0 comments on commit f79d223

Please sign in to comment.