-
Notifications
You must be signed in to change notification settings - Fork 103
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
150 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Feature: Msg/RemoveAllowedDenom | ||
|
||
An allowed denom can be removed: | ||
- when the authority is a governance account address | ||
- when the allowed denom exist | ||
- the denom is removed | ||
|
||
Rule: The authority must be governance account address | ||
|
||
Scenario: The authority is a governance account address | ||
Given an allowed denom with properties | ||
""" | ||
{ | ||
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68", | ||
"bank_denom":"uregen", | ||
"display_denom":"REGEN", | ||
"exponent":6 | ||
} | ||
""" | ||
When alice attempts to remove a bank denom with properties | ||
""" | ||
{ | ||
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68", | ||
"denom":"uregen" | ||
} | ||
""" | ||
Then expect no error | ||
And expect bank denom is removed "uregen" | ||
|
||
Scenario: The authority is not a governance account address | ||
When alice attempts to remove a bank denom with properties | ||
""" | ||
{ | ||
"authority":"regen1fua8speyxgempgy06gpfs0p4z32zznkqakm57s", | ||
"denom":"uregen" | ||
} | ||
""" | ||
Then expect error contains "expected gov account as only signer for proposal message" | ||
|
||
Rule: The bank denom exist | ||
|
||
Scenario: The bank denom exist | ||
Given an allowed denom with properties | ||
""" | ||
{ | ||
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68", | ||
"bank_denom":"uregen", | ||
"display_denom":"REGEN", | ||
"exponent":6 | ||
} | ||
""" | ||
When alice attempts to remove a bank denom with properties | ||
""" | ||
{ | ||
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68", | ||
"denom":"uregen" | ||
} | ||
""" | ||
Then expect no error | ||
And expect bank denom is removed "uregen" | ||
|
||
Scenario: The bank denom does not exist | ||
When alice attempts to remove a bank denom with properties | ||
""" | ||
{ | ||
"authority":"regen1nzh226hxrsvf4k69sa8v0nfuzx5vgwkczk8j68", | ||
"denom":"uregen" | ||
} | ||
""" | ||
Then expect the error "allowed denom uregen not found: not found" |
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
66 changes: 66 additions & 0 deletions
66
x/ecocredit/server/marketplace/msg_remove_allowed_denom_test.go
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 |
---|---|---|
@@ -1 +1,67 @@ | ||
package marketplace | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/orm/types/ormerrors" | ||
"github.com/regen-network/gocuke" | ||
"github.com/stretchr/testify/require" | ||
|
||
api "github.com/regen-network/regen-ledger/api/regen/ecocredit/marketplace/v1" | ||
"github.com/regen-network/regen-ledger/x/ecocredit/marketplace" | ||
) | ||
|
||
type removeAllowedDenomSuite struct { | ||
*baseSuite | ||
err error | ||
} | ||
|
||
func TestRemoveAllowedDenom(t *testing.T) { | ||
gocuke.NewRunner(t, &removeAllowedDenomSuite{}).Path("./features/msg_remove_allowed_denom.feature").Run() | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) Before(t gocuke.TestingT) { | ||
s.baseSuite = setupBase(t, 1) | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) AnAllowedDenomWithProperties(a gocuke.DocString) { | ||
var msg *marketplace.AllowedDenom | ||
|
||
err := json.Unmarshal([]byte(a.Content), &msg) | ||
require.NoError(s.t, err) | ||
|
||
err = s.k.stateStore.AllowedDenomTable().Insert(s.ctx, &api.AllowedDenom{ | ||
BankDenom: msg.BankDenom, | ||
DisplayDenom: msg.DisplayDenom, | ||
Exponent: msg.Exponent, | ||
}) | ||
require.NoError(s.t, err) | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) AliceAttemptsToRemoveABankDenomWithProperties(a gocuke.DocString) { | ||
var msg *marketplace.MsgRemoveAllowedDenom | ||
|
||
err := json.Unmarshal([]byte(a.Content), &msg) | ||
require.NoError(s.t, err) | ||
|
||
_, s.err = s.k.RemoveAllowedDenom(s.ctx, msg) | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) ExpectNoError() { | ||
require.NoError(s.t, s.err) | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) ExpectBankDenomIsRemoved(denom string) { | ||
_, err := s.marketStore.AllowedDenomTable().Get(s.ctx, denom) | ||
require.Error(s.t, err) | ||
require.ErrorIs(s.t, err, ormerrors.NotFound) | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) ExpectTheError(a string) { | ||
require.EqualError(s.t, s.err, a) | ||
} | ||
|
||
func (s *removeAllowedDenomSuite) ExpectErrorContains(a string) { | ||
require.ErrorContains(s.t, s.err, a) | ||
} |