Skip to content

Commit

Permalink
refactor: extract variables for common utia and tia amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Chirag018 committed Oct 16, 2023
1 parent 40385b9 commit 20d2ff2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/celestiaorg/celestia-app/test/util/blobfactory"
"github.com/celestiaorg/celestia-app/test/util/genesis"
"github.com/celestiaorg/celestia-app/test/util/testfactory"
"github.com/celestiaorg/celestia-app/test/util/testnode"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -227,7 +228,7 @@ func (s *IntegrationTestSuite) TestSubmitPayForBlob() {
"small random typical",
mustNewBlob(ns1, tmrand.Bytes(3000), appconsts.ShareVersionZero),
[]user.TxOption{
user.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1)))),
user.SetFeeAmount(genesis.Utia),
user.SetGasLimit(1_000_000_000),
},
},
Expand Down
5 changes: 3 additions & 2 deletions app/test/prepare_proposal_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/pkg/user"
"github.com/celestiaorg/celestia-app/test/util/genesis"
"github.com/celestiaorg/celestia-app/test/util/testfactory"
"github.com/celestiaorg/celestia-app/test/util/testnode"
"github.com/cosmos/cosmos-sdk/crypto/hd"
Expand Down Expand Up @@ -54,7 +55,7 @@ func TestTimeInPrepareProposalContext(t *testing.T) {
msg := vestingtypes.NewMsgCreateVestingAccount(
sendingAccAddr,
vestAccAddr,
sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000))),
genesis.Tia,
time.Now().Unix(),
time.Now().Add(time.Second*100).Unix(),
false,
Expand All @@ -72,7 +73,7 @@ func TestTimeInPrepareProposalContext(t *testing.T) {
msg := banktypes.NewMsgSend(
vestAccAddr,
sendingAccAddr,
sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1))),
genesis.Utia,
)
return []sdk.Msg{msg}, vestAccName
},
Expand Down
11 changes: 6 additions & 5 deletions app/test/std_sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/celestiaorg/celestia-app/app/encoding"
"github.com/celestiaorg/celestia-app/pkg/user"
"github.com/celestiaorg/celestia-app/test/util/blobfactory"
"github.com/celestiaorg/celestia-app/test/util/genesis"
"github.com/celestiaorg/celestia-app/test/util/testfactory"
"github.com/celestiaorg/celestia-app/test/util/testnode"
"github.com/cosmos/cosmos-sdk/crypto/hd"
Expand Down Expand Up @@ -86,7 +87,7 @@ func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {
msgSend := banktypes.NewMsgSend(
testfactory.GetAddress(s.cctx.Keyring, account1),
testfactory.GetAddress(s.cctx.Keyring, account2),
sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1))),
genesis.Utia,
)
return []sdk.Msg{msgSend}, account1
},
Expand Down Expand Up @@ -158,7 +159,7 @@ func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {
msg := vestingtypes.NewMsgCreateVestingAccount(
sendingAccAddr,
vestAccAddr,
sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000))),
genesis.Tia,
time.Now().Add(time.Hour).Unix(),
time.Now().Add(time.Hour*2).Unix(),
false,
Expand All @@ -176,7 +177,7 @@ func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {
// to inflation so if 1 coin is not present in the community
// pool, consider expanding the block interval or waiting for
// more blocks to be produced prior to executing this test case.
coins := sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1)))
coins := genesis.Utia
content := disttypes.NewCommunityPoolSpendProposal(
"title",
"description",
Expand Down Expand Up @@ -222,13 +223,13 @@ func (s *StandardSDKIntegrationTestSuite) TestStandardSDK() {
msgSend1 := banktypes.NewMsgSend(
testfactory.GetAddress(s.cctx.Keyring, account1),
testfactory.GetAddress(s.cctx.Keyring, account2),
sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1))),
genesis.Utia,
)
account3 := s.unusedAccount()
msgSend2 := banktypes.NewMsgSend(
testfactory.GetAddress(s.cctx.Keyring, account1),
testfactory.GetAddress(s.cctx.Keyring, account3),
sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1))),
genesis.Utia,
)
return []sdk.Msg{msgSend1, msgSend2}, account1
},
Expand Down
8 changes: 7 additions & 1 deletion test/util/genesis/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ type Account struct {
InitialTokens int64
}

var (
Utia = sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1)))
// Tia is 1e6 utia (a.k.a one million utia)
Tia = sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1e6)))
)

func NewAccounts(initBal int64, names ...string) []Account {
accounts := make([]Account, len(names))
for i, name := range names {
Expand Down Expand Up @@ -115,7 +121,7 @@ func (v *Validator) GenTx(ecfg encoding.Config, kr keyring.Keyring, chainID stri
return nil, err
}

fee := sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1)))
fee := Utia
txBuilder := ecfg.TxConfig.NewTxBuilder()
err = txBuilder.SetMsgs(createValMsg)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions test/util/genesis/modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"time"

"github.com/celestiaorg/celestia-app/app"
blobtypes "github.com/celestiaorg/celestia-app/x/blob/types"
qgbtypes "github.com/celestiaorg/celestia-app/x/qgb/types"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -35,7 +34,7 @@ func SetBlobParams(codec codec.Codec, params blobtypes.Params) Modifier {
func ImmediateProposals(codec codec.Codec) Modifier {
return func(state map[string]json.RawMessage) map[string]json.RawMessage {
gs := v1.DefaultGenesisState()
gs.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(app.BondDenom, sdk.NewInt(1)))
gs.DepositParams.MinDeposit = Utia
gs.TallyParams.Quorum = "0.000001"
gs.TallyParams.Threshold = "0.000001"
vp := time.Second * 5
Expand Down

0 comments on commit 20d2ff2

Please sign in to comment.