common

package
v0.0.0-...-a5cec35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2018 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package common is a generated GoMock package.

Package common is a generated GoMock package.

Index

Constants

View Source
const (
	// MessageIDKey is a key for message ID
	// This ID is required to track from which chat a given send transaction request is coming.
	MessageIDKey = contextKey("message_id")
)

Variables

View Source
var (
	ErrInvalidFromAddress = errors.New("Failed to parse From Address")
	ErrInvalidToAddress   = errors.New("Failed to parse To Address")
)

contains series of errors for parsing operations.

View Source
var (
	ErrDeprecatedMethod = errors.New("Method is depricated and will be removed in future release")
)

errors

View Source
var (
	ErrInvalidAccountAddressOrKey = errors.New("cannot parse address or key to valid account address")
)

errors

Functions

func Fatalf

func Fatalf(reason interface{}, args ...interface{})

Fatalf is used to halt the execution. When called the function prints stack end exits. Failure is logged into both StdErr and StdOut.

func FromAddress

func FromAddress(accountAddress string) common.Address

FromAddress converts account address from string to common.Address. The function is useful to format "From" field of send transaction struct.

func ImportTestAccount

func ImportTestAccount(keystoreDir, accountFile string) error

ImportTestAccount imports keystore from static resources, see "static/keys" folder

func MessageIDFromContext

func MessageIDFromContext(ctx context.Context) string

MessageIDFromContext returns message id from context (if exists)

func PanicAfter

func PanicAfter(waitSeconds time.Duration, abort chan struct{}, desc string)

PanicAfter throws panic() after waitSeconds, unless abort channel receives notification

func ParseAccountString

func ParseAccountString(account string) (accounts.Account, error)

ParseAccountString parses hex encoded string and returns is as accounts.Account.

func ParseJSONArray

func ParseJSONArray(items string) ([]string, error)

ParseJSONArray parses JSON array into Go array of string

func ToAddress

func ToAddress(accountAddress string) *common.Address

ToAddress converts account address from string to *common.Address. The function is useful to format "To" field of send transaction struct.

Types

type APIDetailedResponse

type APIDetailedResponse struct {
	Status      bool            `json:"status"`
	Message     string          `json:"message,omitempty"`
	FieldErrors []APIFieldError `json:"field_errors,omitempty"`
}

APIDetailedResponse represents a generic response with possible errors.

func (APIDetailedResponse) Error

func (r APIDetailedResponse) Error() string

type APIError

type APIError struct {
	Message string `json:"message"`
}

APIError represents a single error.

func (APIError) Error

func (e APIError) Error() string

type APIFieldError

type APIFieldError struct {
	Parameter string     `json:"parameter,omitempty"`
	Errors    []APIError `json:"errors"`
}

APIFieldError represents a set of errors related to a parameter.

func (APIFieldError) Error

func (e APIFieldError) Error() string

type APIResponse

type APIResponse struct {
	Error string `json:"error"`
}

APIResponse generic response from API

type AccountInfo

type AccountInfo struct {
	Address  string `json:"address"`
	PubKey   string `json:"pubkey"`
	Mnemonic string `json:"mnemonic"`
	Error    string `json:"error"`
}

AccountInfo represents account's info

type AccountManager

type AccountManager interface {
	// CreateAccount creates an internal geth account
	// BIP44-compatible keys are generated: CKD#1 is stored as account key, CKD#2 stored as sub-account root
	// Public key of CKD#1 is returned, with CKD#2 securely encoded into account key file (to be used for
	// sub-account derivations)
	CreateAccount(password string) (address, pubKey, mnemonic string, err error)

	// CreateChildAccount creates sub-account for an account identified by parent address.
	// CKD#2 is used as root for master accounts (when parentAddress is "").
	// Otherwise (when parentAddress != ""), child is derived directly from parent.
	CreateChildAccount(parentAddress, password string) (address, pubKey string, err error)

	// RecoverAccount re-creates master key using given details.
	// Once master key is re-generated, it is inserted into keystore (if not already there).
	RecoverAccount(password, mnemonic string) (address, pubKey string, err error)

	// VerifyAccountPassword tries to decrypt a given account key file, with a provided password.
	// If no error is returned, then account is considered verified.
	VerifyAccountPassword(keyStoreDir, address, password string) (*keystore.Key, error)

	// SelectAccount selects current account, by verifying that address has corresponding account which can be decrypted
	// using provided password. Once verification is done, decrypted key is injected into Whisper (as a single identity,
	// all previous identities are removed).
	SelectAccount(address, password string) error

	// ReSelectAccount selects previously selected account, often, after node restart.
	ReSelectAccount() error

	// SelectedAccount returns currently selected account
	SelectedAccount() (*SelectedExtKey, error)

	// Logout clears whisper identities
	Logout() error

	// Accounts returns handler to process account list request
	Accounts() ([]common.Address, error)

	// AccountsRPCHandler returns RPC wrapper for Accounts()
	AccountsRPCHandler() rpc.Handler

	// AddressToDecryptedAccount tries to load decrypted key for a given account.
	// The running node, has a keystore directory which is loaded on start. Key file
	// for a given address is expected to be in that directory prior to node start.
	AddressToDecryptedAccount(address, password string) (accounts.Account, *keystore.Key, error)
}

AccountManager defines expected methods for managing Status accounts

type CompleteTransactionResult

type CompleteTransactionResult struct {
	ID    string `json:"id"`
	Hash  string `json:"hash"`
	Error string `json:"error"`
}

CompleteTransactionResult is a JSON returned from transaction complete function (used in exposed method)

type CompleteTransactionsResult

type CompleteTransactionsResult struct {
	Results map[string]CompleteTransactionResult `json:"results"`
}

CompleteTransactionsResult is list of results from CompleteTransactions() (used in exposed method)

type DiscardTransactionResult

type DiscardTransactionResult struct {
	ID    string `json:"id"`
	Error string `json:"error"`
}

DiscardTransactionResult is a JSON returned from transaction discard function

type DiscardTransactionsResult

type DiscardTransactionsResult struct {
	Results map[string]DiscardTransactionResult `json:"results"`
}

DiscardTransactionsResult is a list of results from DiscardTransactions()

type MockAccountManager

type MockAccountManager struct {
	// contains filtered or unexported fields
}

MockAccountManager is a mock of AccountManager interface

func NewMockAccountManager

func NewMockAccountManager(ctrl *gomock.Controller) *MockAccountManager

NewMockAccountManager creates a new mock instance

func (*MockAccountManager) Accounts

func (m *MockAccountManager) Accounts() ([]common.Address, error)

Accounts mocks base method

func (*MockAccountManager) AccountsRPCHandler

func (m *MockAccountManager) AccountsRPCHandler() rpc.Handler

AccountsRPCHandler mocks base method

func (*MockAccountManager) AddressToDecryptedAccount

func (m *MockAccountManager) AddressToDecryptedAccount(address, password string) (accounts.Account, *keystore.Key, error)

AddressToDecryptedAccount mocks base method

func (*MockAccountManager) CreateAccount

func (m *MockAccountManager) CreateAccount(password string) (string, string, string, error)

CreateAccount mocks base method

func (*MockAccountManager) CreateChildAccount

func (m *MockAccountManager) CreateChildAccount(parentAddress, password string) (string, string, error)

CreateChildAccount mocks base method

func (*MockAccountManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockAccountManager) Logout

func (m *MockAccountManager) Logout() error

Logout mocks base method

func (*MockAccountManager) ReSelectAccount

func (m *MockAccountManager) ReSelectAccount() error

ReSelectAccount mocks base method

func (*MockAccountManager) RecoverAccount

func (m *MockAccountManager) RecoverAccount(password, mnemonic string) (string, string, error)

RecoverAccount mocks base method

func (*MockAccountManager) SelectAccount

func (m *MockAccountManager) SelectAccount(address, password string) error

SelectAccount mocks base method

func (*MockAccountManager) SelectedAccount

func (m *MockAccountManager) SelectedAccount() (*SelectedExtKey, error)

SelectedAccount mocks base method

func (*MockAccountManager) VerifyAccountPassword

func (m *MockAccountManager) VerifyAccountPassword(keyStoreDir, address, password string) (*keystore.Key, error)

VerifyAccountPassword mocks base method

type MockAccountManagerMockRecorder

type MockAccountManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockAccountManagerMockRecorder is the mock recorder for MockAccountManager

func (*MockAccountManagerMockRecorder) Accounts

func (mr *MockAccountManagerMockRecorder) Accounts() *gomock.Call

Accounts indicates an expected call of Accounts

func (*MockAccountManagerMockRecorder) AccountsRPCHandler

func (mr *MockAccountManagerMockRecorder) AccountsRPCHandler() *gomock.Call

AccountsRPCHandler indicates an expected call of AccountsRPCHandler

func (*MockAccountManagerMockRecorder) AddressToDecryptedAccount

func (mr *MockAccountManagerMockRecorder) AddressToDecryptedAccount(address, password interface{}) *gomock.Call

AddressToDecryptedAccount indicates an expected call of AddressToDecryptedAccount

func (*MockAccountManagerMockRecorder) CreateAccount

func (mr *MockAccountManagerMockRecorder) CreateAccount(password interface{}) *gomock.Call

CreateAccount indicates an expected call of CreateAccount

func (*MockAccountManagerMockRecorder) CreateChildAccount

func (mr *MockAccountManagerMockRecorder) CreateChildAccount(parentAddress, password interface{}) *gomock.Call

CreateChildAccount indicates an expected call of CreateChildAccount

func (*MockAccountManagerMockRecorder) Logout

Logout indicates an expected call of Logout

func (*MockAccountManagerMockRecorder) ReSelectAccount

func (mr *MockAccountManagerMockRecorder) ReSelectAccount() *gomock.Call

ReSelectAccount indicates an expected call of ReSelectAccount

func (*MockAccountManagerMockRecorder) RecoverAccount

func (mr *MockAccountManagerMockRecorder) RecoverAccount(password, mnemonic interface{}) *gomock.Call

RecoverAccount indicates an expected call of RecoverAccount

func (*MockAccountManagerMockRecorder) SelectAccount

func (mr *MockAccountManagerMockRecorder) SelectAccount(address, password interface{}) *gomock.Call

SelectAccount indicates an expected call of SelectAccount

func (*MockAccountManagerMockRecorder) SelectedAccount

func (mr *MockAccountManagerMockRecorder) SelectedAccount() *gomock.Call

SelectedAccount indicates an expected call of SelectedAccount

func (*MockAccountManagerMockRecorder) VerifyAccountPassword

func (mr *MockAccountManagerMockRecorder) VerifyAccountPassword(keyStoreDir, address, password interface{}) *gomock.Call

VerifyAccountPassword indicates an expected call of VerifyAccountPassword

type MockNodeManager

type MockNodeManager struct {
	// contains filtered or unexported fields
}

MockNodeManager is a mock of NodeManager interface

func NewMockNodeManager

func NewMockNodeManager(ctrl *gomock.Controller) *MockNodeManager

NewMockNodeManager creates a new mock instance

func (*MockNodeManager) AccountKeyStore

func (m *MockNodeManager) AccountKeyStore() (*keystore.KeyStore, error)

AccountKeyStore mocks base method

func (*MockNodeManager) AccountManager

func (m *MockNodeManager) AccountManager() (*accounts.Manager, error)

AccountManager mocks base method

func (*MockNodeManager) AddPeer

func (m *MockNodeManager) AddPeer(url string) error

AddPeer mocks base method

func (*MockNodeManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockNodeManager) EnsureSync

func (m *MockNodeManager) EnsureSync(ctx context.Context) error

EnsureSync mocks base method

func (*MockNodeManager) IsNodeRunning

func (m *MockNodeManager) IsNodeRunning() bool

IsNodeRunning mocks base method

func (*MockNodeManager) LightEthereumService

func (m *MockNodeManager) LightEthereumService() (*les.LightEthereum, error)

LightEthereumService mocks base method

func (*MockNodeManager) Node

func (m *MockNodeManager) Node() (*node.Node, error)

Node mocks base method

func (*MockNodeManager) NodeConfig

func (m *MockNodeManager) NodeConfig() (*params.NodeConfig, error)

NodeConfig mocks base method

func (*MockNodeManager) PeerCount

func (m *MockNodeManager) PeerCount() int

PeerCount mocks base method

func (*MockNodeManager) PopulateStaticPeers

func (m *MockNodeManager) PopulateStaticPeers() error

PopulateStaticPeers mocks base method

func (*MockNodeManager) RPCClient

func (m *MockNodeManager) RPCClient() *rpc.Client

RPCClient mocks base method

func (*MockNodeManager) StartNode

func (m *MockNodeManager) StartNode(config *params.NodeConfig) error

StartNode mocks base method

func (*MockNodeManager) StopNode

func (m *MockNodeManager) StopNode() error

StopNode mocks base method

func (*MockNodeManager) WhisperService

func (m *MockNodeManager) WhisperService() (*whisperv6.Whisper, error)

WhisperService mocks base method

type MockNodeManagerMockRecorder

type MockNodeManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockNodeManagerMockRecorder is the mock recorder for MockNodeManager

func (*MockNodeManagerMockRecorder) AccountKeyStore

func (mr *MockNodeManagerMockRecorder) AccountKeyStore() *gomock.Call

AccountKeyStore indicates an expected call of AccountKeyStore

func (*MockNodeManagerMockRecorder) AccountManager

func (mr *MockNodeManagerMockRecorder) AccountManager() *gomock.Call

AccountManager indicates an expected call of AccountManager

func (*MockNodeManagerMockRecorder) AddPeer

func (mr *MockNodeManagerMockRecorder) AddPeer(url interface{}) *gomock.Call

AddPeer indicates an expected call of AddPeer

func (*MockNodeManagerMockRecorder) EnsureSync

func (mr *MockNodeManagerMockRecorder) EnsureSync(ctx interface{}) *gomock.Call

EnsureSync indicates an expected call of EnsureSync

func (*MockNodeManagerMockRecorder) IsNodeRunning

func (mr *MockNodeManagerMockRecorder) IsNodeRunning() *gomock.Call

IsNodeRunning indicates an expected call of IsNodeRunning

func (*MockNodeManagerMockRecorder) LightEthereumService

func (mr *MockNodeManagerMockRecorder) LightEthereumService() *gomock.Call

LightEthereumService indicates an expected call of LightEthereumService

func (*MockNodeManagerMockRecorder) Node

Node indicates an expected call of Node

func (*MockNodeManagerMockRecorder) NodeConfig

func (mr *MockNodeManagerMockRecorder) NodeConfig() *gomock.Call

NodeConfig indicates an expected call of NodeConfig

func (*MockNodeManagerMockRecorder) PeerCount

func (mr *MockNodeManagerMockRecorder) PeerCount() *gomock.Call

PeerCount indicates an expected call of PeerCount

func (*MockNodeManagerMockRecorder) PopulateStaticPeers

func (mr *MockNodeManagerMockRecorder) PopulateStaticPeers() *gomock.Call

PopulateStaticPeers indicates an expected call of PopulateStaticPeers

func (*MockNodeManagerMockRecorder) RPCClient

func (mr *MockNodeManagerMockRecorder) RPCClient() *gomock.Call

RPCClient indicates an expected call of RPCClient

func (*MockNodeManagerMockRecorder) StartNode

func (mr *MockNodeManagerMockRecorder) StartNode(config interface{}) *gomock.Call

StartNode indicates an expected call of StartNode

func (*MockNodeManagerMockRecorder) StopNode

func (mr *MockNodeManagerMockRecorder) StopNode() *gomock.Call

StopNode indicates an expected call of StopNode

func (*MockNodeManagerMockRecorder) WhisperService

func (mr *MockNodeManagerMockRecorder) WhisperService() *gomock.Call

WhisperService indicates an expected call of WhisperService

type MockNotifier

type MockNotifier struct {
	// contains filtered or unexported fields
}

MockNotifier is a mock of Notifier interface

func NewMockNotifier

func NewMockNotifier(ctrl *gomock.Controller) *MockNotifier

NewMockNotifier creates a new mock instance

func (*MockNotifier) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockNotifier) Send

func (m *MockNotifier) Send(body string, payload go_fcm.NotificationPayload, tokens ...string) error

Send mocks base method

type MockNotifierMockRecorder

type MockNotifierMockRecorder struct {
	// contains filtered or unexported fields
}

MockNotifierMockRecorder is the mock recorder for MockNotifier

func (*MockNotifierMockRecorder) Send

func (mr *MockNotifierMockRecorder) Send(body, payload interface{}, tokens ...interface{}) *gomock.Call

Send indicates an expected call of Send

type NodeManager

type NodeManager interface {
	// StartNode start Status node, fails if node is already started
	StartNode(config *params.NodeConfig) error

	// EnsureSync waits until blockchain is synchronized.
	EnsureSync(ctx context.Context) error

	// StopNode stop the running Status node.
	// Stopped node cannot be resumed, one starts a new node instead.
	StopNode() error

	// IsNodeRunning confirm that node is running
	IsNodeRunning() bool

	// NodeConfig returns reference to running node's configuration
	NodeConfig() (*params.NodeConfig, error)

	// Node returns underlying Status node
	Node() (*node.Node, error)

	// PopulateStaticPeers populates node's list of static bootstrap peers
	PopulateStaticPeers() error

	// AddPeer adds URL of static peer
	AddPeer(url string) error

	// PeerCount returns number of connected peers
	PeerCount() int

	// LightEthereumService exposes reference to LES service running on top of the node
	LightEthereumService() (*les.LightEthereum, error)

	// WhisperService returns reference to running Whisper service
	WhisperService() (*whisper.Whisper, error)

	// AccountManager returns reference to node's account manager
	AccountManager() (*accounts.Manager, error)

	// AccountKeyStore returns reference to account manager's keystore
	AccountKeyStore() (*keystore.KeyStore, error)

	// RPCClient exposes reference to RPC client connected to the running node
	RPCClient() *rpc.Client
}

NodeManager defines expected methods for managing Status node

type NotificationConstructor

type NotificationConstructor func() Notifier

NotificationConstructor returns constructor of configured instance Notifier interface.

type Notifier

type Notifier interface {
	Send(body string, payload fcm.NotificationPayload, tokens ...string) error
}

Notifier manages Push Notifications.

type NotifyResult

type NotifyResult struct {
	Status bool   `json:"status"`
	Error  string `json:"error,omitempty"`
}

NotifyResult is a JSON returned from notify message

type QueuedTx

type QueuedTx struct {
	ID      QueuedTxID
	Context context.Context
	Args    SendTxArgs
	Result  chan TransactionResult
}

QueuedTx holds enough information to complete the queued transaction.

func CreateTransaction

func CreateTransaction(ctx context.Context, args SendTxArgs) *QueuedTx

CreateTransaction returns a transaction object.

type QueuedTxID

type QueuedTxID string

QueuedTxID queued transaction identifier

type RPCCall

type RPCCall struct {
	ID     int64
	Method string
	Params []interface{}
}

RPCCall represents a unit of a rpc request which is to be executed.

func (RPCCall) ParseData

func (r RPCCall) ParseData() hexutil.Bytes

ParseData returns the bytes associated with the call.

func (RPCCall) ParseFromAddress

func (r RPCCall) ParseFromAddress() (gethcommon.Address, error)

ParseFromAddress returns the address associated with the RPCCall.

func (RPCCall) ParseGas

func (r RPCCall) ParseGas() *hexutil.Uint64

ParseGas returns the hex big associated with the call. nolint: dupl

func (RPCCall) ParseGasPrice

func (r RPCCall) ParseGasPrice() *hexutil.Big

ParseGasPrice returns the hex big associated with the call. nolint: dupl

func (RPCCall) ParseToAddress

func (r RPCCall) ParseToAddress() (gethcommon.Address, error)

ParseToAddress returns the gethcommon.Address associated with the call.

func (RPCCall) ParseValue

func (r RPCCall) ParseValue() *hexutil.Big

ParseValue returns the hex big associated with the call. nolint: dupl

func (RPCCall) ToSendTxArgs

func (r RPCCall) ToSendTxArgs() SendTxArgs

ToSendTxArgs converts RPCCall to SendTxArgs.

type RawDiscardTransactionResult

type RawDiscardTransactionResult struct {
	Error error
}

RawDiscardTransactionResult is list of results from CompleteTransactions() (used internally)

type SelectedExtKey

type SelectedExtKey struct {
	Address     common.Address
	AccountKey  *keystore.Key
	SubAccounts []accounts.Account
}

SelectedExtKey is a container for currently selected (logged in) account

func (*SelectedExtKey) Hex

func (k *SelectedExtKey) Hex() string

Hex dumps address of a given extended key as hex string

type SendTxArgs

type SendTxArgs struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	Input    hexutil.Bytes   `json:"input"`
}

SendTxArgs represents the arguments to submit a new transaction into the transaction pool. This struct is based on go-ethereum's type in internal/ethapi/api.go, but we have freedom over the exact layout of this struct.

type StopRPCCallError

type StopRPCCallError struct {
	Err error
}

StopRPCCallError defines a error type specific for killing a execution process.

func (StopRPCCallError) Error

func (c StopRPCCallError) Error() string

Error returns the internal error associated with the critical error.

type TestConfig

type TestConfig struct {
	Node struct {
		SyncSeconds time.Duration
		HTTPPort    int
		WSPort      int
	}
	Account1 account
	Account2 account
	Account3 account
}

TestConfig contains shared (among different test packages) parameters

func LoadTestConfig

func LoadTestConfig(networkID int) (*TestConfig, error)

LoadTestConfig loads test configuration values from disk

type TransactionResult

type TransactionResult struct {
	Hash  common.Hash
	Error error
}

TransactionResult is a JSON returned from transaction complete function (used internally)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL