[R4R] Bep3 sim changes (#442)

* fix: choose claim amount as percentage

* fix: lower asset supply to avoid overwhelming auctions
This commit is contained in:
Kevin Davis 2020-04-17 14:05:36 -04:00 committed by GitHub
parent 783247851d
commit 5ae0b76e0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View File

@ -24,7 +24,7 @@ const (
) )
var ( var (
MaxSupplyLimit = sdk.NewInt(10000000000000000) MaxSupplyLimit = sdk.NewInt(1000000000000)
Accs []simulation.Account Accs []simulation.Account
ConsistentDenoms = [3]string{"bnb", "xrp", "btc"} ConsistentDenoms = [3]string{"bnb", "xrp", "btc"}
) )

View File

@ -50,19 +50,12 @@ func SimulateMsgCreateAtomicSwap(ak auth.AccountKeeper, k keeper.Keeper) simulat
// Check that the sender has coins of this type // Check that the sender has coins of this type
availableAmount := ak.GetAccount(ctx, sender).GetCoins().AmountOf(asset.Denom) availableAmount := ak.GetAccount(ctx, sender).GetCoins().AmountOf(asset.Denom)
if !availableAmount.IsPositive() { // Get an amount of coins between 0.1 and 2% of total coins
return noOpMsg, nil, fmt.Errorf("available amount must be positive") amount := availableAmount.Quo(sdk.NewInt(int64(simulation.RandIntBetween(r, 50, 1000))))
if amount.IsZero() {
return simulation.NewOperationMsgBasic(bep3.ModuleName, fmt.Sprintf("no-operation (all funds exhausted for asset %s)", asset.Denom), "", false, nil), nil, nil
} }
coin := sdk.NewCoin(asset.Denom, amount)
// Get a random amount of the available coins
amount, err := simulation.RandPositiveInt(r, availableAmount)
if err != nil {
return noOpMsg, nil, err
}
// If we don't adjust the conversion factor, we'll be out of funds soon
adjustedAmount := amount.Int64() / int64(math.Pow10(8))
coin := sdk.NewInt64Coin(asset.Denom, adjustedAmount)
coins := sdk.NewCoins(coin) coins := sdk.NewCoins(coin)
expectedIncome := coin.String() expectedIncome := coin.String()