-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,237 additions
and
12 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
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
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,32 @@ | ||
syntax = "proto3"; | ||
package confio.globalfee.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmwasm/wasm/v1beta1/genesis.proto"; | ||
|
||
option go_package = "github.com/confio/tgrade/x/globalfee"; | ||
|
||
// GenesisState - initial state of module | ||
message GenesisState { | ||
// Params of this module | ||
Params params = 1 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.jsontag) = "params,omitempty" | ||
]; | ||
} | ||
|
||
// Params defines the set of module parameters. | ||
message Params { | ||
// Minimum stores the minimum gas price(s) for all TX on the chain. | ||
// When multiple coins are defined then they are accepted alternatively. | ||
// The list must be sorted by denoms asc. No duplicate denoms or zero amount | ||
// values allowed. For more information see | ||
// https://docs.cosmos.network/master/modules/auth/01_concepts.html | ||
repeated cosmos.base.v1beta1.DecCoin minimum_gas_prices = 1 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.jsontag) = "minimum,omitempty", | ||
(gogoproto.moretags) = "yaml:\"minimum_gas_pricess\"", | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" | ||
]; | ||
} |
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,42 @@ | ||
// +build system_test | ||
|
||
package testing | ||
|
||
import ( | ||
"encoding/json" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tidwall/sjson" | ||
"testing" | ||
) | ||
|
||
func TestGlobalFee(t *testing.T) { | ||
sut.ResetChain(t) | ||
sut.ModifyGenesisJson(t, SetGlobalMinFee(t, sdk.NewDecCoinFromDec("utgd", sdk.NewDecWithPrec(1, 3)))) | ||
sut.StartChain(t) | ||
|
||
cli := NewTgradeCli(t, sut, verbose) | ||
|
||
const anyContract = "testing/contracts/tg4_group.wasm" | ||
t.Log("Any transaction without enough fees should fail") | ||
txResult := cli.CustomCommand("tx", "wasm", "store", anyContract, "--from=node0", "--gas=1500000", "--fees=1utg") | ||
RequireTxFailure(t, txResult, "insufficient fee") | ||
|
||
t.Log("Any transaction with enough fees should pass") | ||
txResult = cli.CustomCommand("tx", "wasm", "store", anyContract, "--from=node0", "--gas=1500000", "--fees=1500utgd") | ||
RequireTxSuccess(t, txResult) | ||
} | ||
|
||
// SetGlobalMinFee set the passed coins to the global minimum fee | ||
func SetGlobalMinFee(t *testing.T, fees ...sdk.DecCoin) GenesisMutator { | ||
return func(genesis []byte) []byte { | ||
t.Helper() | ||
coins := sdk.NewDecCoins(fees...) | ||
require.NoError(t, coins.Validate()) | ||
val, err := json.Marshal(coins) | ||
require.NoError(t, err) | ||
state, err := sjson.SetRawBytes(genesis, "app_state.globalfee.params.minimum_gas_prices", val) | ||
require.NoError(t, err) | ||
return state | ||
} | ||
} |
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
Oops, something went wrong.