Documentation ¶
Index ¶
- func RequireTxFailure(t *testing.T, got string, containsMsgs ...string)
- func RequireTxSuccess(t *testing.T, got string)
- type CleanupFn
- type EventConsumer
- type EventListener
- type GenesisMutator
- func SetAllEngagementPoints(t *testing.T, points int) GenesisMutator
- func SetBlockRewards(t *testing.T, amount sdk.Coin) GenesisMutator
- func SetConsensusMaxGas(t *testing.T, max int) GenesisMutator
- func SetEpochLength(t *testing.T, epoch time.Duration) GenesisMutator
- func SetGlobalMinFee(t *testing.T, fees ...sdk.DecCoin) GenesisMutator
- func SetPoEParamsMutator(t *testing.T, params poetypes.Params) GenesisMutator
- func SetUnbondingPeriod(t *testing.T, unbonding time.Duration) GenesisMutator
- type Node
- type RPCClient
- type RunErrorAssert
- type SystemUnderTest
- func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumber int, nodePath string)) Node
- func (s SystemUnderTest) AllNodes(t *testing.T) []Node
- func (s SystemUnderTest) AllPeers(t *testing.T) []string
- func (s *SystemUnderTest) AwaitNextBlock(t *testing.T, timeout ...time.Duration) int64
- func (s *SystemUnderTest) AwaitNodeUp(t *testing.T, rpcAddr string)
- func (s SystemUnderTest) BuildNewBinary()
- func (s *SystemUnderTest) ForEachNodeExecAndWait(t *testing.T, cmds ...[]string) [][]string
- func (s SystemUnderTest) IsDirty() bool
- func (s SystemUnderTest) Log(msg string)
- func (s SystemUnderTest) Logf(msg string, args ...interface{})
- func (s *SystemUnderTest) MarkDirty()
- func (s *SystemUnderTest) ModifyGenesisCLI(t *testing.T, cmds ...[]string)
- func (s *SystemUnderTest) ModifyGenesisJSON(t *testing.T, mutators ...GenesisMutator)
- func (s *SystemUnderTest) NewEventListener(t *testing.T) *EventListener
- func (s SystemUnderTest) PrintBuffer()
- func (s SystemUnderTest) RPCClient(t *testing.T) RPCClient
- func (s *SystemUnderTest) ReadGenesisJSON(t *testing.T) string
- func (s *SystemUnderTest) ResetChain(t *testing.T)
- func (s *SystemUnderTest) ResetDirtyChain(t *testing.T)
- func (s *SystemUnderTest) SetupChain()
- func (s *SystemUnderTest) StartChain(t *testing.T, xargs ...string)
- func (s *SystemUnderTest) StopChain()
- type TgradeCli
- func (c TgradeCli) AddKey(name string) string
- func (c TgradeCli) CustomCommand(args ...string) string
- func (c TgradeCli) CustomQuery(args ...string) string
- func (c TgradeCli) Execute(contractAddr, msg, from string, args ...string) string
- func (c TgradeCli) FundAddress(destAddr, amount string) string
- func (c TgradeCli) GetKeyAddr(name string) string
- func (c TgradeCli) GetPoEContractAddress(v string) string
- func (c TgradeCli) GetTendermintValidatorSet() rpc.ResultValidatorsOutput
- func (c TgradeCli) InstantiateWasm(codeID int, initMsg string, args ...string) string
- func (c TgradeCli) IsInTendermintValset(valPubKey cryptotypes.PubKey) (rpc.ResultValidatorsOutput, bool)
- func (c TgradeCli) Keys(args ...string) string
- func (c TgradeCli) QueryBalance(addr, denom string) int64
- func (c TgradeCli) QueryBalances(addr string) string
- func (c TgradeCli) QuerySmart(contractAddr, msg string, args ...string) string
- func (c TgradeCli) QueryTotalSupply(denom string) int64
- func (c TgradeCli) QueryValidator(addr string) string
- func (c TgradeCli) QueryValidatorRewards(addr string) sdk.DecCoin
- func (c TgradeCli) StoreWasm(file string, args ...string) int
- func (c TgradeCli) WithNodeAddress(addr string) TgradeCli
- func (c TgradeCli) WithRunErrorMatcher(f RunErrorAssert) TgradeCli
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequireTxFailure ¶
RequireTxFailure require the received response to contain any failure code and the passed msgsgs
func RequireTxSuccess ¶
RequireTxSuccess require the received response to contain the success code
Types ¶
type EventConsumer ¶
type EventConsumer func(e ctypes.ResultEvent) (more bool)
func CaptureAllEventsConsumer ¶
func CaptureAllEventsConsumer(t *testing.T, optMaxWaitTime ...time.Duration) (c EventConsumer, done func() []ctypes.ResultEvent)
CaptureAllEventsConsumer is an `EventConsumer` that captures all events until `done()` is called to stop or timeout happens. The consumer works async in the background and returns all the captured events when `done()` is called. This can be used to verify that certain events have happened. Example usage:
c, done := CaptureAllEventsConsumer(t) query := `tm.event='Tx'` cleanupFn := l.Subscribe(query, c) t.Cleanup(cleanupFn) // do something in your test that create events assert.Len(t, done(), 1) // then verify your assumption
func CaptureSingleEventConsumer ¶
func CaptureSingleEventConsumer() (EventConsumer, *ctypes.ResultEvent)
CaptureSingleEventConsumer consumes one event. No timeout
func TimeoutConsumer ¶
func TimeoutConsumer(t *testing.T, maxWaitTime time.Duration, next EventConsumer) EventConsumer
TimeoutConsumer is an event consumer decorator with a max wait time. Panics when wait time exceeded without a result returned
type EventListener ¶
type EventListener struct {
// contains filtered or unexported fields
}
EventListener watches for events on the chain
func NewEventListener ¶
func NewEventListener(t *testing.T, rpcAddr string) *EventListener
NewEventListener event listener
func (*EventListener) AwaitQuery ¶
func (l *EventListener) AwaitQuery(query string, optMaxWaitTime ...time.Duration) *ctypes.ResultEvent
AwaitQuery blocks and waits for a single result or timeout. This can be used with `broadcast-mode=async`. For query syntax See https://docs.cosmos.network/master/core/events.html#subscribing-to-events
func (*EventListener) Subscribe ¶
func (l *EventListener) Subscribe(query string, cb EventConsumer) func()
Subscribe to receive events for a topic. Does not block. For query syntax See https://docs.cosmos.network/master/core/events.html#subscribing-to-events
type GenesisMutator ¶
func SetAllEngagementPoints ¶
func SetAllEngagementPoints(t *testing.T, points int) GenesisMutator
SetAllEngagementPoints set the given value for all members of the engagement group (default = validators)
func SetBlockRewards ¶
func SetBlockRewards(t *testing.T, amount sdk.Coin) GenesisMutator
SetBlockRewards set the valset contract config unbonding period
func SetConsensusMaxGas ¶
func SetConsensusMaxGas(t *testing.T, max int) GenesisMutator
SetConsensusMaxGas max gas that can be consumed in a block
func SetEpochLength ¶
func SetEpochLength(t *testing.T, epoch time.Duration) GenesisMutator
SetEpochLength set the valset contract config to given epoch length
func SetGlobalMinFee ¶
func SetGlobalMinFee(t *testing.T, fees ...sdk.DecCoin) GenesisMutator
SetGlobalMinFee set the passed coins to the global minimum fee
func SetPoEParamsMutator ¶
func SetPoEParamsMutator(t *testing.T, params poetypes.Params) GenesisMutator
SetPoEParamsMutator set params in genesis
func SetUnbondingPeriod ¶ added in v0.8.0
func SetUnbondingPeriod(t *testing.T, unbonding time.Duration) GenesisMutator
SetUnbondingPeriod set the stake contract config unbonding period
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient is a test helper to interact with a node via the RPC endpoint.
func (RPCClient) Validators ¶
type RunErrorAssert ¶
RunErrorAssert is custom type that is satisfies by testify matchers as well
var ( // ErrOutOfGasMatcher requires error with out of gas message ErrOutOfGasMatcher RunErrorAssert = func(t require.TestingT, err error, args ...interface{}) { const oogMsg = "out of gas" expErrWithMsg(t, err, args, oogMsg) } // ErrTimeoutMatcher requires time out message ErrTimeoutMatcher RunErrorAssert = func(t require.TestingT, err error, args ...interface{}) { const expMsg = "timed out waiting for tx to be included in a block" expErrWithMsg(t, err, args, expMsg) } // ErrPostFailedMatcher requires post failed ErrPostFailedMatcher RunErrorAssert = func(t require.TestingT, err error, args ...interface{}) { const expMsg = "post failed" expErrWithMsg(t, err, args, expMsg) } // ErrInvalidQuery requires smart query request failed ErrInvalidQuery RunErrorAssert = func(t require.TestingT, err error, args ...interface{}) { const expMsg = "query wasm contract failed" expErrWithMsg(t, err, args, expMsg) } )
type SystemUnderTest ¶
type SystemUnderTest struct { ChainStarted bool // contains filtered or unexported fields }
SystemUnderTest blockchain provisioning
func NewSystemUnderTest ¶
func NewSystemUnderTest(verbose bool, nodesCount int, blockTime time.Duration) *SystemUnderTest
func (*SystemUnderTest) AddFullnode ¶
func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumber int, nodePath string)) Node
AddFullnode starts a new fullnode that connects to the existing chain but is not a validator.
func (*SystemUnderTest) AwaitNextBlock ¶
AwaitNextBlock is a first class function that any caller can use to ensure a new block was minted. Returns the new height
func (*SystemUnderTest) AwaitNodeUp ¶
func (s *SystemUnderTest) AwaitNodeUp(t *testing.T, rpcAddr string)
AwaitNodeUp ensures the node is running
func (SystemUnderTest) BuildNewBinary ¶
func (s SystemUnderTest) BuildNewBinary()
BuildNewBinary builds and installs new tgrade binary
func (*SystemUnderTest) ForEachNodeExecAndWait ¶
func (s *SystemUnderTest) ForEachNodeExecAndWait(t *testing.T, cmds ...[]string) [][]string
ForEachNodeExecAndWait runs the given tgrade commands for all cluster nodes synchronously The commands output is returned for each node.
func (SystemUnderTest) IsDirty ¶
func (s SystemUnderTest) IsDirty() bool
IsDirty true when non default genesis or other state modification were applied that might create incompatibility for tests
func (SystemUnderTest) Log ¶
func (s SystemUnderTest) Log(msg string)
func (SystemUnderTest) Logf ¶
func (s SystemUnderTest) Logf(msg string, args ...interface{})
func (*SystemUnderTest) MarkDirty ¶
func (s *SystemUnderTest) MarkDirty()
MarkDirty whole chain will be reset when marked dirty
func (*SystemUnderTest) ModifyGenesisCLI ¶
func (s *SystemUnderTest) ModifyGenesisCLI(t *testing.T, cmds ...[]string)
ModifyGenesisCLI executes the CLI commands to modify the genesis
func (*SystemUnderTest) ModifyGenesisJSON ¶
func (s *SystemUnderTest) ModifyGenesisJSON(t *testing.T, mutators ...GenesisMutator)
ModifyGenesisJSON resets the chain and executes the callbacks to update the json representation The mutator callbacks after each other receive the genesis as raw bytes and return the updated genesis for the next. example:
return func(genesis []byte) []byte { val, _ := json.Marshal(sdk.NewDecCoins(fees...)) state, _ := sjson.SetRawBytes(genesis, "app_state.globalfee.params.minimum_gas_prices", val) return state }
func (*SystemUnderTest) NewEventListener ¶
func (s *SystemUnderTest) NewEventListener(t *testing.T) *EventListener
NewEventListener constructor for Eventlistener with system rpc address
func (SystemUnderTest) PrintBuffer ¶
func (s SystemUnderTest) PrintBuffer()
PrintBuffer prints the chain logs to the console
func (*SystemUnderTest) ReadGenesisJSON ¶
func (s *SystemUnderTest) ReadGenesisJSON(t *testing.T) string
ReadGenesisJSON returns current genesis.json content as raw string
func (*SystemUnderTest) ResetChain ¶
func (s *SystemUnderTest) ResetChain(t *testing.T)
ResetChain stops and clears all nodes state via 'unsafe-reset-all'
func (*SystemUnderTest) ResetDirtyChain ¶
func (s *SystemUnderTest) ResetDirtyChain(t *testing.T)
ResetDirtyChain reset chain when non default setup or state (dirty)
func (*SystemUnderTest) SetupChain ¶
func (s *SystemUnderTest) SetupChain()
func (*SystemUnderTest) StartChain ¶
func (s *SystemUnderTest) StartChain(t *testing.T, xargs ...string)
func (*SystemUnderTest) StopChain ¶
func (s *SystemUnderTest) StopChain()
StopChain stops the system under test and executes all registered cleanup callbacks
type TgradeCli ¶
type TgradeCli struct { Debug bool // contains filtered or unexported fields }
TgradeCli wraps the command line interface
func NewTgradeCli ¶
func NewTgradeCli(t *testing.T, sut *SystemUnderTest, verbose bool) *TgradeCli
func NewTgradeCliX ¶
func (TgradeCli) CustomCommand ¶
func (TgradeCli) CustomQuery ¶
func (TgradeCli) FundAddress ¶
FundAddress sends the token amount to the destination address
func (TgradeCli) GetKeyAddr ¶
GetKeyAddr returns address
func (TgradeCli) GetPoEContractAddress ¶
GetPoEContractAddress query the PoE contract address
func (TgradeCli) GetTendermintValidatorSet ¶
func (c TgradeCli) GetTendermintValidatorSet() rpc.ResultValidatorsOutput
func (TgradeCli) InstantiateWasm ¶
InstantiateWasm create a new contract instance. returns contract address
func (TgradeCli) IsInTendermintValset ¶
func (c TgradeCli) IsInTendermintValset(valPubKey cryptotypes.PubKey) (rpc.ResultValidatorsOutput, bool)
IsInTendermintValset returns true when the giben pub key is in the current active tendermint validator set
func (TgradeCli) QueryBalance ¶
QueryBalance returns balance amount for given denom. 0 when not found
func (TgradeCli) QueryBalances ¶
QueryBalances queries all balances for an account. Returns json response Example:`{"balances":[{"denom":"node0token","amount":"1000000000"},{"denom":"utgd","amount":"400000003"}],"pagination":{}}`
func (TgradeCli) QuerySmart ¶
QuerySmart run smart contract query
func (TgradeCli) QueryTotalSupply ¶
QueryTotalSupply returns total amount of tokens for a given denom. 0 when not found
func (TgradeCli) QueryValidator ¶
QueryValidator queries the validator for the given operator address. Returns json response
func (TgradeCli) QueryValidatorRewards ¶
QueryValidatorRewards queries the validator rewards for the given operator address
func (TgradeCli) WithNodeAddress ¶
func (TgradeCli) WithRunErrorMatcher ¶
func (c TgradeCli) WithRunErrorMatcher(f RunErrorAssert) TgradeCli
WithRunErrorMatcher assert function to ensure run command error value