Skip to content

Commit

Permalink
Fix errors in tests due to proto revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Jun 13, 2024
1 parent 3b69394 commit bc88d46
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 52 deletions.
10 changes: 5 additions & 5 deletions x/market/client/cli/query_drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func networkWithDropObjects(t *testing.T, n int) (*network.Network, []types.Drop

for i := 0; i < n; i++ {
drop := types.Drop{
Uid: uint64(i),
Owner: strconv.Itoa(i),
Pair: strconv.Itoa(i),
Drops: sdk.NewIntFromUint64(uint64(i)),
ProductBeg: sdk.NewIntFromUint64(uint64(i)),
Uid: uint64(i),
Owner: strconv.Itoa(i),
Pair: strconv.Itoa(i),
Drops: sdk.NewIntFromUint64(uint64(i)),
Product: sdk.NewIntFromUint64(uint64(i)),
}
nullify.Fill(&drop)
state.DropList = append(state.DropList, drop)
Expand Down
24 changes: 12 additions & 12 deletions x/market/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ func TestGenesis(t *testing.T) {
},
DropList: []types.Drop{
{
Uid: 0,
Owner: "0",
Pair: "0",
Drops: sdk.NewIntFromUint64(uint64(0)),
ProductBeg: sdk.NewIntFromUint64(uint64(0)),
Active: true,
Uid: 0,
Owner: "0",
Pair: "0",
Drops: sdk.NewIntFromUint64(uint64(0)),
Product: sdk.NewIntFromUint64(uint64(0)),
Active: true,
},
{
Uid: 1,
Owner: "1",
Pair: "1",
Drops: sdk.NewIntFromUint64(uint64(1)),
ProductBeg: sdk.NewIntFromUint64(uint64(0)),
Active: true,
Uid: 1,
Owner: "1",
Pair: "1",
Drops: sdk.NewIntFromUint64(uint64(1)),
Product: sdk.NewIntFromUint64(uint64(0)),
Active: true,
},
},
MemberList: []types.Member{
Expand Down
2 changes: 1 addition & 1 deletion x/market/keeper/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func createNDrop(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Drop {
items[i].Owner = strconv.Itoa(i)
items[i].Pair = strconv.Itoa(i)
items[i].Drops = sdk.NewIntFromUint64(uint64(i))
items[i].ProductBeg = sdk.NewIntFromUint64(uint64(i))
items[i].Product = sdk.NewIntFromUint64(uint64(i))

keeper.SetDrop(ctx, items[i])
}
Expand Down
11 changes: 2 additions & 9 deletions x/market/keeper/msg_server_create_drop_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keeper_test

import (
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -234,10 +233,7 @@ func TestCreateDrop_Pool_Not_Active(t *testing.T) {

pair, _, _, testdata := dropCommon(t, testInput)

pool, found := testInput.MarketKeeper.GetPool(testInput.Context, pair)
require.True(t, found)

var rd = types.MsgRedeemDrop{Creator: addr, Uid: strconv.FormatUint(pool.LastDrop, 10)}
var rd = types.MsgRedeemDrop{Creator: addr, Uid: "1"}
createRedeemDropResponse, redeemdropErr := keeper.NewMsgServerImpl(*testInput.MarketKeeper).RedeemDrop(sdk.WrapSDKContext(testInput.Context), &rd)
require.NoError(t, redeemdropErr)
require.Contains(t, createRedeemDropResponse.String(), rd.GetCreator())
Expand Down Expand Up @@ -299,11 +295,8 @@ func TestCreateDrop_Negative(t *testing.T) {

pair, denomA, denomB, _ := dropCommon(t, testInput)

pool, found := testInput.MarketKeeper.GetPool(testInput.Context, pair)
require.True(t, found)

//validate GetDrop
drop, dropFound := testInput.MarketKeeper.GetDrop(testInput.Context, pool.LastDrop)
drop, dropFound := testInput.MarketKeeper.GetDrop(testInput.Context, uint64(1))
require.True(t, dropFound)
require.Equal(t, drop.Pair, pair)
//validate CreateDrop
Expand Down
14 changes: 1 addition & 13 deletions x/market/keeper/msg_server_redeem_drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,9 @@ func TestRedeemDrop(t *testing.T) {
// Validate RedeemDrop
Uid := strconv.FormatUint(createDropResponse.Uid, 10)
var rd = types.MsgRedeemDrop{Creator: addr2, Uid: Uid}
redeemDropResponse, redeemdropErr := keeper.NewMsgServerImpl(*testInput.MarketKeeper).RedeemDrop(sdk.WrapSDKContext(testInput.Context), &rd)
_, redeemdropErr := keeper.NewMsgServerImpl(*testInput.MarketKeeper).RedeemDrop(sdk.WrapSDKContext(testInput.Context), &rd)
require.NoError(t, redeemdropErr)

coin1Beg, err := sdk.ParseCoinNormalized(redeemDropResponse.Coin1Beg)
require.NoError(t, err)

coin1End, err := sdk.ParseCoinNormalized(redeemDropResponse.Coin1End)
require.NoError(t, err)

// Drop coinEnd should be greater than coinBeg except in cases where there
// is no profit accrued in the pool since the drop was created.
// In that case round up +1 added to round down division requires coin1End+1
// to ensure invariant is not violated.
require.True(t, (coin1End.AddAmount(sdk.NewIntFromUint64(1))).IsGTE(coin1Beg))

// Validate Drop After Redeem Drop
drop1, drop1Found := testInput.MarketKeeper.GetDrop(testInput.Context, createDropResponse.Uid)
require.True(t, drop1Found)
Expand Down
24 changes: 12 additions & 12 deletions x/market/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ func TestGenesisState_Validate(t *testing.T) {
},
DropList: []types.Drop{
{
Uid: 0,
Owner: "0",
Pair: "0",
Drops: sdk.NewIntFromUint64(uint64(0)),
ProductBeg: sdk.NewIntFromUint64(uint64(0)),
Active: true,
Uid: 0,
Owner: "0",
Pair: "0",
Drops: sdk.NewIntFromUint64(uint64(0)),
Product: sdk.NewIntFromUint64(uint64(0)),
Active: true,
},
{
Uid: 1,
Owner: "1",
Pair: "1",
Drops: sdk.NewIntFromUint64(uint64(1)),
ProductBeg: sdk.NewIntFromUint64(uint64(0)),
Active: true,
Uid: 1,
Owner: "1",
Pair: "1",
Drops: sdk.NewIntFromUint64(uint64(1)),
Product: sdk.NewIntFromUint64(uint64(0)),
Active: true,
},
},
MemberList: []types.Member{
Expand Down

0 comments on commit bc88d46

Please sign in to comment.