-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-allowance-typo
- Loading branch information
Showing
31 changed files
with
946 additions
and
143 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
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
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
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
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
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
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
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
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,89 @@ | ||
package kv_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/kv" | ||
) | ||
|
||
func TestAssertKeyAtLeastLength(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
key []byte | ||
length int | ||
expectPanic bool | ||
}{ | ||
{ | ||
name: "Store key length is less than the given length", | ||
key: []byte("hello"), | ||
length: 10, | ||
expectPanic: true, | ||
}, | ||
{ | ||
name: "Store key length is equal to the given length", | ||
key: []byte("store-key"), | ||
length: 9, | ||
expectPanic: false, | ||
}, | ||
{ | ||
name: "Store key length is greater than the given length", | ||
key: []byte("unique"), | ||
length: 3, | ||
expectPanic: false, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
if tc.expectPanic { | ||
assert.Panics(t, func() { | ||
kv.AssertKeyAtLeastLength(tc.key, tc.length) | ||
}) | ||
return | ||
} | ||
kv.AssertKeyAtLeastLength(tc.key, tc.length) | ||
}) | ||
} | ||
} | ||
|
||
func TestAssertKeyLength(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
key []byte | ||
length int | ||
expectPanic bool | ||
}{ | ||
{ | ||
name: "Store key length is less than the given length", | ||
key: []byte("hello"), | ||
length: 10, | ||
expectPanic: true, | ||
}, | ||
{ | ||
name: "Store key length is equal to the given length", | ||
key: []byte("store-key"), | ||
length: 9, | ||
expectPanic: false, | ||
}, | ||
{ | ||
name: "Store key length is greater than the given length", | ||
key: []byte("unique"), | ||
length: 3, | ||
expectPanic: true, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
if tc.expectPanic { | ||
assert.Panics(t, func() { | ||
kv.AssertKeyLength(tc.key, tc.length) | ||
}) | ||
return | ||
} | ||
kv.AssertKeyLength(tc.key, tc.length) | ||
}) | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.