Documentation ¶
Overview ¶
Package testcli contains auxiliary code to test CLI commands.
All testdata assets for it are contained in the cli directory and paths here use `../` prefix to reference them because the package itself is used from cli/* subpackages.
Index ¶
- Constants
- Variables
- func DeployContract(t *testing.T, e *Executor, inPath, configPath, wallet, address, pass string) util.Uint160
- func GenerateKeys(t *testing.T, n int) ([]*keys.PrivateKey, keys.PublicKeys)
- func NewTestChain(t *testing.T, f func(*config.Config), run bool) (*core.Blockchain, *rpcsrv.Server, *network.Server)
- type ConcurrentBuffer
- type Executor
- func (e *Executor) CheckEOF(t *testing.T)
- func (e *Executor) CheckLine(t *testing.T, line, expected string)
- func (e *Executor) CheckNextLine(t *testing.T, expected string)
- func (e *Executor) CheckScriptDump(t *testing.T, scriptSize int)
- func (e *Executor) CheckTxPersisted(t *testing.T, prefix ...string) (*transaction.Transaction, uint32)
- func (e *Executor) CheckTxTestInvokeOutput(t *testing.T, scriptSize int)
- func (e *Executor) Close(t *testing.T)
- func (e *Executor) GetNextLine(t *testing.T) string
- func (e *Executor) GetTransaction(t *testing.T, h util.Uint256) (*transaction.Transaction, uint32)
- func (e *Executor) Run(t *testing.T, args ...string)
- func (e *Executor) RunWithError(t *testing.T, args ...string)
Constants ¶
const ( ValidatorWIF = "KxyjQ8eUa4FHt3Gvioyt1Wz29cTUrE4eTqX3yFSk1YFCsPL8uNsY" ValidatorAddr = "NfgHwwTi3wHAS8aFAN243C5vGbkYDpqLHP" MultisigAddr = "NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq" TestWalletPath = "../testdata/testwallet.json" TestWalletAccount = "Nfyz4KcsgYepRJw1W5C2uKCi6QWKf7v6gG" ValidatorWallet = "../testdata/wallet1_solo.json" ValidatorPass = "one" )
Variables ¶
var (
ValidatorHash, _ = address.StringToUint160(ValidatorAddr)
ValidatorPriv, _ = keys.NewPrivateKeyFromWIF(ValidatorWIF)
)
Functions ¶
func DeployContract ¶
func GenerateKeys ¶
func GenerateKeys(t *testing.T, n int) ([]*keys.PrivateKey, keys.PublicKeys)
Types ¶
type ConcurrentBuffer ¶
type ConcurrentBuffer struct {
// contains filtered or unexported fields
}
ConcurrentBuffer is a wrapper over Buffer with mutex.
func NewConcurrentBuffer ¶
func NewConcurrentBuffer() *ConcurrentBuffer
NewConcurrentBuffer returns new ConcurrentBuffer with underlying buffer initialized.
func (*ConcurrentBuffer) Bytes ¶
func (w *ConcurrentBuffer) Bytes() []byte
Bytes is a concurrent wrapper over the corresponding method of bytes.Buffer.
func (*ConcurrentBuffer) ReadString ¶
func (w *ConcurrentBuffer) ReadString(delim byte) (string, error)
ReadString is a concurrent wrapper over the corresponding method of bytes.Buffer.
func (*ConcurrentBuffer) Reset ¶
func (w *ConcurrentBuffer) Reset()
Reset is a concurrent wrapper over the corresponding method of bytes.Buffer.
func (*ConcurrentBuffer) String ¶
func (w *ConcurrentBuffer) String() string
String is a concurrent wrapper over the corresponding method of bytes.Buffer.
type Executor ¶
type Executor struct { // CLI is a cli application to test. CLI *cli.App // Chain is a blockchain instance (can be empty). Chain *core.Blockchain // RPC is an RPC server to query (can be empty). RPC *rpcsrv.Server // NetSrv is a network server (can be empty). NetSrv *network.Server // Out contains command output. Out *ConcurrentBuffer // Err contains command errors. Err *bytes.Buffer // In contains command input. In *bytes.Buffer }
Executor represents context for a test instance. It can be safely used in multiple tests, but not in parallel.
func NewExecutorSuspended ¶
func NewExecutorWithConfig ¶
func (*Executor) CheckTxPersisted ¶
func (e *Executor) CheckTxPersisted(t *testing.T, prefix ...string) (*transaction.Transaction, uint32)
func (*Executor) CheckTxTestInvokeOutput ¶
func (*Executor) GetTransaction ¶
func (e *Executor) GetTransaction(t *testing.T, h util.Uint256) (*transaction.Transaction, uint32)
GetTransaction returns tx with hash h after it has persisted. If it is in mempool, we can just wait for the next block, otherwise it must be already in chain. 1 second is time per block in a unittest chain.