diff --git a/x/bep3/simulation/genesis.go b/x/bep3/simulation/genesis.go index 1e31120f..12b529f1 100644 --- a/x/bep3/simulation/genesis.go +++ b/x/bep3/simulation/genesis.go @@ -52,16 +52,16 @@ func GenMaxBlockLock(r *rand.Rand, minBlockLock uint64) uint64 { // GenSupportedAssets gets randomized SupportedAssets func GenSupportedAssets(r *rand.Rand) types.AssetParams { - var assets types.AssetParams + numAssets := (r.Intn(10) + 1) + assets := make(types.AssetParams, numAssets+1) for i := 0; i < numAssets; i++ { denom := strings.ToLower(simulation.RandStringOfLength(r, (r.Intn(3) + 3))) asset := genSupportedAsset(r, denom) - assets = append(assets, asset) + assets[i] = asset } // Add bnb, btc, or xrp as a supported asset for interactions with other modules - stableAsset := genSupportedAsset(r, ConsistentDenoms[r.Intn(3)]) - assets = append(assets, stableAsset) + assets[len(assets)-1] = genSupportedAsset(r, ConsistentDenoms[r.Intn(3)]) return assets } @@ -91,6 +91,7 @@ func RandomizedGenState(simState *module.SimulationState) { // Update supply to match amount of coins in auth var supplyGenesis supply.GenesisState simState.Cdc.MustUnmarshalJSON(simState.GenState[supply.ModuleName], &supplyGenesis) + for _, deputyCoin := range totalCoins { supplyGenesis.Supply = supplyGenesis.Supply.Add(deputyCoin...) } @@ -122,8 +123,7 @@ func loadRandomBep3GenState(simState *module.SimulationState) types.GenesisState return bep3Genesis } -func loadAuthGenState(simState *module.SimulationState, bep3Genesis types.GenesisState) ( - auth.GenesisState, []sdk.Coins) { +func loadAuthGenState(simState *module.SimulationState, bep3Genesis types.GenesisState) (auth.GenesisState, []sdk.Coins) { var authGenesis auth.GenesisState simState.Cdc.MustUnmarshalJSON(simState.GenState[auth.ModuleName], &authGenesis) diff --git a/x/bep3/types/swap.go b/x/bep3/types/swap.go index 5747a449..98ab3c8c 100644 --- a/x/bep3/types/swap.go +++ b/x/bep3/types/swap.go @@ -95,7 +95,7 @@ func (a AtomicSwap) Validate() error { if strings.TrimSpace(a.RecipientOtherChain) == "" { return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "recipient other chain cannot be blank") } - if a.ClosedBlock == 0 { + if a.Status == Completed && a.ClosedBlock == 0 { return errors.New("closed block cannot be 0") } if a.Status == NULL || a.Status > 3 { diff --git a/x/bep3/types/swap_test.go b/x/bep3/types/swap_test.go index b59dc6dc..01d13b88 100644 --- a/x/bep3/types/swap_test.go +++ b/x/bep3/types/swap_test.go @@ -194,6 +194,7 @@ func (suite *AtomicSwapTestSuite) TestNewAtomicSwap() { SenderOtherChain: "bnb1uky3me9ggqypmrsvxk7ur6hqkzq7zmv4ed4ng7", RecipientOtherChain: "bnb1urfermcg92dwq36572cx4xg84wpk3lfpksr5g7", ClosedBlock: 0, + Status: types.Completed, }, false, },