-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bump to v0.46.11; migrate (by replace) to cometbft (v0.34.27) * dont rewrite the wheel for CoinFromRequestKey * fix off by one error in local claim validation - fixes QCK-29 * add tests for local claim validation - ref QCK-29 * ensure liquid token submodule can support 0.46 balances * remove println * Update utils/coins.go Co-authored-by: Alex Johnson <[email protected]> * chore: formatting * remove unused CoinFromRequestKey method; add tests for DenomFromRequestKey; handle case where key is invalid and contains no denom * inadvertently changed comment --------- Co-authored-by: Alex Johnson <[email protected]>
- Loading branch information
Joe Bowman
and
Alex Johnson
authored
Mar 10, 2023
1 parent
504c998
commit 7d5d28b
Showing
14 changed files
with
448 additions
and
181 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package utils_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
utils "github.com/ingenuity-build/quicksilver/utils" | ||
) | ||
|
||
func TestDenomFromRequestKey(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
fn func() (sdk.AccAddress, string, []byte) | ||
err string | ||
}{ | ||
{ | ||
"valid", | ||
func() (sdk.AccAddress, string, []byte) { | ||
accAddr := utils.GenerateAccAddressForTest() | ||
prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) | ||
key := append(prefix, []byte("denom")...) | ||
return accAddr, "denom", key | ||
}, | ||
"", | ||
}, | ||
{ | ||
"invalid - address mismatch", | ||
func() (sdk.AccAddress, string, []byte) { | ||
keyAddr, err := utils.AccAddressFromBech32("cosmos135rd8ft0dyq8fv3w3hhmaa55qu3pe668j99qh67mg747ew4ad03qsgq8vh", "cosmos") | ||
require.NoError(t, err) | ||
checkAddr, err := utils.AccAddressFromBech32("cosmos1ent5eg0xn3pskf3fhdw8mky88ry7t4kx628ru3pzp4nqjp6eufusphlldy", "cosmos") | ||
require.NoError(t, err) | ||
prefix := banktypes.CreateAccountBalancesPrefix(keyAddr.Bytes()) | ||
key := append(prefix, []byte("denom")...) | ||
return checkAddr, "denom", key | ||
}, | ||
"account mismatch; expected cosmos135rd8ft0dyq8fv3w3hhmaa55qu3pe668j99qh67mg747ew4ad03qsgq8vh, got cosmos1ent5eg0xn3pskf3fhdw8mky88ry7t4kx628ru3pzp4nqjp6eufusphlldy", | ||
}, | ||
{ | ||
"invalid - empty address", | ||
func() (sdk.AccAddress, string, []byte) { | ||
accAddr := sdk.AccAddress{} | ||
prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) | ||
key := append(prefix, []byte("denom")...) | ||
return accAddr, "denom", key | ||
}, | ||
"invalid key", | ||
}, | ||
{ | ||
"invalid - empty denom", | ||
func() (sdk.AccAddress, string, []byte) { | ||
accAddr := utils.GenerateAccAddressForTest() | ||
prefix := banktypes.CreateAccountBalancesPrefix(accAddr.Bytes()) | ||
key := append(prefix, []byte("")...) | ||
return accAddr, "", key | ||
}, | ||
"key contained no denom", | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
address, expectedDenom, key := c.fn() | ||
actualDenom, error := utils.DenomFromRequestKey(key, address) | ||
if len(c.err) == 0 { | ||
require.NoError(t, error) | ||
require.Equal(t, expectedDenom, actualDenom) | ||
} else { | ||
require.Errorf(t, error, c.err) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.