-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
4 changed files
with
96 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"cosmossdk.io/math" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/noble-assets/aura/utils" | ||
"github.com/noble-assets/aura/utils/mocks" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSendRestriction(t *testing.T) { | ||
keeper, ctx := mocks.AuraKeeper(t) | ||
from, to := utils.TestAccount(), utils.TestAccount() | ||
|
||
// ACT: Attempt to send 1 USDC. | ||
_, err := keeper.SendRestrictionFn(ctx, from.Bytes, to.Bytes, sdk.NewCoins(sdk.NewCoin( | ||
"uusdc", math.NewInt(1_000_000), | ||
))) | ||
// ASSERT: Action should succeed as it's not USDY. | ||
require.NoError(t, err) | ||
|
||
// ACT: Attempt to send 1 USDY. | ||
_, err = keeper.SendRestrictionFn(ctx, from.Bytes, to.Bytes, sdk.NewCoins(sdk.NewCoin( | ||
keeper.Denom, ONE, | ||
))) | ||
// ASSERT: Action should succeed. | ||
require.NoError(t, err) | ||
|
||
// ARRANGE: Set paused state to true. | ||
require.NoError(t, keeper.Paused.Set(ctx, true)) | ||
|
||
// ACT: Attempt to send 1 USDY when paused. | ||
_, err = keeper.SendRestrictionFn(ctx, from.Bytes, to.Bytes, sdk.NewCoins(sdk.NewCoin( | ||
keeper.Denom, ONE, | ||
))) | ||
// ASSERT: Action should succeed. | ||
require.ErrorContains(t, err, "ausdy transfers are paused") | ||
|
||
// ARRANGE: Set paused state to false. | ||
require.NoError(t, keeper.Paused.Set(ctx, false)) | ||
// ARRANGE: Block from address. | ||
require.NoError(t, keeper.BlockedAddresses.Set(ctx, from.Bytes, true)) | ||
|
||
// ACT: Attempt to send 1 USDY from blocklisted address. | ||
_, err = keeper.SendRestrictionFn(ctx, from.Bytes, to.Bytes, sdk.NewCoins(sdk.NewCoin( | ||
keeper.Denom, ONE, | ||
))) | ||
// ASSERT: Action should've failed due to blocked sender. | ||
require.ErrorContains(t, err, "blocked from sending") | ||
|
||
// ARRANGE: Unblock from address. | ||
require.NoError(t, keeper.BlockedAddresses.Remove(ctx, from.Bytes)) | ||
// ARRANGE: Block to address. | ||
require.NoError(t, keeper.BlockedAddresses.Set(ctx, to.Bytes, true)) | ||
|
||
// ACT: Attempt to send 1 USDY to blocklisted address. | ||
_, err = keeper.SendRestrictionFn(ctx, from.Bytes, to.Bytes, sdk.NewCoins(sdk.NewCoin( | ||
keeper.Denom, ONE, | ||
))) | ||
// ASSERT: Action should've failed due to blocked recipient. | ||
require.ErrorContains(t, err, "blocked from receiving") | ||
} |
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