-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-2p6r-37p9-89p2
* test: adding authz grant tests * fix TestCLITxGrantAuthorization/Invalid_expiration_time test case * comment out the test * reenable test
- Loading branch information
1 parent
4e08d1c
commit 68ab790
Showing
5 changed files
with
54 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package authz | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
// banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func expecError(r *require.Assertions, expected string, received error) { | ||
if expected == "" { | ||
r.NoError(received) | ||
} else { | ||
r.Error(received) | ||
r.Contains(received.Error(), expected) | ||
} | ||
} | ||
|
||
func TestNewGrant(t *testing.T) { | ||
// ba := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123))) | ||
a := NewGenericAuthorization("some-type") | ||
var tcs = []struct { | ||
title string | ||
a Authorization | ||
blockTime time.Time | ||
expire time.Time | ||
err string | ||
}{ | ||
// {"wrong expire time (1)", a, time.Unix(10, 0), time.Unix(8, 0), "expiration must be after"}, | ||
// {"wrong expire time (2)", a, time.Unix(10, 0), time.Unix(10, 0), "expiration must be after"}, | ||
{"good expire time (1)", a, time.Unix(10, 0), time.Unix(10, 1), ""}, | ||
{"good expire time (2)", a, time.Unix(10, 0), time.Unix(11, 0), ""}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
t.Run(tc.title, func(t *testing.T) { | ||
// _, err := NewGrant(tc.blockTime, tc.a, tc.expire) | ||
_, err := NewGrant(tc.a, tc.expire) | ||
expecError(require.New(t), tc.err, 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