Skip to content

Commit

Permalink
failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Jan 31, 2024
1 parent c5b3f41 commit 32d7bf1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
21 changes: 12 additions & 9 deletions x/ecocredit/marketplace/keeper/features/msg_buy_direct.feature
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Feature: Msg/BuyDirect
Background:
Given a credit type
And alice created a sell order with quantity "10"
And bob has a bank balance with amount "150"
And bob has bank balance "150regen"

Scenario Outline: quantity less than or equal to sell order quantity
When bob attempts to buy credits with quantity "<quantity>"
Expand Down Expand Up @@ -220,7 +220,7 @@ Feature: Msg/BuyDirect

Scenario: buyer bank balance updated
Given alice created a sell order with quantity "10" and ask price "10regen"
And bob has the bank balance "100regen"
And bob has bank balance "100regen"
When bob attempts to buy credits with quantity "10" and bid price "10regen"
Then expect bob bank balance "0regen"

Expand Down Expand Up @@ -383,10 +383,13 @@ Feature: Msg/BuyDirect
}
"""

Rule: Buyer fees are added to order cost

Rule: Seller fees are deducted from order cost

Rule: uregen is burned

Rule: non-uregen denoms are kept
Rule: Buyer fees are deducted from buyer, seller fees are deducted from seller, and both go to fee pool
Scenario:
Given alice created a sell order with quantity "10" and ask amount "10"
* bob has bank balance "110regen"
* alice has bank balance "0regen"
* buyer fees are 0.1 and seller fees are 0.05
When bob attempts to buy credits with quantity "10" and bid amount "10"
Then expect alice bank balance "95regen"
* expect bob bank balance "0regen"
* expect no error
10 changes: 9 additions & 1 deletion x/ecocredit/marketplace/keeper/msg_buy_direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

sdkmath "cosmossdk.io/math"
"github.com/cockroachdb/apd/v3"
"github.com/gogo/protobuf/jsonpb"
"github.com/regen-network/gocuke"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -96,7 +97,7 @@ func (s *buyDirectSuite) AliceHasBankBalance(a string) {
s.aliceBankBalance = coin
}

func (s *buyDirectSuite) BobHasTheBankBalance(a string) {
func (s *buyDirectSuite) BobHasBankBalance(a string) {
coin, err := sdk.ParseCoinNormalized(a)
require.NoError(s.t, err)

Expand Down Expand Up @@ -448,6 +449,13 @@ func (s *buyDirectSuite) BobAttemptsToBuyCreditsInTwoOrdersEachWithQuantityAndBi
},
})
}
func (s *buyDirectSuite) BuyerFeesAreAndSellerFeesAre(buyerFee *apd.Decimal, sellerFee *apd.Decimal) {
err := s.k.stateStore.FeeParamsTable().Save(s.ctx, &api.FeeParams{
BuyerPercentageFee: buyerFee.String(),
SellerPercentageFee: sellerFee.String(),
})
require.NoError(s.t, err)
}

func (s *buyDirectSuite) ExpectNoError() {
require.NoError(s.t, s.err)
Expand Down

0 comments on commit 32d7bf1

Please sign in to comment.