Skip to content
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ca8df09
supply and withdraw tests
toteki Aug 25, 2022
d17672e
err--
toteki Aug 25, 2022
3f6e746
make proto-all
toteki Aug 25, 2022
18ad3f9
error improvements and fix cascading client test error DEVX
toteki Aug 29, 2022
01a0d9d
TestCollateralize
toteki Aug 29, 2022
55e0242
++
toteki Aug 29, 2022
3ac25d8
TestDe+Collateralize
toteki Aug 29, 2022
fb2465d
case++
toteki Aug 29, 2022
196a2dd
borrow test + more cases
toteki Aug 29, 2022
0c89068
add invariant checks to every msg test case
toteki Aug 29, 2022
a7c28ad
move files
toteki Aug 29, 2022
c24c19b
++
toteki Aug 29, 2022
7bf90ef
TestRepay
toteki Aug 29, 2022
da7a29d
--
toteki Aug 29, 2022
8bdbc1f
Liquidate single-denom test cases
toteki Aug 29, 2022
29075d0
liquidate cases
toteki Aug 30, 2022
f4d3fbf
--
toteki Aug 30, 2022
b6c065b
remove setupAccount and initBorrowScenario
toteki Aug 30, 2022
e0f12e0
Merge branch 'main' into adam/tests
toteki Aug 30, 2022
c317fae
imports
toteki Aug 30, 2022
84b454b
lint++
toteki Aug 30, 2022
137b60b
fix test
toteki Aug 30, 2022
16f6087
++
toteki Aug 30, 2022
c951541
cl++
toteki Aug 30, 2022
abc1520
remove unnecessary interface
toteki Aug 30, 2022
58d3dab
move function
toteki Aug 30, 2022
c38f47f
Merge branch 'main' into adam/tests
toteki Aug 30, 2022
357b4c3
apply s.app, s.ctx, and s.Require() shorthands
toteki Aug 30, 2022
b0058d0
Merge branch 'adam/tests' of github.com:umee-network/umee into adam/t…
toteki Aug 30, 2022
2d7c253
apply coin shorthand in keeper_test package
toteki Aug 30, 2022
104e8f2
use setReserves helper
toteki Aug 30, 2022
f19ad73
improve big number readability
toteki Aug 30, 2022
d69a209
Merge branch 'main' into adam/tests
toteki Aug 30, 2022
29464d2
ensure espected value is on the left for all require.Equal
toteki Aug 30, 2022
95aa22b
use borrow and repay helpers
toteki Aug 30, 2022
28c4707
lint++
toteki Aug 30, 2022
2031109
always require.ErrorIs
toteki Aug 30, 2022
e4c6f67
use forceBorrow helper rather than SetTokenSettings in high utilizati…
toteki Aug 30, 2022
09daf91
Merge branch 'main' into adam/tests
toteki Aug 30, 2022
ed7b666
Merge branch 'main' into adam/tests
toteki Aug 30, 2022
187c0fe
fix #1310
toteki Aug 31, 2022
ace8889
Merge branch 'main' into adam/tests
toteki Aug 31, 2022
b3379b6
fix sim tests
toteki Sep 1, 2022
e526216
Merge branch 'main' into adam/tests
toteki Sep 1, 2022
ccec6f0
Merge branch 'main' into adam/tests
toteki Sep 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1012](https://github.com/umee-network/umee/pull/1012) Improve negative time elapsed error message
- [1236](https://github.com/umee-network/umee/pull/1236) Improve leverage event fields.
- [1294](https://github.com/umee-network/umee/pull/1294) Simplify window progress query math.
- [1300](https://github.com/umee-network/umee/pull/1300) Improve leverage test suite and error specificity.

### Bug Fixes

Expand Down
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ func (app *UmeeApp) setAnteHandler(txConfig client.TxConfig) {
OracleKeeper: app.OracleKeeper,
},
)

if err != nil {
panic(err)
}
Expand Down
119 changes: 101 additions & 18 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,60 @@ paths:
type: string
tags:
- Query
/umee/leverage/v1/bad_debts:
get:
summary: >-
BadDebts queries a list of borrow positions that have been marked for
bad debt repayment.
operationId: BadDebts
responses:
'200':
description: A successful response.
schema:
type: object
properties:
targets:
type: array
items:
type: object
properties:
address:
type: string
denom:
type: string
description: >-
BadDebt is a bad debt instance used in the leverage module's
genesis state.
description: >-
Targets are borrow positions currently marked for bad debt
repayment. Each contains an Address and a Denom.
description: >-
QueryBadDebtsResponse defines the response structure for the
BedDebts gRPC service handler.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
tags:
- Query
/umee/leverage/v1/liquidation_targets:
get:
summary: >-
Expand All @@ -205,9 +259,7 @@ paths:
liquidation.
description: >-
QueryLiquidationTargetsResponse defines the response structure for
the

LiquidationTargets gRPC service handler.
the LiquidationTargets gRPC service handler.
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -475,13 +527,13 @@ paths:
direct_liquidation_fee:
type: string
description: >-
Direct Liquidation Fee is the reduction in liquidation
incentive experienced
Direct Liquidation Fee is a reduction factor in
liquidation incentive

by liquidators who choose to receive base assets instead
of uTokens as
experienced by liquidators who choose to receive base
assets instead of

liquidation rewards.
uTokens as liquidation rewards.
description: Params defines the parameters for the leverage module.
description: >-
QueryParamsResponse defines the response structure for the Params
Expand Down Expand Up @@ -1368,6 +1420,16 @@ definitions:
value:
type: string
format: byte
umee.leverage.v1.BadDebt:
type: object
properties:
address:
type: string
denom:
type: string
description: >-
BadDebt is a bad debt instance used in the leverage module's genesis
state.
umee.leverage.v1.Params:
type: object
properties:
Expand Down Expand Up @@ -1403,12 +1465,12 @@ definitions:
direct_liquidation_fee:
type: string
description: >-
Direct Liquidation Fee is the reduction in liquidation incentive
experienced
Direct Liquidation Fee is a reduction factor in liquidation incentive

by liquidators who choose to receive base assets instead of uTokens as
experienced by liquidators who choose to receive base assets instead
of

liquidation rewards.
uTokens as liquidation rewards.
description: Params defines the parameters for the leverage module.
umee.leverage.v1.QueryAccountBalancesResponse:
type: object
Expand Down Expand Up @@ -1504,6 +1566,27 @@ definitions:
description: >-
QueryAccountSummaryResponse defines the response structure for the
AccountSummary gRPC service handler.
umee.leverage.v1.QueryBadDebtsResponse:
type: object
properties:
targets:
type: array
items:
type: object
properties:
address:
type: string
denom:
type: string
description: >-
BadDebt is a bad debt instance used in the leverage module's genesis
state.
description: >-
Targets are borrow positions currently marked for bad debt repayment.
Each contains an Address and a Denom.
description: >-
QueryBadDebtsResponse defines the response structure for the BedDebts gRPC
service handler.
umee.leverage.v1.QueryLiquidationTargetsResponse:
type: object
properties:
Expand All @@ -1512,7 +1595,7 @@ definitions:
items:
type: string
description: Targets are the addresses of borrowers eligible for liquidation.
description: |-
description: >-
QueryLiquidationTargetsResponse defines the response structure for the
LiquidationTargets gRPC service handler.
umee.leverage.v1.QueryMarketSummaryResponse:
Expand Down Expand Up @@ -1703,13 +1786,13 @@ definitions:
direct_liquidation_fee:
type: string
description: >-
Direct Liquidation Fee is the reduction in liquidation incentive
experienced
Direct Liquidation Fee is a reduction factor in liquidation
incentive

by liquidators who choose to receive base assets instead of
uTokens as
experienced by liquidators who choose to receive base assets
instead of

liquidation rewards.
uTokens as liquidation rewards.
description: Params defines the parameters for the leverage module.
description: |-
QueryParamsResponse defines the response structure for the Params gRPC
Expand Down
105 changes: 36 additions & 69 deletions x/leverage/client/tests/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
type IntegrationTestSuite struct {
suite.Suite

abort bool // stop interdependent tests on the first error for clarity

cfg network.Config
network *network.Network
}
Expand All @@ -44,38 +42,37 @@ func (s *IntegrationTestSuite) TearDownSuite() {
s.network.Cleanup()
}

// TestCases are queries and transactions that can be run, and return a boolean
// which indicates to abort the test suite if true
type TestCase interface {
Run(s *IntegrationTestSuite) bool
// runTestQuery
func (s *IntegrationTestSuite) runTestQueries(tqs ...testQuery) {
for _, t := range tqs {
t.Run(s)
}
}

// runTestCases runs test transactions or queries, stopping early if an error occurs
func (s *IntegrationTestSuite) runTestCases(tcs ...TestCase) {
for _, t := range tcs {
if !s.abort {
s.abort = t.Run(s)
}
func (s *IntegrationTestSuite) runTestTransactions(txs ...testTransaction) {
for _, t := range txs {
t.Run(s)
}
}

type testTransaction struct {
name string
msg string
command *cobra.Command
args []string
expectedErr *errors.Error
}

type testQuery struct {
name string
msg string
command *cobra.Command
args []string
expectErr bool
responseType proto.Message
expectedResponse proto.Message
}

func (t testTransaction) Run(s *IntegrationTestSuite) (abort bool) {
func (t testTransaction) Run(s *IntegrationTestSuite) {
clientCtx := s.network.Validators[0].ClientCtx

txFlags := []string{
Expand All @@ -87,36 +84,21 @@ func (t testTransaction) Run(s *IntegrationTestSuite) (abort bool) {

t.args = append(t.args, txFlags...)

s.Run(t.name, func() {
out, err := clitestutil.ExecTestCLICmd(clientCtx, t.command, t.args)
s.Require().NoError(err)
if err != nil {
abort = true
}

resp := &sdk.TxResponse{}
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), resp)
s.Require().NoError(err, out.String())
if err != nil {
abort = true
}

if t.expectedErr == nil {
s.Require().Equal(0, int(resp.Code), "events %v", resp.Events)
if int(resp.Code) != 0 {
abort = true
}
} else {
s.Require().Equal(int(t.expectedErr.ABCICode()), int(resp.Code))
if int(resp.Code) != int(t.expectedErr.ABCICode()) {
abort = true
}
}
})
return abort
out, err := clitestutil.ExecTestCLICmd(clientCtx, t.command, t.args)
s.Require().NoError(err, t.msg)

resp := &sdk.TxResponse{}
err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), resp)
s.Require().NoError(err, t.msg)

if t.expectedErr == nil {
s.Require().Equal(0, int(resp.Code), t.msg)
} else {
s.Require().Equal(int(t.expectedErr.ABCICode()), int(resp.Code), t.msg)
}
}

func (t testQuery) Run(s *IntegrationTestSuite) (abort bool) {
func (t testQuery) Run(s *IntegrationTestSuite) {
clientCtx := s.network.Validators[0].ClientCtx

queryFlags := []string{
Expand All @@ -125,31 +107,16 @@ func (t testQuery) Run(s *IntegrationTestSuite) (abort bool) {

t.args = append(t.args, queryFlags...)

s.Run(t.name, func() {
out, err := clitestutil.ExecTestCLICmd(clientCtx, t.command, t.args)

if t.expectErr {
s.Require().Error(err)
if err == nil {
abort = true
}
} else {
s.Require().NoError(err)
if err != nil {
abort = true
}

err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), t.responseType)
s.Require().NoError(err, out.String())
if err != nil {
abort = true
}

s.Require().Equal(t.expectedResponse, t.responseType)
if !s.Assert().Equal(t.expectedResponse, t.responseType) {
abort = true
}
}
})
return abort
out, err := clitestutil.ExecTestCLICmd(clientCtx, t.command, t.args)

if t.expectErr {
s.Require().Error(err, t.msg)
} else {
s.Require().NoError(err, t.msg)

err = clientCtx.Codec.UnmarshalJSON(out.Bytes(), t.responseType)
s.Require().NoError(err, t.msg)

s.Require().Equal(t.expectedResponse, t.responseType)
}
}
Loading