Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dwedul/1699 exchange keeper tests #1713

Merged
merged 112 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
c051276
[1699]: Unit tests on params.
SpicyLemon Oct 15, 2023
cd2bf81
[1699]: Unit tests on the flat fee getters.
SpicyLemon Oct 15, 2023
5fadb5f
[1699]: Unit tests on the ratio fee getters and calculators.
SpicyLemon Oct 16, 2023
0b6d733
[1699]: Unit tests on the flat fee validators.
SpicyLemon Oct 16, 2023
6ae52a1
[1699]: Unit tests on ValidateAskPrice.
SpicyLemon Oct 16, 2023
55ff8d8
[1699]: Change TestSuite.ratio to use ParseFeeRatio.
SpicyLemon Oct 16, 2023
903ab16
[1699]: Unit tests on ValidateBuyerSettlementFee.
SpicyLemon Oct 17, 2023
700a272
[1699]: Unit tests on UpdateFees.
SpicyLemon Oct 17, 2023
c9a9539
[1699]: Create Keeper.IsMarketKnown and tweak the comments on IsMarke…
SpicyLemon Oct 18, 2023
49d2d5e
[1699]: Unit tests on IsMarketKnown and IsMarketActive.
SpicyLemon Oct 18, 2023
5665ab5
[1699]: Unit tests on UpdateMarketActive.
SpicyLemon Oct 18, 2023
31da371
[1699]: Unit tests 0on IsUserSettlementAllowed and UpdateUserSettleme…
SpicyLemon Oct 18, 2023
7069fb5
[1699]: Unit tests on HasPermission and each of the specific Can... p…
SpicyLemon Oct 18, 2023
5b55161
Merge branch 'main' into dwedul/1699-exchange-keeper-tests
SpicyLemon Oct 18, 2023
831ab5e
[1699]: Fix getAccessGrants.
SpicyLemon Oct 19, 2023
4f8d7eb
[1699]: Unit tests on GetUserPermissions and GetAccessGrants.
SpicyLemon Oct 19, 2023
2096280
Merge branch 'main' into dwedul/1699-exchange-keeper-tests
SpicyLemon Oct 19, 2023
f5fe101
[1699]: Unit tests on UpdatePermissions.
SpicyLemon Oct 19, 2023
a0b670f
[1699]: Unit tests on GetReqAttrsAsk, GetReqAttrsBid, CanCreateAsk, a…
SpicyLemon Oct 19, 2023
b561010
[1699]: Make NewEventMarketPermissionsUpdated just take in the admin …
SpicyLemon Oct 19, 2023
26f581d
[1699]: Make NewEventMarketReqAttrUpdated just take in the admin as a…
SpicyLemon Oct 19, 2023
bedd1da
[1699]: Unit tests on UpdateReqAttrs.
SpicyLemon Oct 19, 2023
43a83aa
[1699]: Unit tests on GetMarketAccount.
SpicyLemon Oct 19, 2023
a46ebdf
[1699]: Unit tests on GetMarketDetails.
SpicyLemon Oct 19, 2023
a5524b5
[1699]: Remove 'Calls' from the field names of the mock keeper ...Cal…
SpicyLemon Oct 19, 2023
c1072d4
[1699]: Update NewEventMarketDetailsUpdated to take in a string since…
SpicyLemon Oct 19, 2023
7fdaf06
[1699]: Update NewEventMarketActiveUpdated, NewEventMarketEnabled, an…
SpicyLemon Oct 19, 2023
90096a7
[1699]: Change NewEventMarketWithdraw to take in withdrawnBy as a str…
SpicyLemon Oct 19, 2023
3bd8877
[1699]: Update NewEventMarketUserSettleUpdated, NewEventMarketUserSet…
SpicyLemon Oct 19, 2023
0f383a6
[1699]: Update exchange.NewEventOrderCancelled to take in cancelledBy…
SpicyLemon Oct 19, 2023
e071e75
[1699]: A little cleanup in TestTypedEventToEvent.
SpicyLemon Oct 19, 2023
04c9168
[1699]: Unit tests on UpdateMarketDetails.
SpicyLemon Oct 19, 2023
d0060c1
[1699]: Change NewAccountResultsMap to NewAccountModifierMap and have…
SpicyLemon Oct 19, 2023
5867b5d
[1699]: Unit tests on CreateMarket.
SpicyLemon Oct 19, 2023
16af39f
[1699]: Unit tests on GetMarket and IterateMarkets.
SpicyLemon Oct 20, 2023
7bdd07b
[1699]: A little cleanup in TestKeeper_CreateMarket since I have SetA…
SpicyLemon Oct 20, 2023
9427087
[1699]: Unit tests on GetMarketBrief.
SpicyLemon Oct 20, 2023
ca912f1
[1699]: Unit tests on WithdrawMarketFunds.
SpicyLemon Oct 20, 2023
1442a3f
[1699]: Unit tests on ValidateMarket.
SpicyLemon Oct 20, 2023
70f27c0
[1699]: Clean up the market unit tests by not passing the *TestSuite …
SpicyLemon Oct 20, 2023
bde70b1
[1699] Unit tests on GetOrder.
SpicyLemon Oct 20, 2023
d2364cb
[1699]: Unit tests on GetOrderByExternalID.
SpicyLemon Oct 20, 2023
ff07d5f
[1699]: Fix setOrderInStore to check the store correctly for an exist…
SpicyLemon Oct 20, 2023
045e7a5
[1699]: Add IsReqAttrMatch unit test case.
SpicyLemon Oct 20, 2023
d631b81
[1699]: Unit tests on CreateAskOrder and CreateBidOrder.
SpicyLemon Oct 20, 2023
ecef7aa
[1699]: Unit tests on CancelOrder.
SpicyLemon Oct 20, 2023
64b0c84
[1699]: Unit tests on SetOrderExternalID.
SpicyLemon Oct 20, 2023
3677641
[1699]: In parseOrderStoreKeyValue, include the failed order id when …
SpicyLemon Oct 20, 2023
0bd00ad
[1699]: Unit tests on IterateOrders.
SpicyLemon Oct 20, 2023
4fecabd
[1699]: Unit tests on IterateMarketOrders, IterateAddressOrders, and …
SpicyLemon Oct 21, 2023
66a0d8a
[1699]: In InitGenesis, ensure that the last order id is at least the…
SpicyLemon Oct 23, 2023
54e9f5f
[1699]: Unit tests on InitGenesis and ExportGenesis.
SpicyLemon Oct 23, 2023
b4303c5
[1699]: Create expEvents using var instead of empty slice since asser…
SpicyLemon Oct 23, 2023
247dc14
[1699]: Unit tests on FillBids.
SpicyLemon Oct 23, 2023
2fee16d
[1699]: Unit tests on FillAsks.
SpicyLemon Oct 24, 2023
6a3c196
[1699]: Unit tests on SettleOrders.
SpicyLemon Oct 24, 2023
5d9fb97
[1699]: Take the stdlibCtx out of the TestSuite and delete the unused…
SpicyLemon Oct 24, 2023
385cc52
[1699]: In OrderFeeCalc, return an error if the market does not exist.
SpicyLemon Oct 24, 2023
e4928cc
[1699]: Unit tests on the OrderFeeCalc query.
SpicyLemon Oct 24, 2023
d8c0ca7
[1699]: In GetOrderByExternalID, return an error if either the market…
SpicyLemon Oct 24, 2023
cfd6130
[1699]: Unit tests on GetOrder and GetOrderByExternalID.
SpicyLemon Oct 24, 2023
5b8b646
[1699]: Fix the order index queries to properly get the orders.
SpicyLemon Oct 25, 2023
92ff222
[1699]: Modify filteredPaginateAfterOrder with key to return a NextKe…
SpicyLemon Oct 25, 2023
2e5d254
[1699]: In getOrderIterator, for the reverse iterator, the 'start' or…
SpicyLemon Oct 25, 2023
76d477d
[1699]: Unit tests on the GetMarketOrders query.
SpicyLemon Oct 25, 2023
1e57227
[1699]: Include the invalid owner in the error from GetOwnerOrders.
SpicyLemon Oct 25, 2023
c7bfdc9
[1699]: Unit tests on the GetOwnerOrders query.
SpicyLemon Oct 25, 2023
f021726
[1699]: Unit tests on the GetAssetOrders query.
SpicyLemon Oct 25, 2023
09c2d53
[1699]: Add a unit test on each of the order iterator queries for a c…
SpicyLemon Oct 25, 2023
d119d35
[1699]: Fix GetAllOrders.
SpicyLemon Oct 25, 2023
d5d0d19
[1699]: Unit tests on GetAllOrders.
SpicyLemon Oct 25, 2023
50d26b4
[1699]: Change the querySetupFunc to not take in the context, and jus…
SpicyLemon Oct 25, 2023
9252364
[1699]: Set the address in the QueryGetMarketResponse.
SpicyLemon Oct 25, 2023
464e1dc
[1699]: Unit tests on the GetMarket query. Create requireCreateMarket…
SpicyLemon Oct 25, 2023
349a14b
[1699]: Unit tests on the GetAllMarkets query.
SpicyLemon Oct 25, 2023
cbd542e
[1699]: Unit tests on the Params query.
SpicyLemon Oct 25, 2023
7ff1549
[1699]: Unit tests on the ValidateCreateMarket query.
SpicyLemon Oct 25, 2023
d92ea10
[1699]: Unit tests on the ValidateMarket query.
SpicyLemon Oct 25, 2023
68e2e2c
[1699]: Unit tests on the ValidateManageFees query.
SpicyLemon Oct 25, 2023
638e948
[1699]: Remove todo about discussing the DefaultDefaultSplit value. B…
SpicyLemon Oct 26, 2023
eedf1b6
[1699]: Comment change on the querySetupFunc definition.
SpicyLemon Oct 26, 2023
58b93d1
[1699]: Unit tests on the CreateAsk and CreateBid endpoints.
SpicyLemon Oct 26, 2023
e21dc85
[1699]: Unit tests on the CancelOrder endpoint.
SpicyLemon Oct 27, 2023
72162fb
[1699]: change IsMarketActive to only return true if the market is bo…
SpicyLemon Oct 27, 2023
901c5e9
[1699]: Add saffron-rc2 no-op upgrade entry.
SpicyLemon Oct 27, 2023
13bbd81
[1699]: In FillBids, calculate the seller settlement ratio fee off th…
SpicyLemon Oct 27, 2023
89a367f
[1699]: Unit tests on FillBids. Extract the balance checking stuff so…
SpicyLemon Oct 27, 2023
31c8f2a
[1699]: Unit tests on FillAsks.
SpicyLemon Oct 27, 2023
74f122a
[1699]: Unit tests on the MarketSettle endpoint.
SpicyLemon Oct 27, 2023
25bf391
[1699]: Fix error message from MarketSetOrderExternalID when admin do…
SpicyLemon Oct 27, 2023
4a8f0a7
[1699]: Unit tests on the MarketSetOrderExternalID endpoint.
SpicyLemon Oct 27, 2023
b3c86c2
[1699] Unit tests on the MarketWithdraw endpoint.
SpicyLemon Oct 28, 2023
53e906c
[1699]: Unit tests on the MarketUpdateDetails endpoint. Replace uses …
SpicyLemon Oct 28, 2023
7e1ba22
[1699]: Unit tests on the MarketUpdateEnabled and MarketUpdateUserSet…
SpicyLemon Oct 28, 2023
afea6c0
[1699]: Unit tests on the MarketManagePermissions and MarketManageReq…
SpicyLemon Oct 28, 2023
33ca337
[1699]: Unit tests on the GovCreateMarket, GovManageFees, and GovUpda…
SpicyLemon Oct 28, 2023
3bd1269
[1699]: Mark v1.17.0-rc1 in the changelog.
SpicyLemon Oct 28, 2023
8cf8c1d
[1699]: Add changelog entry.
SpicyLemon Oct 28, 2023
63d9301
[1699]: clean up some of the expected event creation stuff.
SpicyLemon Oct 30, 2023
6ca98bb
[1699]: Move all the generic keeper test helper funcs to a new suite_…
SpicyLemon Oct 30, 2023
d612a4f
[1699]: Remove some unneeded things from the TestSuite.
SpicyLemon Oct 30, 2023
957425b
[1699]: Some comment clarifications.
SpicyLemon Oct 30, 2023
7117309
[1699]: Make TestSuite.badKey for changing a key into a bad version o…
SpicyLemon Oct 30, 2023
a9b5010
[1699]: Do some of the market id comparisons as ints for better failu…
SpicyLemon Oct 30, 2023
2e358e9
[1699]: Refactor grpc_query_test to be similar to msg_server_test wit…
SpicyLemon Oct 30, 2023
4aa1a95
[1699]: Add some test cases to the ValidateManageFees query where eve…
SpicyLemon Oct 30, 2023
ebf259c
[1699]: Underscore some unused followup func arguments in msg_server_…
SpicyLemon Oct 30, 2023
20820ad
[1699]: Create agCanOnly, agCanAllBut, and agCanEverything and use th…
SpicyLemon Oct 30, 2023
a090bba
[1699]: Clean up some of the follow-up args type defs.
SpicyLemon Oct 30, 2023
257a331
Merge branch 'main' into dwedul/1699-exchange-keeper-tests
SpicyLemon Oct 31, 2023
48c9693
Merge branch 'main' into dwedul/1699-exchange-keeper-tests
SpicyLemon Oct 31, 2023
7400d7e
Merge branch 'main' into dwedul/1699-exchange-keeper-tests
iramiller Nov 1, 2023
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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* Add the (empty) `saffron-rc2` upgrade [#1699](https://github.com/provenance-io/provenance/issues/1699).

### Improvements

* Wrote unit tests on the keeper methods [#1699](https://github.com/provenance-io/provenance/issues/1699).
* During `FillBids`, the seller settlement fee is now calculated on the total price instead of each order individually [#1699](https://github.com/provenance-io/provenance/issues/1699).
* In the `OrderFeeCalc` query, ensure the market exists [#1699](https://github.com/provenance-io/provenance/issues/1699).

### Bug Fixes

* During `InitGenesis`, ensure LastOrderId is at least the largest order id [#1699](https://github.com/provenance-io/provenance/issues/1699).
* Properly populate the permissions lists when reading access grants from state [#1699](https://github.com/provenance-io/provenance/issues/1699).
* Fixed the paginated order queries to properly look up orders [#1699](https://github.com/provenance-io/provenance/issues/1699).

---

## [v1.17.0-rc1](https://github.com/provenance-io/provenance/releases/tag/v1.17.0-rc1) - 2023-10-18

### Features

* Create the `x/exchange` module which facilitates the buying and selling of assets [#1658](https://github.com/provenance-io/provenance/issues/1658).
Assets and funds remain in their owner's account (with a hold on them) until the order is settled (or cancelled).
Market's are created to manage order matching and define fees.
Expand Down Expand Up @@ -117,6 +137,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
- Bump `golang.org/x/net` from 0.15.0 to 0.17.0 ([#1704](https://github.com/provenance-io/provenance/pull/1704))
- Bump `bufbuild/buf-lint-action` from 1.0.3 to 1.1.0 ([#1705](https://github.com/provenance-io/provenance/pull/1705))

### Full Commit History

* https://github.com/provenance-io/provenance/compare/v1.16.0...v1.17.0-rc1

---

## [v1.16.0](https://github.com/provenance-io/provenance/releases/tag/v1.16.0) - 2023-06-23
Expand Down
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var upgrades = map[string]appUpgrade{
},
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName},
},
"saffron-rc2": {}, // upgrade for v1.17.0-rc2
"saffron": { // upgrade for v1.17.0,
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
Expand Down
40 changes: 20 additions & 20 deletions x/exchange/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func NewEventOrderCreated(order OrderI) *EventOrderCreated {
}
}

func NewEventOrderCancelled(order OrderI, cancelledBy sdk.AccAddress) *EventOrderCancelled {
func NewEventOrderCancelled(order OrderI, cancelledBy string) *EventOrderCancelled {
return &EventOrderCancelled{
OrderId: order.GetOrderID(),
CancelledBy: cancelledBy.String(),
CancelledBy: cancelledBy,
MarketId: order.GetMarketID(),
ExternalId: order.GetExternalID(),
}
Expand Down Expand Up @@ -54,79 +54,79 @@ func NewEventOrderExternalIDUpdated(order OrderI) *EventOrderExternalIDUpdated {
}
}

func NewEventMarketWithdraw(marketID uint32, amount sdk.Coins, destination, withdrawnBy sdk.AccAddress) *EventMarketWithdraw {
func NewEventMarketWithdraw(marketID uint32, amount sdk.Coins, destination sdk.AccAddress, withdrawnBy string) *EventMarketWithdraw {
return &EventMarketWithdraw{
MarketId: marketID,
Amount: amount.String(),
Destination: destination.String(),
WithdrawnBy: withdrawnBy.String(),
WithdrawnBy: withdrawnBy,
}
}

func NewEventMarketDetailsUpdated(marketID uint32, updatedBy sdk.AccAddress) *EventMarketDetailsUpdated {
func NewEventMarketDetailsUpdated(marketID uint32, updatedBy string) *EventMarketDetailsUpdated {
return &EventMarketDetailsUpdated{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

// NewEventMarketActiveUpdated returns a new EventMarketEnabled if isActive == true,
// or a new EventMarketDisabled if isActive == false.
func NewEventMarketActiveUpdated(marketID uint32, updatedBy sdk.AccAddress, isActive bool) proto.Message {
func NewEventMarketActiveUpdated(marketID uint32, updatedBy string, isActive bool) proto.Message {
if isActive {
return NewEventMarketEnabled(marketID, updatedBy)
}
return NewEventMarketDisabled(marketID, updatedBy)
}

func NewEventMarketEnabled(marketID uint32, updatedBy sdk.AccAddress) *EventMarketEnabled {
func NewEventMarketEnabled(marketID uint32, updatedBy string) *EventMarketEnabled {
return &EventMarketEnabled{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

func NewEventMarketDisabled(marketID uint32, updatedBy sdk.AccAddress) *EventMarketDisabled {
func NewEventMarketDisabled(marketID uint32, updatedBy string) *EventMarketDisabled {
return &EventMarketDisabled{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

// NewEventMarketUserSettleUpdated returns a new EventMarketUserSettleEnabled if isAllowed == true,
// or a new EventMarketUserSettleDisabled if isActive == false.
func NewEventMarketUserSettleUpdated(marketID uint32, updatedBy sdk.AccAddress, isAllowed bool) proto.Message {
func NewEventMarketUserSettleUpdated(marketID uint32, updatedBy string, isAllowed bool) proto.Message {
if isAllowed {
return NewEventMarketUserSettleEnabled(marketID, updatedBy)
}
return NewEventMarketUserSettleDisabled(marketID, updatedBy)
}

func NewEventMarketUserSettleEnabled(marketID uint32, updatedBy sdk.AccAddress) *EventMarketUserSettleEnabled {
func NewEventMarketUserSettleEnabled(marketID uint32, updatedBy string) *EventMarketUserSettleEnabled {
return &EventMarketUserSettleEnabled{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

func NewEventMarketUserSettleDisabled(marketID uint32, updatedBy sdk.AccAddress) *EventMarketUserSettleDisabled {
func NewEventMarketUserSettleDisabled(marketID uint32, updatedBy string) *EventMarketUserSettleDisabled {
return &EventMarketUserSettleDisabled{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

func NewEventMarketPermissionsUpdated(marketID uint32, updatedBy sdk.AccAddress) *EventMarketPermissionsUpdated {
func NewEventMarketPermissionsUpdated(marketID uint32, updatedBy string) *EventMarketPermissionsUpdated {
return &EventMarketPermissionsUpdated{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

func NewEventMarketReqAttrUpdated(marketID uint32, updatedBy sdk.AccAddress) *EventMarketReqAttrUpdated {
func NewEventMarketReqAttrUpdated(marketID uint32, updatedBy string) *EventMarketReqAttrUpdated {
return &EventMarketReqAttrUpdated{
MarketId: marketID,
UpdatedBy: updatedBy.String(),
UpdatedBy: updatedBy,
}
}

Expand Down
Loading
Loading