-
Notifications
You must be signed in to change notification settings - Fork 12
/
data.go
33 lines (27 loc) · 900 Bytes
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors
// SPDX-License-Identifier: Apache-2.0
package base
import (
sdkTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/AssetMantle/modules/schema/data"
baseData "github.com/AssetMantle/modules/schema/data/base"
baseTypes "github.com/AssetMantle/modules/schema/types/base"
"math"
"math/rand"
)
func GenerateRandomData(r *rand.Rand) data.Data {
randomPositiveInt := int(math.Abs(float64(r.Int())))
switch randomPositiveInt % 4 {
case 0:
return baseData.NewIDData(GenerateRandomID(r))
case 1:
return baseData.NewStringData(simulation.RandStringOfLength(r, r.Intn(99)))
case 2:
return baseData.NewDecData(simulation.RandomDecAmount(r, sdkTypes.NewDec(99)))
case 3:
return baseData.NewHeightData(baseTypes.NewHeight(r.Int63()))
default:
return nil
}
}