Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions app/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"fmt"
"strings"
"time"

tmos "github.com/cometbft/cometbft/libs/os"
Expand Down Expand Up @@ -42,10 +43,14 @@ type TestnetValidator struct {
Delegations []TestnetDelegation
}

type TestnetVotingPeriod struct {
time.Duration
}

type TestnetGovConfig struct {
VotingParams *struct {
VotingPeriod time.Duration `json:"voting_period,omitempty"`
ExpeditedVotePeriod time.Duration `json:"expedited_vote_period"`
VotingPeriod TestnetVotingPeriod `json:"voting_period,omitempty"`
ExpeditedVotePeriod TestnetVotingPeriod `json:"expedited_vote_period"`
} `json:"voting_params,omitempty"`
}

Expand All @@ -65,6 +70,27 @@ type TestnetConfig struct {
Upgrade TestnetUpgrade
}

func TrimQuotes(data string) string {
data = strings.TrimPrefix(data, "\"")
return strings.TrimSuffix(data, "\"")
}

func (t *TestnetVotingPeriod) UnmarshalJSON(data []byte) error {
val := TrimQuotes(string(data))

if !strings.HasSuffix(val, "s") {
return fmt.Errorf("invalid format of voting period. must contain time unit. Valid time units are ns|us(µs)|ms|s|m|h") // nolint: goerr113
}

var err error
t.Duration, err = time.ParseDuration(val)
if err != nil {
return err
}

return nil
}

// InitAkashAppForTestnet is broken down into two sections:
// Required Changes: Changes that, if not made, will cause the testnet to halt or panic
// Optional Changes: Changes to customize the testnet to one's liking (lower vote times, fund accounts, etc)
Expand Down Expand Up @@ -258,8 +284,8 @@ func InitAkashAppForTestnet(
if err != nil {
panic(err.Error())
}
govParams.ExpeditedVotingPeriod = &tcfg.Gov.VotingParams.ExpeditedVotePeriod
govParams.VotingPeriod = &tcfg.Gov.VotingParams.VotingPeriod
govParams.ExpeditedVotingPeriod = &tcfg.Gov.VotingParams.ExpeditedVotePeriod.Duration
govParams.VotingPeriod = &tcfg.Gov.VotingParams.VotingPeriod.Duration
govParams.MinDeposit = sdk.NewCoins(sdk.NewInt64Coin(sdkutil.DenomUakt, 100000000))
govParams.ExpeditedMinDeposit = sdk.NewCoins(sdk.NewInt64Coin(sdkutil.DenomUakt, 150000000))

Expand Down
Loading