Skip to content

Commit

Permalink
Fix user order spend
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Jun 11, 2024
1 parent a58e73a commit 649ef61
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x/market/keeper/msg_server_simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestSimulate(t *testing.T) {

users := []User{user1, user2, user3}

for i := 1; i < 100; i++ {
for i := 1; i < 10000; i++ {

j := rand.IntN(6)
k := rand.IntN(2)
Expand All @@ -98,7 +98,9 @@ func TestSimulate(t *testing.T) {
userAddr, _ := sdk.AccAddressFromBech32(users[k].Addr)

spendable := testInput.BankKeeper.SpendableCoins(testInput.Context, userAddr)

if len(spendable) < 2 {
continue
}
l := rand.Uint64N(99)
if l == 0 {
continue
Expand Down Expand Up @@ -165,6 +167,12 @@ func TestSimulate(t *testing.T) {
// Cancel Order
if len(users[k].Orders) > 0 {
p := rand.IntN(len(users[k].Orders))
order, found := testInput.MarketKeeper.GetOrder(testInput.Context, users[k].Orders[p])
require.True(t, found)
if order.Status == "filled" || order.Status == "cancelled" {
users[k].Orders, _ = removeUid(users[k].Orders, users[k].Orders[p])
continue
}
co := types.MsgCancelOrder{Creator: addr, Uid: strconv.FormatUint(users[k].Orders[p], 10)}
_, err = keeper.NewMsgServerImpl(*testInput.MarketKeeper).CancelOrder(sdk.WrapSDKContext(testInput.Context), &co)
require.NoError(t, err)
Expand Down

0 comments on commit 649ef61

Please sign in to comment.