Documentation
¶
Index ¶
- Variables
- func CreateTmpKeyStore(accountCount int) ([]string, error)
- func ExecShell(cmdstr string, param []string, logfile string, canquit bool) bool
- func MarshalIndent(v interface{}) string
- type Channel
- func (c1 *Channel) CheckEqualByPartnerNode(env *TestEnv) bool
- func (c1 *Channel) CheckLockBoth(lockAmt int32) bool
- func (c1 *Channel) CheckLockPartner(lockAmt int32) bool
- func (c1 *Channel) CheckLockSelf(lockAmt int32) bool
- func (c1 *Channel) CheckNoLock() bool
- func (c1 *Channel) CheckPartnerBalance(balance int32) bool
- func (c1 *Channel) CheckSelfBalance(balance int32) bool
- func (c1 *Channel) CheckState(state int) bool
- func (c *Channel) PrintDataAfterCrash() *Channel
- func (c *Channel) PrintDataAfterRestart() *Channel
- func (c *Channel) PrintDataAfterTransfer() *Channel
- func (c *Channel) PrintDataBeforeTransfer() *Channel
- func (c *Channel) Println(header string) *Channel
- type PartnersDataResponse
- type PhotonNode
- func (node *PhotonNode) AllowSecret(secretHash, token string)
- func (node *PhotonNode) CancelTransfer(token, locksecrethash string) (err error)
- func (node *PhotonNode) ClearHistoryData(dataDir string)
- func (node *PhotonNode) Close(channelIdentifier string, waitSeconds ...int) (err error)
- func (node *PhotonNode) CooperateSettle(channelIdentifier string, waitSeconds ...int) (err error)
- func (node *PhotonNode) Deposit(partnerAddress, tokenAddress string, balance int64, waitSeconds ...int) error
- func (node *PhotonNode) FindPath(target *PhotonNode, tokenAddress common.Address, amount int32) (path []pfsproxy.FindPathResponse)
- func (node *PhotonNode) ForceUnlock(channelIdentifier string, secret string) (err error)
- func (node *PhotonNode) GenerateSecret() (secret, secretHash string, err error)
- func (node *PhotonNode) GetAddress() common.Address
- func (node *PhotonNode) GetChannelWith(partnerNode *PhotonNode, tokenAddr string) *Channel
- func (node *PhotonNode) GetChannels(tokenAddr string) []*Channel
- func (node *PhotonNode) GetReceivedTransfers() (trs []*models.ReceivedTransfer, err error)
- func (node *PhotonNode) GetSentTransferDetail(token, locksecrethash string) (status *models.SentTransferDetail, err error)
- func (node *PhotonNode) GetSentTransferDetails() (trs []*models.SentTransferDetail, err error)
- func (node *PhotonNode) GetUnfinishedReceivedTransfer(token, locksecrethash string) (resp *photon.TransferDataResponse, err error)
- func (node *PhotonNode) IsRunning() bool
- func (node *PhotonNode) OpenChannel(partnerAddress, tokenAddress string, balance, settleTimeout int64, ...) error
- func (node *PhotonNode) PrepareUpdate() (err error)
- func (node *PhotonNode) ReStartWithoutConditionquit(env *TestEnv)
- func (node *PhotonNode) RegisterSecret(secret string) (err error)
- func (node *PhotonNode) RestartName() *PhotonNode
- func (node *PhotonNode) SendTrans(tokenAddress string, amount int32, targetAddress string, isDirect bool)
- func (node *PhotonNode) SendTransWithRouteInfo(target *PhotonNode, tokenAddress string, amount int32, ...)
- func (node *PhotonNode) SendTransWithSecret(tokenAddress string, amount int32, targetAddress string, secretSeed string)
- func (node *PhotonNode) SetConditionQuit(c *params.ConditionQuit) *PhotonNode
- func (node *PhotonNode) SetDoPprof() *PhotonNode
- func (node *PhotonNode) SetFeePolicy(fp *models.FeePolicy) error
- func (node *PhotonNode) SetNoNetwork() *PhotonNode
- func (node *PhotonNode) Settle(channelIdentifier string, waitSeconds ...int) (err error)
- func (node *PhotonNode) Shutdown(env *TestEnv)
- func (node *PhotonNode) SpecifiedChannel(channelIdentifier string) (c channeltype.ChannelDataDetail, err error)
- func (node *PhotonNode) Start(env *TestEnv)
- func (node *PhotonNode) StartWithFeeAndPFS(env *TestEnv)
- func (node *PhotonNode) SwitchNetwork(tomesh string) (err error)
- func (node *PhotonNode) TokenBalance(token string) (v int, err error)
- func (node *PhotonNode) TokenPartners(token string) (partners []*PartnersDataResponse, err error)
- func (node *PhotonNode) TokenSwap(target, locksecrethash, sendingtoken, receivingtoken, role, secret string, ...) error
- func (node *PhotonNode) Tokens() (tokens []string, err error)
- func (node *PhotonNode) Transfer(tokenAddress string, amount int32, targetAddress string, isDirect bool) error
- func (node *PhotonNode) UpdateMeshNetworkNodes(nodes ...*PhotonNode)
- func (node *PhotonNode) Withdraw(channelIdentifier string, withdrawAmount int32)
- type PhotonNodeRuntime
- type Req
- type TestEnv
- func (env *TestEnv) ClearHistoryData()
- func (env *TestEnv) GetNodeAddressByName(nodeName string) (index int, address common.Address)
- func (env *TestEnv) GetNodeByAddress(nodeAddress string) *PhotonNode
- func (env *TestEnv) GetPfsProxy(privateKey *ecdsa.PrivateKey) pfsproxy.PfsProxy
- func (env *TestEnv) GetPrivateKeyByNode(node *PhotonNode) (key *ecdsa.PrivateKey)
- func (env *TestEnv) GetTokenByName(tokenName string) (index int, token *Token)
- func (env *TestEnv) KillAllPhotonNodes()
- func (env *TestEnv) Println(header string)
- func (env *TestEnv) StartPFS()
- type Token
- type TransferPayload
Constants ¶
This section is empty.
Variables ¶
var Logger *log.Logger
Logger : global case logger
var TmpKeyStoreDir = "../../../testdata/casemanager-keystore-tmp"
TmpKeyStoreDir :
Functions ¶
func CreateTmpKeyStore ¶
CreateTmpKeyStore :
Types ¶
type Channel ¶
type Channel struct { Name string `json:"name"` SelfAddress string `json:"self_address"` ChannelIdentifier string `json:"channel_identifier"` PartnerAddress string `json:"partner_address"` Balance int32 `json:"balance"` LockedAmount int32 `json:"locked_amount"` PartnerBalance int32 `json:"partner_balance"` PartnerLockedAmount int32 `json:"partner_locked_amount"` TokenAddress string `json:"token_address"` State int `json:"state"` SettleTimeout int32 `json:"settle_timeout"` RevealTimeout int32 `json:"reveal_timeout"` }
Channel photon chainnode
func (*Channel) CheckEqualByPartnerNode ¶
CheckEqualByPartnerNode :
func (*Channel) CheckLockBoth ¶
CheckLockBoth :
func (*Channel) CheckLockPartner ¶
CheckLockPartner :
func (*Channel) CheckLockSelf ¶
CheckLockSelf :
func (*Channel) CheckPartnerBalance ¶
CheckPartnerBalance :
func (*Channel) CheckSelfBalance ¶
CheckSelfBalance :
func (*Channel) PrintDataAfterCrash ¶
PrintDataAfterCrash :
func (*Channel) PrintDataAfterRestart ¶
PrintDataAfterRestart :b
func (*Channel) PrintDataAfterTransfer ¶
PrintDataAfterTransfer :
func (*Channel) PrintDataBeforeTransfer ¶
PrintDataBeforeTransfer :
type PartnersDataResponse ¶
type PartnersDataResponse struct { PartnerAddress string `json:"partner_address"` Channel string `json:"channel"` }
PartnersDataResponse query by token
type PhotonNode ¶
type PhotonNode struct { Host string Address string Name string APIAddress string ListenAddress string ConditionQuit *params.ConditionQuit DebugCrash bool Running bool NoNetwork bool DoPprof bool Runtime PhotonNodeRuntime }
PhotonNode a photon node
func (*PhotonNode) AllowSecret ¶
func (node *PhotonNode) AllowSecret(secretHash, token string)
AllowSecret :
func (*PhotonNode) CancelTransfer ¶
func (node *PhotonNode) CancelTransfer(token, locksecrethash string) (err error)
CancelTransfer cancel a on transfer which secret is not revealed
func (*PhotonNode) ClearHistoryData ¶
func (node *PhotonNode) ClearHistoryData(dataDir string)
ClearHistoryData :
func (*PhotonNode) Close ¶
func (node *PhotonNode) Close(channelIdentifier string, waitSeconds ...int) (err error)
Close :
func (*PhotonNode) CooperateSettle ¶
func (node *PhotonNode) CooperateSettle(channelIdentifier string, waitSeconds ...int) (err error)
CooperateSettle : 由于CooperateSettle,close,settle,withdraw都是异步调用,因此必须再次封装
func (*PhotonNode) Deposit ¶
func (node *PhotonNode) Deposit(partnerAddress, tokenAddress string, balance int64, waitSeconds ...int) error
Deposit :
func (*PhotonNode) FindPath ¶
func (node *PhotonNode) FindPath(target *PhotonNode, tokenAddress common.Address, amount int32) (path []pfsproxy.FindPathResponse)
FindPath :
func (*PhotonNode) ForceUnlock ¶
func (node *PhotonNode) ForceUnlock(channelIdentifier string, secret string) (err error)
ForceUnlock unlock a unlock whenever i send annoucedisposed or not
func (*PhotonNode) GenerateSecret ¶
func (node *PhotonNode) GenerateSecret() (secret, secretHash string, err error)
GenerateSecret :
func (*PhotonNode) GetChannelWith ¶
func (node *PhotonNode) GetChannelWith(partnerNode *PhotonNode, tokenAddr string) *Channel
GetChannelWith :
func (*PhotonNode) GetChannels ¶
func (node *PhotonNode) GetChannels(tokenAddr string) []*Channel
GetChannels :
func (*PhotonNode) GetReceivedTransfers ¶
func (node *PhotonNode) GetReceivedTransfers() (trs []*models.ReceivedTransfer, err error)
GetReceivedTransfers query node's received transfer
func (*PhotonNode) GetSentTransferDetail ¶
func (node *PhotonNode) GetSentTransferDetail(token, locksecrethash string) (status *models.SentTransferDetail, err error)
GetSentTransferDetail :
func (*PhotonNode) GetSentTransferDetails ¶
func (node *PhotonNode) GetSentTransferDetails() (trs []*models.SentTransferDetail, err error)
GetSentTransferDetails query node's sent transfer
func (*PhotonNode) GetUnfinishedReceivedTransfer ¶
func (node *PhotonNode) GetUnfinishedReceivedTransfer(token, locksecrethash string) (resp *photon.TransferDataResponse, err error)
GetUnfinishedReceivedTransfer query unfinished received transfers
func (*PhotonNode) IsRunning ¶
func (node *PhotonNode) IsRunning() bool
IsRunning check by api address
func (*PhotonNode) OpenChannel ¶
func (node *PhotonNode) OpenChannel(partnerAddress, tokenAddress string, balance, settleTimeout int64, waitSeconds ...int) error
OpenChannel :
func (*PhotonNode) PrepareUpdate ¶
func (node *PhotonNode) PrepareUpdate() (err error)
PrepareUpdate query token partners
func (*PhotonNode) ReStartWithoutConditionquit ¶
func (node *PhotonNode) ReStartWithoutConditionquit(env *TestEnv)
ReStartWithoutConditionquit : Restart start a photon node
func (*PhotonNode) RegisterSecret ¶
func (node *PhotonNode) RegisterSecret(secret string) (err error)
RegisterSecret register a secret to contract
func (*PhotonNode) RestartName ¶
func (node *PhotonNode) RestartName() *PhotonNode
RestartName name添加restart的链式调用
func (*PhotonNode) SendTrans ¶
func (node *PhotonNode) SendTrans(tokenAddress string, amount int32, targetAddress string, isDirect bool)
SendTrans send a transfer, should be instead of Transfer
func (*PhotonNode) SendTransWithRouteInfo ¶
func (node *PhotonNode) SendTransWithRouteInfo(target *PhotonNode, tokenAddress string, amount int32, routeInfo []pfsproxy.FindPathResponse)
SendTransWithRouteInfo send a transfer with route info from pfs
func (*PhotonNode) SendTransWithSecret ¶
func (node *PhotonNode) SendTransWithSecret(tokenAddress string, amount int32, targetAddress string, secretSeed string)
SendTransWithSecret send a transfer
func (*PhotonNode) SetConditionQuit ¶
func (node *PhotonNode) SetConditionQuit(c *params.ConditionQuit) *PhotonNode
SetConditionQuit 链式调用
func (*PhotonNode) SetFeePolicy ¶
func (node *PhotonNode) SetFeePolicy(fp *models.FeePolicy) error
SetFeePolicy :
func (*PhotonNode) SetNoNetwork ¶
func (node *PhotonNode) SetNoNetwork() *PhotonNode
SetNoNetwork 不与其他节点通信
func (*PhotonNode) Settle ¶
func (node *PhotonNode) Settle(channelIdentifier string, waitSeconds ...int) (err error)
Settle :
func (*PhotonNode) Shutdown ¶
func (node *PhotonNode) Shutdown(env *TestEnv)
Shutdown check by api address,保证退出的时候已经关闭
func (*PhotonNode) SpecifiedChannel ¶
func (node *PhotonNode) SpecifiedChannel(channelIdentifier string) (c channeltype.ChannelDataDetail, err error)
SpecifiedChannel query channel's detail
func (*PhotonNode) StartWithFeeAndPFS ¶
func (node *PhotonNode) StartWithFeeAndPFS(env *TestEnv)
StartWithFeeAndPFS :
func (*PhotonNode) SwitchNetwork ¶
func (node *PhotonNode) SwitchNetwork(tomesh string) (err error)
SwitchNetwork disable mediated transfer
func (*PhotonNode) TokenBalance ¶
func (node *PhotonNode) TokenBalance(token string) (v int, err error)
TokenBalance query this account's balance of this token
func (*PhotonNode) TokenPartners ¶
func (node *PhotonNode) TokenPartners(token string) (partners []*PartnersDataResponse, err error)
TokenPartners query token partners
func (*PhotonNode) TokenSwap ¶
func (node *PhotonNode) TokenSwap(target, locksecrethash, sendingtoken, receivingtoken, role, secret string, sendingAmount, receivingAmount int, routeInfo []pfsproxy.FindPathResponse) error
TokenSwap send a transfer
func (*PhotonNode) Tokens ¶
func (node *PhotonNode) Tokens() (tokens []string, err error)
Tokens : query registered tokens
func (*PhotonNode) Transfer ¶
func (node *PhotonNode) Transfer(tokenAddress string, amount int32, targetAddress string, isDirect bool) error
Transfer send a transfer
func (*PhotonNode) UpdateMeshNetworkNodes ¶
func (node *PhotonNode) UpdateMeshNetworkNodes(nodes ...*PhotonNode)
UpdateMeshNetworkNodes :
func (*PhotonNode) Withdraw ¶
func (node *PhotonNode) Withdraw(channelIdentifier string, withdrawAmount int32)
Withdraw :
type PhotonNodeRuntime ¶
PhotonNodeRuntime case运行过程中存储临时数据的地方
type Req ¶
type Req struct { APIName string `json:"api_name"` FullURL string `json:"url"` Method string `json:"method"` Payload string `json:"payload"` Timeout time.Duration `json:"timeout"` }
Req a photon api http request
func (*Req) InvokeWithoutErrorCode ¶
InvokeWithoutErrorCode : send a http request
type TestEnv ¶
type TestEnv struct { Conn *ethclient.Client CaseName string Main string DataDir string KeystorePath string PasswordFile string XMPPServer string EthRPCEndpoint string TokenNetwork *contracts.TokensNetwork TokenNetworkAddress string UseMatrix bool Verbosity int Debug bool Nodes []*PhotonNode Tokens []*Token Channels []*Channel Keys []*ecdsa.PrivateKey `json:"-"` UseOldToken bool PFSMain string // pfs可执行文件全路径 UseNewAccount bool MDNSServiceTag string }
TestEnv env manager for test
func NewTestEnv ¶
func NewTestEnv(configFilePath string, useMatrix bool, ethEndPoint string) (env *TestEnv, err error)
NewTestEnv default contractor
func (*TestEnv) GetNodeAddressByName ¶
GetNodeAddressByName :
func (*TestEnv) GetNodeByAddress ¶
func (env *TestEnv) GetNodeByAddress(nodeAddress string) *PhotonNode
GetNodeByAddress :
func (*TestEnv) GetPfsProxy ¶
func (env *TestEnv) GetPfsProxy(privateKey *ecdsa.PrivateKey) pfsproxy.PfsProxy
GetPfsProxy :
func (*TestEnv) GetPrivateKeyByNode ¶
func (env *TestEnv) GetPrivateKeyByNode(node *PhotonNode) (key *ecdsa.PrivateKey)
GetPrivateKeyByNode :
func (*TestEnv) GetTokenByName ¶
GetTokenByName :
func (*TestEnv) KillAllPhotonNodes ¶
func (env *TestEnv) KillAllPhotonNodes()
KillAllPhotonNodes kill all photon node
type TransferPayload ¶
type TransferPayload struct { Amount int32 `json:"amount"` IsDirect bool `json:"is_direct"` Secret string `json:"secret"` Sync bool `json:"sync"` RouteInfo []pfsproxy.FindPathResponse `json:"route_info,omitempty"` Data string `json:"data"` }
TransferPayload API http body