-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed wrong protobuf type reference in simulations
Signed-off-by: jay-dee7 <[email protected]>
- Loading branch information
jay-dee7
committed
May 31, 2021
1 parent
51c643c
commit 5cedac1
Showing
11 changed files
with
134 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/simulation" | ||
hubtypes "github.com/sentinel-official/hub/types" | ||
) | ||
|
||
func getRandomDeposit(r *rand.Rand) int64 { | ||
return int64(r.Intn(100) + 1) | ||
} | ||
|
||
func getRandomInactiveDuration(r *rand.Rand) time.Duration { | ||
return time.Duration(simulation.RandIntBetween(r, 60, 60<<13)) | ||
} | ||
|
||
func getNodeAddress() hubtypes.NodeAddress { | ||
bz := make([]byte, 20) | ||
_, err := rand.Read(bz) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return hubtypes.NodeAddress(bz) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/simulation" | ||
"github.com/sentinel-official/hub/x/provider/types" | ||
) | ||
|
||
func getRandomDeposit(r *rand.Rand) sdk.Coin { | ||
denom := simulation.RandStringOfLength(r, r.Intn(125)+3) | ||
amount := sdk.NewInt(r.Int63n(10<<12)) | ||
|
||
return sdk.NewCoin(denom, amount) | ||
} | ||
|
||
func getRandomProviders(r *rand.Rand) types.Providers { | ||
var providers types.Providers | ||
|
||
for _, acc := range simulation.RandomAccounts(r, r.Intn(20)+4) { | ||
providers = append(providers, types.Provider{ | ||
Address: acc.Address.String(), | ||
Name: simulation.RandStringOfLength(r, r.Intn(60)+4), | ||
Identity: simulation.RandStringOfLength(r, r.Intn(60)+4), | ||
Website: simulation.RandStringOfLength(r, r.Intn(60)+4), | ||
Description: simulation.RandStringOfLength(r, r.Intn(250)+6), | ||
}) | ||
} | ||
|
||
return providers | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdksimulation "github.com/cosmos/cosmos-sdk/types/simulation" | ||
hubtypes "github.com/sentinel-official/hub/types" | ||
"github.com/sentinel-official/hub/x/session/types" | ||
) | ||
|
||
func getRandomSessions(r *rand.Rand) types.Sessions { | ||
sessions := make(types.Sessions, r.Int31n(28)+4) | ||
|
||
for range sessions { | ||
sessions = append(sessions, types.Session{ | ||
Id: rand.Uint64(), | ||
Subscription: 0, | ||
Node: hubtypes.NodeAddress("node-address").String(), | ||
Address: sdk.AccAddress("address").String(), | ||
Duration: time.Duration(r.Int31n(1800)+1800), | ||
Bandwidth: hubtypes.NewBandwidthFromInt64(int64(1024<<20 * r.Intn(10)), int64(1024<<20 * r.Intn(10))), | ||
Status: hubtypes.Status(r.Int31n(3)), | ||
StatusAt: sdksimulation.RandTimestamp(r), | ||
}) | ||
} | ||
|
||
return sessions | ||
} | ||
|
||
func getRandomInactiveDuration(r *rand.Rand) time.Duration { | ||
return time.Duration(sdksimulation.RandIntBetween(r, 60, 60<<13)) | ||
} | ||
|
||
func getRandomProofVerificationEnabled(r *rand.Rand) bool { | ||
return rand.Int31n(2) == int32(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package simulation | ||
|
||
import ( | ||
"math/rand" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/simulation" | ||
) | ||
|
||
func GetRandomSwapDenom(r *rand.Rand) string { | ||
// denom length should be between 3-128 | ||
return simulation.RandStringOfLength(r, r.Intn(125)+3) | ||
} | ||
|
||
func GetRandomApproveBy(r *rand.Rand) string { | ||
bz := make([]byte, 20) | ||
_, err := r.Read(bz) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return sdk.AccAddress(bz).String() | ||
} | ||
|
||
func GetRandomSwapEnabled(r *rand.Rand) bool { | ||
return r.Intn(2) == 1 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters