Documentation ¶
Index ¶
- Constants
- Variables
- func DumpAccounts(accounts []*Account, file string) error
- func DumpKeys(keys []*Key, file string) error
- type Account
- type AccountJSON
- type Client
- func (c *Client) CallAction(sender *Account, contractName, actionName string, args ...interface{}) (string, error)
- func (c *Client) ContractTransfer(cid string, sender, recipient *Account, amount string) error
- func (c *Client) CreateAccount(creator *Account, name string, key *Key) (*Account, error)
- func (c *Client) GetAccount(name string) (*Account, error)
- func (c *Client) GetReceipt(hash string) (*Receipt, error)
- func (c *Client) GetTransaction(hash string) (*Transaction, error)
- func (c *Client) SendTransaction(transaction *Transaction) (string, error)
- func (c *Client) SetContract(creator *Account, contract *Contract) (string, error)
- func (c *Client) Transfer(sender, recipient *Account, token, amount string) error
- func (c *Client) Vote(sender *Account, voteID, recipient, amount string) error
- func (c *Client) VoteProducer(sender *Account, recipient, amount string) error
- type Config
- type Contract
- type ITest
- func (t *ITest) CallActionWithRandClient(sender *Account, contractName, actionName string, args ...interface{}) (string, error)
- func (t *ITest) CheckAccounts(a []*Account) error
- func (t *ITest) ContractTransfer(cid string, sender, recipient *Account, amount string) error
- func (t *ITest) ContractTransferN(cid string, num int, accounts []*Account) error
- func (t *ITest) CreateAccount(name string) (*Account, error)
- func (t *ITest) CreateAccountN(num int) ([]*Account, error)
- func (t *ITest) GetAccount(name string) (*Account, error)
- func (t *ITest) GetClients() []*Client
- func (t *ITest) GetDefaultAccount() *Account
- func (t *ITest) GetTransaction(hash string) (*Transaction, error)
- func (t *ITest) SendTransaction(transaction *Transaction) (string, error)
- func (t *ITest) SetContract(contract *Contract) (string, error)
- func (t *ITest) Transfer(sender, recipient *Account, token, amount string) error
- func (t *ITest) TransferN(num int, accounts []*Account) error
- func (t *ITest) Vote(sender *Account, recipient, amount string) error
- func (t *ITest) VoteN(num, pnum int, accounts []*Account) error
- type Key
- type KeyJSON
- type Receipt
- type Runner
- type Transaction
Constants ¶
const ( DefaultCode = `` /* 301-byte string literal not displayed */ DefaultABI = `` /* 251-byte string literal not displayed */ )
Constant of Contract
const (
DefaultITestConfig = `` /* 259-byte string literal not displayed */
)
Constant of itest config
const (
DefaultKeys = `` /* 641-byte string literal not displayed */
)
Constant of key
const (
Zero = 1e-6
)
Constant of itest
Variables ¶
var ( Interval = 15 * time.Second Timeout = (90 + 30) * time.Second InitToken = "iost" InitAmount = "1000000" InitPledge = "1000000" InitRAM = "1000000" )
Constant of Client
var ( GasLimit = int64(100000000) // about 30000~100000 gas per tx GasRatio = int64(100) // 1 mutiple gas Expiration = int64(math.MaxInt64) // Max expired time is 90 seconds Delay = int64(0 * time.Second) // No delay Signers = make([]string, 0) // No mutiple signers AmountLimit = []*contract.Amount{{Token: "iost", Val: "unlimited"}} )
Constant of Transaction
Functions ¶
func DumpAccounts ¶
DumpAccounts will dump the accounts to file
Types ¶
type Account ¶
type Account struct { ID string // contains filtered or unexported fields }
Account is account of user
func LoadAccounts ¶
LoadAccounts will load accounts from file
func NewAccount ¶
NewAccount return a new account
func (*Account) AddBalance ¶
AddBalance will add the balance of this account
func (*Account) MarshalJSON ¶
MarshalJSON will marshal account to json
func (*Account) Sign ¶
func (a *Account) Sign(t *Transaction) (*Transaction, error)
Sign will sign the transaction by current account
func (*Account) UnmarshalJSON ¶
UnmarshalJSON will unmarshal account from json
type AccountJSON ¶
type AccountJSON struct { ID string `json:"id"` Balance string `json:"balance"` Seckey string `json:"seckey"` Algorithm string `json:"algorithm"` }
AccountJSON is the json serialization of account
type Client ¶
Client is a grpc client for iserver
func (*Client) CallAction ¶
func (c *Client) CallAction(sender *Account, contractName, actionName string, args ...interface{}) (string, error)
CallAction send a tx with given actions
func (*Client) ContractTransfer ¶
ContractTransfer will contract transfer token by sending transaction
func (*Client) CreateAccount ¶
CreateAccount will create account by sending transaction
func (*Client) GetAccount ¶
GetAccount will get account by name
func (*Client) GetReceipt ¶
GetReceipt will get receipt by tx hash
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(hash string) (*Transaction, error)
GetTransaction will get transaction by tx hash
func (*Client) SendTransaction ¶
func (c *Client) SendTransaction(transaction *Transaction) (string, error)
SendTransaction will send transaction to blockchain
func (*Client) SetContract ¶
SetContract will set the contract by sending transaction
type Config ¶
Config is the config of itest
func LoadConfig ¶
LoadConfig will load the itest config from file
type Contract ¶
Contract is the contract object
func LoadContract ¶
LoadContract will load a contract from file
func NewContract ¶
NewContract will return a new contract
type ITest ¶
type ITest struct {
// contains filtered or unexported fields
}
ITest is the test controller
func (*ITest) CallActionWithRandClient ¶
func (t *ITest) CallActionWithRandClient(sender *Account, contractName, actionName string, args ...interface{}) (string, error)
CallActionWithRandClient randomly select one client and use it to send a tx
func (*ITest) CheckAccounts ¶
CheckAccounts will check account info by getting account info
func (*ITest) ContractTransfer ¶
ContractTransfer will contract transfer token from sender to recipient
func (*ITest) ContractTransferN ¶
ContractTransferN will send n contract transfer transaction concurrently
func (*ITest) CreateAccount ¶
CreateAccount will create a account by name
func (*ITest) CreateAccountN ¶
CreateAccountN will create n accounts concurrently
func (*ITest) GetAccount ¶
GetAccount will get account by name
func (*ITest) GetDefaultAccount ¶
GetDefaultAccount return the bank account
func (*ITest) GetTransaction ¶
func (t *ITest) GetTransaction(hash string) (*Transaction, error)
GetTransaction will get transaction by tx hash
func (*ITest) SendTransaction ¶
func (t *ITest) SendTransaction(transaction *Transaction) (string, error)
SendTransaction will send transaction to blockchain
func (*ITest) SetContract ¶
SetContract will set the contract on blockchain
type Key ¶
Key is the key pair
func (*Key) MarshalJSON ¶
MarshalJSON will marshal key to json
func (*Key) UnmarshalJSON ¶
UnmarshalJSON will unmarshal key from json
type Receipt ¶
Receipt is the transaction receipt object
func NewReceiptFromPb ¶
func NewReceiptFromPb(tr *rpcpb.TxReceipt) *Receipt
NewReceiptFromPb returns a new Receipt instance from protobuffer struct.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is the benchmark runner
type Transaction ¶
Transaction is the transaction object
func NewTransaction ¶
func NewTransaction(actions []*tx.Action) *Transaction
NewTransaction will return a new transaction by actions
func NewTransactionFromPb ¶
func NewTransactionFromPb(t *rpcpb.Transaction) *Transaction
NewTransactionFromPb returns a new transaction instance from protobuffer transaction struct.
func (*Transaction) ToTxRequest ¶
func (t *Transaction) ToTxRequest() *rpcpb.TransactionRequest
ToTxRequest converts tx to rpcpb.TransactionRequest.