Skip to content

Commit

Permalink
[1789]: Fix the genaccounts tests too. They broke because of the adde…
Browse files Browse the repository at this point in the history
…d market fields.
  • Loading branch information
SpicyLemon committed Jan 26, 2024
1 parent 79c690e commit f8ef174
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
10 changes: 7 additions & 3 deletions cmd/provenanced/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,10 @@ $ ` + version.AppName + ` add-genesis-custom-market \
// and gives all permissions to each of the provided addrs.
func makeDefaultMarket(feeDenom string, addrs []string) exchange.Market {
market := exchange.Market{
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
}

if len(feeDenom) > 0 {
Expand All @@ -792,6 +793,9 @@ func makeDefaultMarket(feeDenom string, addrs []string) exchange.Market {
market.FeeSellerSettlementRatios = settlementRatio
market.FeeBuyerSettlementFlat = settlementFlat
market.FeeBuyerSettlementRatios = settlementRatio
market.FeeCreateCommitmentFlat = creationFee
market.CommitmentSettlementBips = 50
market.IntermediaryDenom = feeDenom
}

for _, addr := range addrs {
Expand Down
44 changes: 34 additions & 10 deletions cmd/provenanced/cmd/genaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func fixEmptiesInExchangeGenState(exGenState *exchange.GenesisState) {
if market.FeeCreateBidFlat == nil {
exGenState.Markets[i].FeeCreateBidFlat = make([]sdk.Coin, 0)
}
if market.FeeCreateCommitmentFlat == nil {
exGenState.Markets[i].FeeCreateCommitmentFlat = make([]sdk.Coin, 0)
}
if market.FeeSellerSettlementFlat == nil {
exGenState.Markets[i].FeeSellerSettlementFlat = make([]sdk.Coin, 0)
}
Expand All @@ -215,6 +218,9 @@ func fixEmptiesInExchangeGenState(exGenState *exchange.GenesisState) {
if market.ReqAttrCreateBid == nil {
exGenState.Markets[i].ReqAttrCreateBid = make([]string, 0)
}
if market.ReqAttrCreateCommitment == nil {
exGenState.Markets[i].ReqAttrCreateCommitment = make([]string, 0)
}
if market.AccessGrants == nil {
exGenState.Markets[i].AccessGrants = make([]exchange.AccessGrant, 0)
}
Expand All @@ -224,6 +230,9 @@ func fixEmptiesInExchangeGenState(exGenState *exchange.GenesisState) {
}
}
}
if exGenState.Commitments == nil {
exGenState.Commitments = make([]exchange.Commitment, 0)
}

if exGenState.Orders == nil {
exGenState.Orders = make([]exchange.Order, 0)
Expand Down Expand Up @@ -450,30 +459,33 @@ func TestMakeDefaultMarket(t *testing.T) {
feeDenom: "",
addrs: nil,
expMarket: exchange.Market{
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
},
},
{
name: "no denom, one addr",
feeDenom: "",
addrs: addrs[0:1],
expMarket: exchange.Market{
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
AccessGrants: []exchange.AccessGrant{{Address: addrs[0], Permissions: exchange.AllPermissions()}},
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
AccessGrants: []exchange.AccessGrant{{Address: addrs[0], Permissions: exchange.AllPermissions()}},
},
},
{
name: "no denom, three addrs",
feeDenom: "",
addrs: addrs,
expMarket: exchange.Market{
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
MarketDetails: exchange.MarketDetails{Name: "Default Market"},
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
AccessGrants: []exchange.AccessGrant{
{Address: addrs[0], Permissions: exchange.AllPermissions()},
{Address: addrs[1], Permissions: exchange.AllPermissions()},
Expand All @@ -495,6 +507,10 @@ func TestMakeDefaultMarket(t *testing.T) {
FeeBuyerSettlementRatios: ratios("else", 20, 1),
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
FeeCreateCommitmentFlat: coins(100, "else"),
CommitmentSettlementBips: 50,
IntermediaryDenom: "else",
},
},
{
Expand All @@ -511,7 +527,11 @@ func TestMakeDefaultMarket(t *testing.T) {
FeeBuyerSettlementRatios: ratios("vspn", 20, 1),
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
AccessGrants: []exchange.AccessGrant{{Address: addrs[0], Permissions: exchange.AllPermissions()}},
FeeCreateCommitmentFlat: coins(100, "vspn"),
CommitmentSettlementBips: 50,
IntermediaryDenom: "vspn",
},
},
{
Expand All @@ -528,11 +548,15 @@ func TestMakeDefaultMarket(t *testing.T) {
FeeBuyerSettlementRatios: ratios("nhash", 20, 1),
AcceptingOrders: true,
AllowUserSettlement: true,
AcceptingCommitments: true,
AccessGrants: []exchange.AccessGrant{
{Address: addrs[0], Permissions: exchange.AllPermissions()},
{Address: addrs[1], Permissions: exchange.AllPermissions()},
{Address: addrs[2], Permissions: exchange.AllPermissions()},
},
FeeCreateCommitmentFlat: coins(100, "nhash"),
CommitmentSettlementBips: 50,
IntermediaryDenom: "nhash",
},
},
}
Expand Down

0 comments on commit f8ef174

Please sign in to comment.