mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-06 22:26:43 +00:00
Improve linter setup (#186)
* [linter] Add `musttag` Enforce field tags in (un)marshaled structs. * [linter] Add `nestif` Reports deeply nested if statements. * [linter] Add `noctx` Finds sending http request without context.Context. * [linter] Add `paralleltest` Paralleltest detects missing usage of t.Parallel() method in your Go test. * [linter] Add `tagalign` Check that struct tags are well aligned. * [linter] Add `tagliatelle` Checks the struct tags. * [linter] Add `whitespace` Tool for detection of leading and trailing whitespace. * [paralleltest] Exclude files bc of data race in tests Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
5470fc668b
commit
5b25d4cefc
@ -45,11 +45,15 @@ linters:
|
|||||||
- makezero
|
- makezero
|
||||||
- mirror
|
- mirror
|
||||||
- misspell
|
- misspell
|
||||||
|
- musttag
|
||||||
- nakedret
|
- nakedret
|
||||||
|
- nestif
|
||||||
- nilerr
|
- nilerr
|
||||||
- nilnil
|
- nilnil
|
||||||
|
- noctx
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- nosprintfhostport
|
- nosprintfhostport
|
||||||
|
- paralleltest
|
||||||
- perfsprint
|
- perfsprint
|
||||||
- prealloc
|
- prealloc
|
||||||
- predeclared
|
- predeclared
|
||||||
@ -62,6 +66,8 @@ linters:
|
|||||||
- sqlclosecheck
|
- sqlclosecheck
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- stylecheck
|
- stylecheck
|
||||||
|
- tagalign
|
||||||
|
- tagliatelle
|
||||||
- tenv
|
- tenv
|
||||||
- testableexamples
|
- testableexamples
|
||||||
- tparallel
|
- tparallel
|
||||||
@ -70,10 +76,18 @@ linters:
|
|||||||
- unused
|
- unused
|
||||||
- usestdlibvars
|
- usestdlibvars
|
||||||
- wastedassign
|
- wastedassign
|
||||||
|
- whitespace
|
||||||
- zerologlint
|
- zerologlint
|
||||||
linters-settings:
|
linters-settings:
|
||||||
nakedret:
|
nakedret:
|
||||||
max-func-lines: 100
|
max-func-lines: 100
|
||||||
|
tagalign:
|
||||||
|
strict: true
|
||||||
|
tagliatelle:
|
||||||
|
case:
|
||||||
|
use-field-name: true
|
||||||
|
rules:
|
||||||
|
json: kebab
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: x/.*/types/message.*\.go
|
- path: x/.*/types/message.*\.go
|
||||||
@ -85,3 +99,6 @@ issues:
|
|||||||
- path: testutil/nullify/nullify\.go
|
- path: testutil/nullify/nullify\.go
|
||||||
linters:
|
linters:
|
||||||
- exhaustive
|
- exhaustive
|
||||||
|
- path: x/.*/keeper/query.*\.go
|
||||||
|
linters:
|
||||||
|
- paralleltest
|
||||||
|
@ -18,17 +18,19 @@ func NewCheckMintAddressDecorator(dk DaoKeeper) CheckMintAddressDecorator {
|
|||||||
|
|
||||||
func (cmad CheckMintAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
|
func (cmad CheckMintAddressDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
|
||||||
for _, msg := range tx.GetMsgs() {
|
for _, msg := range tx.GetMsgs() {
|
||||||
if sdk.MsgTypeURL(msg) == "/planetmintgo.dao.MsgMintToken" {
|
if sdk.MsgTypeURL(msg) != "/planetmintgo.dao.MsgMintToken" {
|
||||||
mintMsg, ok := msg.(*daotypes.MsgMintToken)
|
continue
|
||||||
if ok {
|
}
|
||||||
if mintMsg.Creator != cmad.dk.GetMintAddress(ctx) {
|
mintMsg, ok := msg.(*daotypes.MsgMintToken)
|
||||||
return ctx, errorsmod.Wrapf(daotypes.ErrInvalidMintAddress, "expected: %s; got: %s", cmad.dk.GetMintAddress(ctx), mintMsg.Creator)
|
if !ok {
|
||||||
}
|
continue
|
||||||
_, found := cmad.dk.GetMintRequestByHash(ctx, mintMsg.GetMintRequest().GetLiquidTxHash())
|
}
|
||||||
if found {
|
if mintMsg.Creator != cmad.dk.GetMintAddress(ctx) {
|
||||||
return ctx, errorsmod.Wrapf(daotypes.ErrAlreadyMinted, "liquid tx hash %s has already been minted", mintMsg.GetMintRequest().GetLiquidTxHash())
|
return ctx, errorsmod.Wrapf(daotypes.ErrInvalidMintAddress, "expected: %s; got: %s", cmad.dk.GetMintAddress(ctx), mintMsg.Creator)
|
||||||
}
|
}
|
||||||
}
|
_, found := cmad.dk.GetMintRequestByHash(ctx, mintMsg.GetMintRequest().GetLiquidTxHash())
|
||||||
|
if found {
|
||||||
|
return ctx, errorsmod.Wrapf(daotypes.ErrAlreadyMinted, "liquid tx hash %s has already been minted", mintMsg.GetMintRequest().GetLiquidTxHash())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,25 +45,27 @@ func checkTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, error) {
|
|||||||
|
|
||||||
feeCoins := feeTx.GetFee()
|
feeCoins := feeTx.GetFee()
|
||||||
|
|
||||||
if ctx.IsCheckTx() {
|
if !ctx.IsCheckTx() {
|
||||||
minGasPrices := ctx.MinGasPrices()
|
return feeCoins, nil
|
||||||
if !minGasPrices.IsZero() {
|
}
|
||||||
feeDenoms := feeCoins.Denoms()
|
minGasPrices := ctx.MinGasPrices()
|
||||||
if len(feeDenoms) != 1 {
|
if minGasPrices.IsZero() {
|
||||||
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "fee must be exactly one coin; got: %s", feeDenoms)
|
return feeCoins, nil
|
||||||
}
|
}
|
||||||
|
feeDenoms := feeCoins.Denoms()
|
||||||
|
if len(feeDenoms) != 1 {
|
||||||
|
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "fee must be exactly one coin; got: %s", feeDenoms)
|
||||||
|
}
|
||||||
|
|
||||||
gasDenom := minGasPrices.GetDenomByIndex(0)
|
gasDenom := minGasPrices.GetDenomByIndex(0)
|
||||||
if !sdk.SliceContains[string](feeDenoms, gasDenom) {
|
if !sdk.SliceContains[string](feeDenoms, gasDenom) {
|
||||||
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "received wrong fee denom; got: %s required: %s", feeDenoms[0], gasDenom)
|
return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "received wrong fee denom; got: %s required: %s", feeDenoms[0], gasDenom)
|
||||||
}
|
}
|
||||||
|
|
||||||
requiredFees := sdk.Coins{sdk.NewCoin(gasDenom, sdk.OneInt())}
|
requiredFees := sdk.Coins{sdk.NewCoin(gasDenom, sdk.OneInt())}
|
||||||
|
|
||||||
if !feeCoins.IsAnyGTE(requiredFees) {
|
if !feeCoins.IsAnyGTE(requiredFees) {
|
||||||
return nil, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
|
return nil, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return feeCoins, nil
|
return feeCoins, nil
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
// TestAccountAddressPrefix makes sure that the account address prefix has a certain value.
|
// TestAccountAddressPrefix makes sure that the account address prefix has a certain value.
|
||||||
func TestAccountAddressPrefix(t *testing.T) {
|
func TestAccountAddressPrefix(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
accountAddressPrefix := "plmnt"
|
accountAddressPrefix := "plmnt"
|
||||||
assert.Equal(t, AccountAddressPrefix, accountAddressPrefix, "The account address prefix should be 'plmnt'.")
|
assert.Equal(t, AccountAddressPrefix, accountAddressPrefix, "The account address prefix should be 'plmnt'.")
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,7 @@ func BenchmarkSimulation(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppStateDeterminism(t *testing.T) {
|
func TestAppStateDeterminism(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
if !simcli.FlagEnabledValue {
|
if !simcli.FlagEnabledValue {
|
||||||
t.Skip("skipping application simulation")
|
t.Skip("skipping application simulation")
|
||||||
}
|
}
|
||||||
@ -219,6 +220,7 @@ func TestAppStateDeterminism(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppImportExport(t *testing.T) {
|
func TestAppImportExport(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
config := simcli.NewConfigFromFlags()
|
config := simcli.NewConfigFromFlags()
|
||||||
config.ChainID = "mars-simapp-import"
|
config.ChainID = "mars-simapp-import"
|
||||||
|
|
||||||
@ -373,6 +375,7 @@ func TestAppImportExport(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppSimulationAfterImport(t *testing.T) {
|
func TestAppSimulationAfterImport(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
config := simcli.NewConfigFromFlags()
|
config := simcli.NewConfigFromFlags()
|
||||||
config.ChainID = "mars-simapp-after-import"
|
config.ChainID = "mars-simapp-after-import"
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
// TestDerivationPath makes sure that purpose and cointype are set to PLMNT (see https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
|
// TestDerivationPath makes sure that purpose and cointype are set to PLMNT (see https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
|
||||||
func TestDerivationPath(t *testing.T) {
|
func TestDerivationPath(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
sdkConfig := initSDKConfig()
|
sdkConfig := initSDKConfig()
|
||||||
|
|
||||||
purpose := uint32(44)
|
purpose := uint32(44)
|
||||||
|
@ -33,23 +33,23 @@ distribution-epochs = {{ .PlmntConfig.DistributionEpochs }}
|
|||||||
|
|
||||||
// Config defines Planetmint's top level configuration
|
// Config defines Planetmint's top level configuration
|
||||||
type Config struct {
|
type Config struct {
|
||||||
AssetRegistryEndpoint string `mapstructure:"asset-registry-endpoint " json:"asset-registry-endpoint "`
|
AssetRegistryEndpoint string `json:"asset-registry-endpoint" mapstructure:"asset-registry-endpoint"`
|
||||||
TokenDenom string `mapstructure:"token-denom" json:"token-denom"`
|
TokenDenom string `json:"token-denom" mapstructure:"token-denom"`
|
||||||
StakeDenom string `mapstructure:"stake-denom" json:"stake-denom"`
|
StakeDenom string `json:"stake-denom" mapstructure:"stake-denom"`
|
||||||
FeeDenom string `mapstructure:"fee-denom" json:"fee-denom"`
|
FeeDenom string `json:"fee-denom" mapstructure:"fee-denom"`
|
||||||
ConfigRootDir string
|
ConfigRootDir string `json:"config-root-dir" mapstructure:"config-root-dir"`
|
||||||
PoPEpochs int `mapstructure:"pop-epochs" json:"pop-epochs"`
|
PoPEpochs int `json:"pop-epochs" mapstructure:"pop-epochs"` //nolint: tagliatelle // json(kebab): got 'pop-epochs' want 'po-p-epochs'
|
||||||
RPCHost string `mapstructure:"rpc-host" json:"rpc-host"`
|
RPCHost string `json:"rpc-host" mapstructure:"rpc-host"`
|
||||||
RPCPort int `mapstructure:"rpc-port" json:"rpc-port"`
|
RPCPort int `json:"rpc-port" mapstructure:"rpc-port"`
|
||||||
RPCUser string `mapstructure:"rpc-user" json:"rpc-user"`
|
RPCUser string `json:"rpc-user" mapstructure:"rpc-user"`
|
||||||
RPCPassword string `mapstructure:"rpc-password" json:"rpc-password"`
|
RPCPassword string `json:"rpc-password" mapstructure:"rpc-password"`
|
||||||
IssuanceServiceDir string `mapstructure:"issuance-service-dir" json:"issuance-service-dir"`
|
IssuanceServiceDir string `json:"issuance-service-dir" mapstructure:"issuance-service-dir"`
|
||||||
ReissuanceAsset string `mapstructure:"reissuance-asset" json:"reissuance-asset"`
|
ReissuanceAsset string `json:"reissuance-asset" mapstructure:"reissuance-asset"`
|
||||||
ValidatorAddress string `mapstructure:"validator-address" json:"validator-address"`
|
ValidatorAddress string `json:"validator-address" mapstructure:"validator-address"`
|
||||||
DistributionAddrInv string `mapstructure:"distribution-address-inv" json:"distribution-address-inv"`
|
DistributionAddrInv string `json:"distribution-addr-inv" mapstructure:"distribution-addr-inv"`
|
||||||
DistributionAddrDAO string `mapstructure:"distribution-address-dao" json:"distribution-address-dao"`
|
DistributionAddrDAO string `json:"distribution-addr-dao" mapstructure:"distribution-addr-dao"`
|
||||||
DistributionAddrPoP string `mapstructure:"distribution-address-pop" json:"distribution-address-pop"`
|
DistributionAddrPoP string `json:"distribution-addr-pop" mapstructure:"distribution-addr-pop"` //nolint: tagliatelle // json(kebab): got 'distribution-addr-pop' want 'distribution-addr-po-p'
|
||||||
DistributionEpochs int `mapstructure:"distribution-epochs" json:"distribution-epochs"`
|
DistributionEpochs int `json:"distribution-epochs" mapstructure:"distribution-epochs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// cosmos-sdk wide global singleton
|
// cosmos-sdk wide global singleton
|
||||||
|
@ -16,11 +16,11 @@ import (
|
|||||||
|
|
||||||
// Config defines library top level configuration.
|
// Config defines library top level configuration.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ChainID string `mapstructure:"chain-id" json:"chain-id"`
|
ChainID string `json:"chain-id" mapstructure:"chain-id"`
|
||||||
EncodingConfig params.EncodingConfig `mapstructure:"encoding-config" json:"encoding-config"`
|
EncodingConfig params.EncodingConfig `json:"encoding-config" mapstructure:"encoding-config"`
|
||||||
GRPCEndpoint string `mapstructure:"grpc-endpoint" json:"grpc-endpoint"`
|
GRPCEndpoint string `json:"grpc-endpoint" mapstructure:"grpc-endpoint"`
|
||||||
GRPCTLSCert string `mapstructure:"grpc-tls-cert" json:"grpc-tls-cert"`
|
GRPCTLSCert string `json:"grpc-tls-cert" mapstructure:"grpc-tls-cert"` //nolint: tagliatelle // json(kebab): got 'grpc-tls-cert' want 'grpctls-cert'
|
||||||
RootDir string `mapstructure:"root-dir" json:"root-dir"`
|
RootDir string `json:"root-dir" mapstructure:"root-dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// lib wide global singleton
|
// lib wide global singleton
|
||||||
|
@ -26,7 +26,7 @@ type KeyPair struct {
|
|||||||
|
|
||||||
// Result defines a generic way to receive responses from the RPC endpoint.
|
// Result defines a generic way to receive responses from the RPC endpoint.
|
||||||
type Result struct {
|
type Result struct {
|
||||||
Info map[string]interface{} `mapstructure:"info" json:"info"`
|
Info map[string]interface{} `json:"info" mapstructure:"info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package asset
|
package asset
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/planetmint/planetmint-go/testutil/network"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/planetmint/planetmint-go/testutil/network"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestE2ETestSuite(t *testing.T) {
|
func TestE2ETestSuite(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
cfg := network.DefaultConfig()
|
cfg := network.DefaultConfig()
|
||||||
cfg.NumValidators = 1
|
cfg.NumValidators = 1
|
||||||
suite.Run(t, NewE2ETestSuite(cfg))
|
suite.Run(t, NewE2ETestSuite(cfg))
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package dao
|
package dao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/planetmint/planetmint-go/testutil/network"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/planetmint/planetmint-go/testutil/network"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestE2ETestSuite(t *testing.T) {
|
func TestE2ETestSuite(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
cfg := network.DefaultConfig()
|
cfg := network.DefaultConfig()
|
||||||
suite.Run(t, NewE2ETestSuite(cfg))
|
suite.Run(t, NewE2ETestSuite(cfg))
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/planetmint/planetmint-go/testutil/network"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/planetmint/planetmint-go/testutil/network"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestE2ETestSuite(t *testing.T) {
|
func TestE2ETestSuite(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
cfg := network.DefaultConfig()
|
cfg := network.DefaultConfig()
|
||||||
cfg.NumValidators = 1
|
cfg.NumValidators = 1
|
||||||
suite.Run(t, NewE2ETestSuite(cfg))
|
suite.Run(t, NewE2ETestSuite(cfg))
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
// GetRequest defines a wrapper around an HTTP GET request with a provided URL.
|
// GetRequest defines a wrapper around an HTTP GET request with a provided URL.
|
||||||
// An error is returned if the request or reading the body fails.
|
// An error is returned if the request or reading the body fails.
|
||||||
func GetRequest(url string) ([]byte, error) {
|
func GetRequest(url string) ([]byte, error) {
|
||||||
res, err := http.Get(url) //nolint:gosec // only used for testing
|
res, err := http.Get(url) //nolint:gosec,noctx // only used for testing
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ func GetRequest(url string) ([]byte, error) {
|
|||||||
// PostRequest defines a wrapper around an HTTP POST request with a provided URL and data.
|
// PostRequest defines a wrapper around an HTTP POST request with a provided URL and data.
|
||||||
// An error is returned if the request or reading the body fails.
|
// An error is returned if the request or reading the body fails.
|
||||||
func PostRequest(url, contentType string, data []byte) ([]byte, error) {
|
func PostRequest(url, contentType string, data []byte) ([]byte, error) {
|
||||||
res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec // only used for testing
|
res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec,noctx // only used for testing
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error while sending post request: %w", err)
|
return nil, fmt.Errorf("error while sending post request: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ type Key struct {
|
|||||||
|
|
||||||
type KeyFile struct {
|
type KeyFile struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
PubKey Key `json:"pub_key"`
|
PubKey Key `json:"pub-key"`
|
||||||
PrivKey Key `json:"priv_key"`
|
PrivKey Key `json:"priv-key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetValidatorCometBFTIdentity(ctx sdk.Context) (string, bool) {
|
func GetValidatorCometBFTIdentity(ctx sdk.Context) (string, bool) {
|
||||||
|
@ -7,18 +7,21 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Test2FloatConvertion(t *testing.T) {
|
func Test2FloatConvertion(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var expectedValue uint64 = 99869000000
|
var expectedValue uint64 = 99869000000
|
||||||
value := RDDLToken2Uint(998.69)
|
value := RDDLToken2Uint(998.69)
|
||||||
assert.Equal(t, expectedValue, value)
|
assert.Equal(t, expectedValue, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test2UintConvertion(t *testing.T) {
|
func Test2UintConvertion(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
expectedValue := 998.69
|
expectedValue := 998.69
|
||||||
value := RDDLToken2Float(99869000000)
|
value := RDDLToken2Float(99869000000)
|
||||||
assert.Equal(t, expectedValue, value)
|
assert.Equal(t, expectedValue, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStringToFloat(t *testing.T) {
|
func TestStringToFloat(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
expectedValue := 998.69
|
expectedValue := 998.69
|
||||||
value, err := RDDLTokenStringToFloat("998.69")
|
value, err := RDDLTokenStringToFloat("998.69")
|
||||||
assert.Equal(t, expectedValue, value)
|
assert.Equal(t, expectedValue, value)
|
||||||
@ -26,6 +29,7 @@ func TestStringToFloat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStringToUint(t *testing.T) {
|
func TestStringToUint(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var expectedValue uint64 = 99869000000
|
var expectedValue uint64 = 99869000000
|
||||||
value, err := RDDLTokenStringToUint("998.69")
|
value, err := RDDLTokenStringToUint("998.69")
|
||||||
assert.Equal(t, expectedValue, value)
|
assert.Equal(t, expectedValue, value)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesis(t *testing.T) {
|
func TestGenesis(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
genesisState := types.GenesisState{
|
genesisState := types.GenesisState{
|
||||||
Params: types.DefaultParams(),
|
Params: types.DefaultParams(),
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ func createNAsset(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.MsgNota
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAsset(t *testing.T) {
|
func TestGetAsset(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.AssetKeeper(t)
|
keeper, ctx := keepertest.AssetKeeper(t)
|
||||||
items := createNAsset(keeper, ctx, 10)
|
items := createNAsset(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -38,6 +39,7 @@ func TestGetAsset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestGetCids(t *testing.T) {
|
func TestGetCids(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.AssetKeeper(t)
|
keeper, ctx := keepertest.AssetKeeper(t)
|
||||||
items := createNAsset(keeper, ctx, 10)
|
items := createNAsset(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -48,6 +50,7 @@ func TestGetCids(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAssetByPubKeys(t *testing.T) {
|
func TestGetAssetByPubKeys(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.AssetKeeper(t)
|
keeper, ctx := keepertest.AssetKeeper(t)
|
||||||
_ = createNAsset(keeper, ctx, 10)
|
_ = createNAsset(keeper, ctx, 10)
|
||||||
assets, found := keeper.GetCidsByAddress(ctx, "plmnt_address")
|
assets, found := keeper.GetCidsByAddress(ctx, "plmnt_address")
|
||||||
|
@ -23,12 +23,14 @@ func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServer(t *testing.T) {
|
func TestMsgServer(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ms, ctx := setupMsgServer(t)
|
ms, ctx := setupMsgServer(t)
|
||||||
require.NotNil(t, ms)
|
require.NotNil(t, ms)
|
||||||
require.NotNil(t, ctx)
|
require.NotNil(t, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerNotarizeAsset(t *testing.T) {
|
func TestMsgServerNotarizeAsset(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
extSk, _ := sample.ExtendedKeyPair(config.PlmntNetParams)
|
extSk, _ := sample.ExtendedKeyPair(config.PlmntNetParams)
|
||||||
xskKey, _ := hdkeychain.NewKeyFromString(extSk)
|
xskKey, _ := hdkeychain.NewKeyFromString(extSk)
|
||||||
privKey, _ := xskKey.ECPrivKey()
|
privKey, _ := xskKey.ECPrivKey()
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetParams(t *testing.T) {
|
func TestGetParams(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
k, ctx := testkeeper.AssetKeeper(t)
|
k, ctx := testkeeper.AssetKeeper(t)
|
||||||
params := types.DefaultParams()
|
params := types.DefaultParams()
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ func TestGetNotarizedAssetByAddress(t *testing.T) {
|
|||||||
err: status.Error(codes.NotFound, "no CIDs found"),
|
err: status.Error(codes.NotFound, "no CIDs found"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
response, err := keeper.GetCIDsByAddress(wctx, tc.request)
|
response, err := keeper.GetCIDsByAddress(wctx, tc.request)
|
||||||
if tc.err != nil {
|
if tc.err != nil {
|
||||||
|
@ -33,7 +33,6 @@ func TestGetNotarizedAsset(t *testing.T) {
|
|||||||
err: status.Error(codes.NotFound, "cid not found"),
|
err: status.Error(codes.NotFound, "cid not found"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
response, err := keeper.GetNotarizedAsset(wctx, tc.request)
|
response, err := keeper.GetNotarizedAsset(wctx, tc.request)
|
||||||
if tc.err != nil {
|
if tc.err != nil {
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestParamsQuery(t *testing.T) {
|
func TestParamsQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := testkeeper.AssetKeeper(t)
|
keeper, ctx := testkeeper.AssetKeeper(t)
|
||||||
wctx := sdk.WrapSDKContext(ctx)
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
params := types.DefaultParams()
|
params := types.DefaultParams()
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesisStateValidate(t *testing.T) {
|
func TestGenesisStateValidate(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
genState *types.GenesisState
|
genState *types.GenesisState
|
||||||
@ -30,7 +31,9 @@ func TestGenesisStateValidate(t *testing.T) {
|
|||||||
// this line is used by starport scaffolding # types/genesis/testcase
|
// this line is used by starport scaffolding # types/genesis/testcase
|
||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
tc := tc
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tc.genState.Validate()
|
err := tc.genState.Validate()
|
||||||
if tc.valid {
|
if tc.valid {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMsgNotarizeAssetValidateBasic(t *testing.T) {
|
func TestMsgNotarizeAssetValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msg MsgNotarizeAsset
|
msg MsgNotarizeAsset
|
||||||
@ -29,7 +30,9 @@ func TestMsgNotarizeAssetValidateBasic(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tt.msg.ValidateBasic()
|
err := tt.msg.ValidateBasic()
|
||||||
if tt.err != nil {
|
if tt.err != nil {
|
||||||
require.ErrorIs(t, err, tt.err)
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
@ -17,32 +17,31 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper)
|
|||||||
|
|
||||||
// Check if node is block proposer
|
// Check if node is block proposer
|
||||||
// take the following actions only once, that's why we filter for the Block Proposer
|
// take the following actions only once, that's why we filter for the Block Proposer
|
||||||
if util.IsValidatorBlockProposer(ctx, proposerAddress) {
|
if !util.IsValidatorBlockProposer(ctx, proposerAddress) {
|
||||||
blockHeight := req.Header.GetHeight()
|
return
|
||||||
if isPoPHeight(blockHeight) {
|
}
|
||||||
logger.Debug("TODO: implement PoP trigger")
|
blockHeight := req.Header.GetHeight()
|
||||||
hexProposerAddress := hex.EncodeToString(proposerAddress)
|
if isPoPHeight(blockHeight) {
|
||||||
conf := config.GetConfig()
|
logger.Debug("TODO: implement PoP trigger")
|
||||||
txUnsigned := keeper.GetReissuanceCommand(conf.ReissuanceAsset, blockHeight)
|
hexProposerAddress := hex.EncodeToString(proposerAddress)
|
||||||
err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, txUnsigned, blockHeight)
|
conf := config.GetConfig()
|
||||||
if err != nil {
|
txUnsigned := keeper.GetReissuanceCommand(conf.ReissuanceAsset, blockHeight)
|
||||||
logger.Error("error while initializing RDDL issuance", err)
|
err := util.InitRDDLReissuanceProcess(ctx, hexProposerAddress, txUnsigned, blockHeight)
|
||||||
}
|
if err != nil {
|
||||||
}
|
logger.Error("error while initializing RDDL issuance", err)
|
||||||
if isDistributionHeight(blockHeight) {
|
}
|
||||||
// initialize the distribution message
|
}
|
||||||
distribution, err := k.GetDistributionForReissuedTokens(ctx, blockHeight)
|
if isDistributionHeight(blockHeight) {
|
||||||
if err != nil {
|
// initialize the distribution message
|
||||||
logger.Error("error while computing the RDDL distribution ", err)
|
distribution, err := k.GetDistributionForReissuedTokens(ctx, blockHeight)
|
||||||
}
|
if err != nil {
|
||||||
err = util.SendRDDLDistributionRequest(ctx, distribution)
|
logger.Error("error while computing the RDDL distribution ", err)
|
||||||
if err != nil {
|
}
|
||||||
logger.Error("sending the distribution request failed")
|
err = util.SendRDDLDistributionRequest(ctx, distribution)
|
||||||
}
|
if err != nil {
|
||||||
|
logger.Error("sending the distribution request failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isPoPHeight(height int64) bool {
|
func isPoPHeight(height int64) bool {
|
||||||
|
@ -17,7 +17,6 @@ func CmdGetReissuances() *cobra.Command {
|
|||||||
Short: "Query get_reissuances",
|
Short: "Query get_reissuances",
|
||||||
Args: cobra.ExactArgs(0),
|
Args: cobra.ExactArgs(0),
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
|
||||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesis(t *testing.T) {
|
func TestGenesis(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
genesisState := types.GenesisState{
|
genesisState := types.GenesisState{
|
||||||
Params: types.DefaultParams(),
|
Params: types.DefaultParams(),
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ func createNChallenge(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetChallenge(t *testing.T) {
|
func TestGetChallenge(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
items := createNChallenge(keeper, ctx, 10)
|
items := createNChallenge(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
|
@ -31,6 +31,7 @@ func createNDistributionOrder(keeper *keeper.Keeper, ctx sdk.Context, n int) []t
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDistributionOrder(t *testing.T) {
|
func TestDistributionOrder(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
items := createNDistributionOrder(keeper, ctx, 10)
|
items := createNDistributionOrder(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -45,6 +46,7 @@ func TestDistributionOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTokenDistribution(t *testing.T) {
|
func TestTokenDistribution(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
k, ctx := keepertest.DaoKeeper(t)
|
k, ctx := keepertest.DaoKeeper(t)
|
||||||
var reissuanceValue uint64 = 99869000000
|
var reissuanceValue uint64 = 99869000000
|
||||||
reissuances := 1000
|
reissuances := 1000
|
||||||
@ -78,5 +80,4 @@ func TestTokenDistribution(t *testing.T) {
|
|||||||
expSum = reissuanceValue * Amount2ndBatch // add the [0] of the
|
expSum = reissuanceValue * Amount2ndBatch // add the [0] of the
|
||||||
assert.Equal(t, expSum, sum)
|
assert.Equal(t, expSum, sum)
|
||||||
assert.Equal(t, uint64(reissuances), Amount1stBatch+Amount2ndBatch)
|
assert.Equal(t, uint64(reissuances), Amount1stBatch+Amount2ndBatch)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ func (k Keeper) StoreMintRequest(ctx sdk.Context, mintRequest types.MintRequest)
|
|||||||
mintRequests.Requests = append(mintRequests.Requests, &mintRequest)
|
mintRequests.Requests = append(mintRequests.Requests, &mintRequest)
|
||||||
addressAppendValue := k.cdc.MustMarshal(&mintRequests)
|
addressAppendValue := k.cdc.MustMarshal(&mintRequests)
|
||||||
addressStore.Set(getMintRequestKeyBytes(mintRequest.Beneficiary), addressAppendValue)
|
addressStore.Set(getMintRequestKeyBytes(mintRequest.Beneficiary), addressAppendValue)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) GetMintRequestsByAddress(ctx sdk.Context, address string) (val types.MintRequests, found bool) {
|
func (k Keeper) GetMintRequestsByAddress(ctx sdk.Context, address string) (val types.MintRequests, found bool) {
|
||||||
|
@ -24,6 +24,7 @@ func createNMintRequests(keeper *keeper.Keeper, ctx sdk.Context, beneficiary str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMintRequestByHash(t *testing.T) {
|
func TestGetMintRequestByHash(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
items := createNMintRequests(keeper, ctx, "beneficiary", 10)
|
items := createNMintRequests(keeper, ctx, "beneficiary", 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -34,6 +35,7 @@ func TestGetMintRequestByHash(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMintRequestByAddress(t *testing.T) {
|
func TestGetMintRequestByAddress(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
items := createNMintRequests(keeper, ctx, "beneficiary", 10)
|
items := createNMintRequests(keeper, ctx, "beneficiary", 10)
|
||||||
mintRequests, found := keeper.GetMintRequestsByAddress(ctx, "beneficiary")
|
mintRequests, found := keeper.GetMintRequestsByAddress(ctx, "beneficiary")
|
||||||
|
@ -20,12 +20,14 @@ func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServer(t *testing.T) {
|
func TestMsgServer(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ms, ctx := setupMsgServer(t)
|
ms, ctx := setupMsgServer(t)
|
||||||
require.NotNil(t, ms)
|
require.NotNil(t, ms)
|
||||||
require.NotNil(t, ctx)
|
require.NotNil(t, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerReportPoPResult(t *testing.T) {
|
func TestMsgServerReportPoPResult(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
initiator := sample.Secp256k1AccAddress()
|
initiator := sample.Secp256k1AccAddress()
|
||||||
challenger := sample.Secp256k1AccAddress()
|
challenger := sample.Secp256k1AccAddress()
|
||||||
challengee := sample.Secp256k1AccAddress()
|
challengee := sample.Secp256k1AccAddress()
|
||||||
@ -94,6 +96,7 @@ func TestMsgServerReportPoPResult(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestMsgServerMintToken(t *testing.T) {
|
func TestMsgServerMintToken(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
minter := sample.AccAddress()
|
minter := sample.AccAddress()
|
||||||
beneficiary := sample.ConstBech32Addr
|
beneficiary := sample.ConstBech32Addr
|
||||||
mintRequest := sample.MintRequest(beneficiary, 1000, "hash")
|
mintRequest := sample.MintRequest(beneficiary, 1000, "hash")
|
||||||
@ -113,6 +116,7 @@ func TestMsgServerMintToken(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerMintTokenInvalidAddress(t *testing.T) {
|
func TestMsgServerMintTokenInvalidAddress(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
minter := sample.AccAddress()
|
minter := sample.AccAddress()
|
||||||
beneficiary := "invalid address"
|
beneficiary := "invalid address"
|
||||||
mintRequest := sample.MintRequest(beneficiary, 1000, "hash")
|
mintRequest := sample.MintRequest(beneficiary, 1000, "hash")
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetParams(t *testing.T) {
|
func TestGetParams(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
k, ctx := testkeeper.DaoKeeper(t)
|
k, ctx := testkeeper.DaoKeeper(t)
|
||||||
params := types.DefaultParams()
|
params := types.DefaultParams()
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestQueryGetMintRequestByHash(t *testing.T) {
|
func TestQueryGetMintRequestByHash(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
wctx := sdk.WrapSDKContext(ctx)
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
items := createNMintRequests(keeper, ctx, sample.ConstBech32Addr, 1)
|
items := createNMintRequests(keeper, ctx, sample.ConstBech32Addr, 1)
|
||||||
@ -34,7 +35,9 @@ func TestQueryGetMintRequestByHash(t *testing.T) {
|
|||||||
err: status.Error(codes.NotFound, "mint request not found"),
|
err: status.Error(codes.NotFound, "mint request not found"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
tc := tc
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
res, err := keeper.GetMintRequestsByHash(wctx, tc.request)
|
res, err := keeper.GetMintRequestsByHash(wctx, tc.request)
|
||||||
if tc.err != nil {
|
if tc.err != nil {
|
||||||
require.ErrorIs(t, err, tc.err)
|
require.ErrorIs(t, err, tc.err)
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestQueryGetReissuance(t *testing.T) {
|
func TestQueryGetReissuance(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
wctx := sdk.WrapSDKContext(ctx)
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
items := createNReissuances(keeper, ctx, 1)
|
items := createNReissuances(keeper, ctx, 1)
|
||||||
@ -33,7 +34,9 @@ func TestQueryGetReissuance(t *testing.T) {
|
|||||||
err: status.Error(codes.NotFound, "reissuance not found"),
|
err: status.Error(codes.NotFound, "reissuance not found"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
tc := tc
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
res, err := keeper.GetReissuance(wctx, tc.request)
|
res, err := keeper.GetReissuance(wctx, tc.request)
|
||||||
if tc.err != nil {
|
if tc.err != nil {
|
||||||
require.ErrorIs(t, err, tc.err)
|
require.ErrorIs(t, err, tc.err)
|
||||||
|
@ -24,5 +24,4 @@ func (k Keeper) GetReissuances(goCtx context.Context, req *types.QueryGetReissua
|
|||||||
return &types.QueryGetReissuancesResponse{Reissuance: &reissuances[0]}, nil
|
return &types.QueryGetReissuancesResponse{Reissuance: &reissuances[0]}, nil
|
||||||
}
|
}
|
||||||
return &types.QueryGetReissuancesResponse{}, nil
|
return &types.QueryGetReissuancesResponse{}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestParamsQuery(t *testing.T) {
|
func TestParamsQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := testkeeper.DaoKeeper(t)
|
keeper, ctx := testkeeper.DaoKeeper(t)
|
||||||
wctx := sdk.WrapSDKContext(ctx)
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
params := types.DefaultParams()
|
params := types.DefaultParams()
|
||||||
|
@ -25,6 +25,7 @@ func createNReissuances(k *keeper.Keeper, ctx sdk.Context, n int) []types.Reissu
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetReissuances(t *testing.T) {
|
func TestGetReissuances(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.DaoKeeper(t)
|
keeper, ctx := keepertest.DaoKeeper(t)
|
||||||
items := createNReissuances(keeper, ctx, 10)
|
items := createNReissuances(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesisState_Validate(t *testing.T) {
|
func TestGenesisState_Validate(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
genState *types.GenesisState
|
genState *types.GenesisState
|
||||||
@ -29,7 +30,9 @@ func TestGenesisState_Validate(t *testing.T) {
|
|||||||
// this line is used by starport scaffolding # types/genesis/testcase
|
// this line is used by starport scaffolding # types/genesis/testcase
|
||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
tc := tc
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tc.genState.Validate()
|
err := tc.genState.Validate()
|
||||||
if tc.valid {
|
if tc.valid {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMsgMintToken_ValidateBasic(t *testing.T) {
|
func TestMsgMintToken_ValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msg MsgMintToken
|
msg MsgMintToken
|
||||||
@ -22,7 +23,9 @@ func TestMsgMintToken_ValidateBasic(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tt.msg.ValidateBasic()
|
err := tt.msg.ValidateBasic()
|
||||||
if tt.err != nil {
|
if tt.err != nil {
|
||||||
require.ErrorIs(t, err, tt.err)
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMsgUpdateParams_ValidateBasic(t *testing.T) {
|
func TestMsgUpdateParams_ValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msg MsgUpdateParams
|
msg MsgUpdateParams
|
||||||
@ -22,7 +23,9 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tt.msg.ValidateBasic()
|
err := tt.msg.ValidateBasic()
|
||||||
if tt.err != nil {
|
if tt.err != nil {
|
||||||
require.ErrorIs(t, err, tt.err)
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesis(t *testing.T) {
|
func TestGenesis(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
genesisState := types.GenesisState{
|
genesisState := types.GenesisState{
|
||||||
Params: types.DefaultParams(),
|
Params: types.DefaultParams(),
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ func createNMachine(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Machi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMachine(t *testing.T) {
|
func TestGetMachine(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.MachineKeeper(t)
|
keeper, ctx := keepertest.MachineKeeper(t)
|
||||||
items := createNMachine(keeper, ctx, 10)
|
items := createNMachine(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -42,6 +43,7 @@ func TestGetMachine(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetMachineIndexByPubKey(t *testing.T) {
|
func TestGetMachineIndexByPubKey(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.MachineKeeper(t)
|
keeper, ctx := keepertest.MachineKeeper(t)
|
||||||
items := createNMachine(keeper, ctx, 10)
|
items := createNMachine(keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
|
@ -21,12 +21,14 @@ func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServer(t *testing.T) {
|
func TestMsgServer(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
ms, ctx := setupMsgServer(t)
|
ms, ctx := setupMsgServer(t)
|
||||||
require.NotNil(t, ms)
|
require.NotNil(t, ms)
|
||||||
require.NotNil(t, ctx)
|
require.NotNil(t, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerAttestMachine(t *testing.T) {
|
func TestMsgServerAttestMachine(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
sk, pk := sample.KeyPair()
|
sk, pk := sample.KeyPair()
|
||||||
ta := sample.TrustAnchor(pk)
|
ta := sample.TrustAnchor(pk)
|
||||||
taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||||
@ -42,6 +44,7 @@ func TestMsgServerAttestMachine(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) {
|
func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
sk, pk := sample.KeyPair()
|
sk, pk := sample.KeyPair()
|
||||||
ta := sample.TrustAnchor(pk)
|
ta := sample.TrustAnchor(pk)
|
||||||
taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||||
@ -56,6 +59,7 @@ func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerRegisterTrustAnchor(t *testing.T) {
|
func TestMsgServerRegisterTrustAnchor(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
_, pk := sample.KeyPair()
|
_, pk := sample.KeyPair()
|
||||||
ta := sample.TrustAnchor(pk)
|
ta := sample.TrustAnchor(pk)
|
||||||
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||||
@ -67,6 +71,7 @@ func TestMsgServerRegisterTrustAnchor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerRegisterTrustAnchorTwice(t *testing.T) {
|
func TestMsgServerRegisterTrustAnchorTwice(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
_, pk := sample.KeyPair()
|
_, pk := sample.KeyPair()
|
||||||
ta := sample.TrustAnchor(pk)
|
ta := sample.TrustAnchor(pk)
|
||||||
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||||
@ -80,6 +85,7 @@ func TestMsgServerRegisterTrustAnchorTwice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgServerRegisterTrustAnchorInvalidPubkey(t *testing.T) {
|
func TestMsgServerRegisterTrustAnchorInvalidPubkey(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
_, pk := sample.KeyPair()
|
_, pk := sample.KeyPair()
|
||||||
ta := types.TrustAnchor{
|
ta := types.TrustAnchor{
|
||||||
Pubkey: "invalidpublickey",
|
Pubkey: "invalidpublickey",
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetParams(t *testing.T) {
|
func TestGetParams(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
k, ctx := testkeeper.MachineKeeper(t)
|
k, ctx := testkeeper.MachineKeeper(t)
|
||||||
params := types.DefaultParams()
|
params := types.DefaultParams()
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package keeper_test
|
package keeper_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
||||||
"github.com/planetmint/planetmint-go/x/machine/types"
|
"github.com/planetmint/planetmint-go/x/machine/types"
|
||||||
"testing"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -41,7 +42,6 @@ func TestGetMachineByPublicKey(t *testing.T) {
|
|||||||
err: status.Error(codes.NotFound, "machine not found"),
|
err: status.Error(codes.NotFound, "machine not found"),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
tc := tc
|
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
response, err := keeper.GetMachineByPublicKey(wctx, tc.request)
|
response, err := keeper.GetMachineByPublicKey(wctx, tc.request)
|
||||||
if tc.err != nil {
|
if tc.err != nil {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package keeper_test
|
package keeper_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
|
||||||
"github.com/planetmint/planetmint-go/x/machine/types"
|
"github.com/planetmint/planetmint-go/x/machine/types"
|
||||||
"testing"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -12,6 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGetTrustAnchorQuery(t *testing.T) {
|
func TestGetTrustAnchorQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.MachineKeeper(t)
|
keeper, ctx := keepertest.MachineKeeper(t)
|
||||||
wctx := sdk.WrapSDKContext(ctx)
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
msgs := createNTrustAnchor(t, keeper, ctx, 2)
|
msgs := createNTrustAnchor(t, keeper, ctx, 2)
|
||||||
@ -39,6 +41,7 @@ func TestGetTrustAnchorQuery(t *testing.T) {
|
|||||||
} {
|
} {
|
||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
response, err := keeper.GetTrustAnchorStatus(wctx, tc.request)
|
response, err := keeper.GetTrustAnchorStatus(wctx, tc.request)
|
||||||
if tc.err != nil {
|
if tc.err != nil {
|
||||||
require.ErrorIs(t, err, tc.err)
|
require.ErrorIs(t, err, tc.err)
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestParamsQuery(t *testing.T) {
|
func TestParamsQuery(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := testkeeper.MachineKeeper(t)
|
keeper, ctx := testkeeper.MachineKeeper(t)
|
||||||
wctx := sdk.WrapSDKContext(ctx)
|
wctx := sdk.WrapSDKContext(ctx)
|
||||||
params := types.DefaultParams()
|
params := types.DefaultParams()
|
||||||
|
@ -37,6 +37,7 @@ func createNTrustAnchor(t *testing.T, keeper *keeper.Keeper, ctx sdk.Context, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetTrustAnchor(t *testing.T) {
|
func TestGetTrustAnchor(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.MachineKeeper(t)
|
keeper, ctx := keepertest.MachineKeeper(t)
|
||||||
items := createNTrustAnchor(t, keeper, ctx, 10)
|
items := createNTrustAnchor(t, keeper, ctx, 10)
|
||||||
for i, item := range items {
|
for i, item := range items {
|
||||||
@ -52,6 +53,7 @@ func TestGetTrustAnchor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateTrustAnchor(t *testing.T) {
|
func TestUpdateTrustAnchor(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.MachineKeeper(t)
|
keeper, ctx := keepertest.MachineKeeper(t)
|
||||||
items := createNTrustAnchor(t, keeper, ctx, 10)
|
items := createNTrustAnchor(t, keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -69,6 +71,7 @@ func TestUpdateTrustAnchor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateTrustAnchorInvalidPubKey(t *testing.T) {
|
func TestUpdateTrustAnchorInvalidPubKey(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
keeper, ctx := keepertest.MachineKeeper(t)
|
keeper, ctx := keepertest.MachineKeeper(t)
|
||||||
items := createNTrustAnchor(t, keeper, ctx, 10)
|
items := createNTrustAnchor(t, keeper, ctx, 10)
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenesisStateValidate(t *testing.T) {
|
func TestGenesisStateValidate(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
desc string
|
desc string
|
||||||
genState *types.GenesisState
|
genState *types.GenesisState
|
||||||
@ -30,7 +31,9 @@ func TestGenesisStateValidate(t *testing.T) {
|
|||||||
// this line is used by starport scaffolding # types/genesis/testcase
|
// this line is used by starport scaffolding # types/genesis/testcase
|
||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
tc := tc
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tc.genState.Validate()
|
err := tc.genState.Validate()
|
||||||
if tc.valid {
|
if tc.valid {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMsgAttestMachineValidateBasic(t *testing.T) {
|
func TestMsgAttestMachineValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msg MsgAttestMachine
|
msg MsgAttestMachine
|
||||||
@ -22,7 +23,9 @@ func TestMsgAttestMachineValidateBasic(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tt.msg.ValidateBasic()
|
err := tt.msg.ValidateBasic()
|
||||||
if tt.err != nil {
|
if tt.err != nil {
|
||||||
require.ErrorIs(t, err, tt.err)
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMsgRegisterTrustAnchor_ValidateBasic(t *testing.T) {
|
func TestMsgRegisterTrustAnchor_ValidateBasic(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msg MsgRegisterTrustAnchor
|
msg MsgRegisterTrustAnchor
|
||||||
@ -22,7 +23,9 @@ func TestMsgRegisterTrustAnchor_ValidateBasic(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
err := tt.msg.ValidateBasic()
|
err := tt.msg.ValidateBasic()
|
||||||
if tt.err != nil {
|
if tt.err != nil {
|
||||||
require.ErrorIs(t, err, tt.err)
|
require.ErrorIs(t, err, tt.err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user