-
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.
test(x/ecocredit): basket put acceptance tests (#1065)
* test(x/ecocredit): basket acceptance tests * update put acceptance tests * add put check balance steps * add put balance and supply steps * consolidate steps with background * simplify steps and use scenario outlines * Update x/ecocredit/server/basket/keeper_test.go Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> * add credit type util test * clean up id and key names * check ok on new int * update credit and token amount scenarios * clean up and add exceeds max decimal * clean up language * fix merge * fix miscommit Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
- Loading branch information
1 parent
3841ec5
commit fae569f
Showing
16 changed files
with
1,112 additions
and
681 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,148 @@ | ||
Feature: MsgPut | ||
|
||
Scenario: a valid message | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT", | ||
"credits": [ | ||
{ | ||
"batch_denom": "C01-001-20200101-20210101-001", | ||
"amount": "100" | ||
} | ||
] | ||
} | ||
""" | ||
When the message is validated | ||
Then expect no error | ||
|
||
Scenario: an error is returned if owner is empty | ||
Given the message | ||
""" | ||
{} | ||
""" | ||
When the message is validated | ||
Then expect the error "empty address string is not allowed: invalid request" | ||
|
||
Scenario: an error is returned if owner is not a bech32 address | ||
Given the message | ||
""" | ||
{ | ||
"owner": "foo" | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "decoding bech32 failed: invalid bech32 string length 3: invalid request" | ||
|
||
Scenario: an error is returned if basket denom is empty | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27" | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "basket denom cannot be empty: invalid request" | ||
|
||
Scenario: an error is returned if basket denom is not formatted | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "1" | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "1 is not a valid basket denom: invalid request" | ||
|
||
Scenario: an error is returned if credit list is empty | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT" | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "credits cannot be empty: invalid request" | ||
|
||
Scenario: an error is returned if a credit batch denom is empty | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT", | ||
"credits": [ | ||
{} | ||
] | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "credit batch denom cannot be empty: invalid request" | ||
|
||
Scenario: an error is returned if a credit batch denom is not formatted | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT", | ||
"credits": [ | ||
{ | ||
"batch_denom": "foo" | ||
} | ||
] | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "invalid denom: expected format A00-000-00000000-00000000-000: parse error: invalid request" | ||
|
||
Scenario: an error is returned if a credit amount is empty | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT", | ||
"credits": [ | ||
{ | ||
"batch_denom": "C01-001-20200101-20210101-001" | ||
} | ||
] | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "credit amount cannot be empty: invalid request" | ||
|
||
Scenario: an error is returned if a credit amount is not an integer | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT", | ||
"credits": [ | ||
{ | ||
"batch_denom": "C01-001-20200101-20210101-001", | ||
"amount": "foo" | ||
} | ||
] | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "parse mantissa: foo: invalid decimal string: invalid decimal string: invalid request" | ||
|
||
Scenario: an error is returned if a credit amount is less than zero | ||
Given the message | ||
""" | ||
{ | ||
"owner": "cosmos1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27", | ||
"basket_denom": "NCT", | ||
"credits": [ | ||
{ | ||
"batch_denom": "C01-001-20200101-20210101-001", | ||
"amount": "-100" | ||
} | ||
] | ||
} | ||
""" | ||
When the message is validated | ||
Then expect the error "expected a positive decimal, got -100: invalid decimal string: invalid request" |
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.