chaintester

package module
v0.0.0-...-1f6fad7 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 19 Imported by: 1

README

chaintester

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = true
View Source
var ErrAbandonRequest = errors.New("request abandoned")

ErrAbandonRequest is a special error server handler implementations can return to indicate that the request has been abandoned.

SimpleIPCServer will check for this error, and close the client connection instead of writing the response/error back to the client.

It shall only be used when the server handler implementation know that the client already abandoned the request (by checking that the passed in context is already canceled, for example).

View Source
var ServerConnectivityCheckInterval = time.Millisecond * 5

ServerConnectivityCheckInterval defines the ticker interval used by connectivity check in thrift compiled TProcessorFunc implementations.

It's defined as a variable instead of constant, so that thrift server implementations can change its value to control the behavior.

If it's changed to <=0, the feature will be disabled.

Functions

func CloseVMAPI

func CloseVMAPI()

func GetVMAPI

func GetVMAPI() *interfaces.ApplyClient

func InitVMAPI

func InitVMAPI()

func IsInApply

func IsInApply() bool

func N2S

func N2S(value uint64) string

func NewProtocol

func NewProtocol(addr string) (thrift.TProtocol, thrift.TProtocol, error)

func NewVMAPIClient

func NewVMAPIClient(addr string) (*interfaces.ApplyClient, error)

func SetApplyRequestServerAddress

func SetApplyRequestServerAddress(addr string)

func SetApplyRequestServerPort

func SetApplyRequestServerPort(port string)

func SetDebuggerServerAddress

func SetDebuggerServerAddress(addr string)

func SetDebuggerServerPort

func SetDebuggerServerPort(port string)

func SetInApply

func SetInApply(inApply bool)

func SetVMAPIServerAddress

func SetVMAPIServerAddress(addr string)

func SetVMAPIServerPort

func SetVMAPIServerPort(port string)

Types

type ActionArguments

type ActionArguments interfaces.ActionArguments

type ActionSender

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

func NewActionSender

func NewActionSender(tester *ChainTester) *ActionSender

func (*ActionSender) AddAction

func (sender *ActionSender) AddAction(account string, action string, args string, permissions string)

func (*ActionSender) AddActionEx

func (sender *ActionSender) AddActionEx(account string, action string, rawArgs []byte, permissions string)

func (*ActionSender) AddActionWithSigner

func (sender *ActionSender) AddActionWithSigner(account string, action string, jsonArgs string, signer string)

func (*ActionSender) AddActionWithSignerEx

func (sender *ActionSender) AddActionWithSignerEx(account string, action string, rawArgs []byte, signer string)

func (*ActionSender) Send

func (sender *ActionSender) Send() (*JsonValue, error)

type ApplyRequestHandler

type ApplyRequestHandler struct {
}

func NewApplyRequestHandler

func NewApplyRequestHandler() *ApplyRequestHandler

func (*ApplyRequestHandler) ApplyEnd

func (p *ApplyRequestHandler) ApplyEnd(ctx context.Context, chainTesterId int32) (_r int32, _err error)

func (*ApplyRequestHandler) ApplyRequest

func (p *ApplyRequestHandler) ApplyRequest(ctx context.Context, receiver *interfaces.Uint64, firstReceiver *interfaces.Uint64, action *interfaces.Uint64, chainTesterId int32) (_r int32, _err error)

type ApplyRequestServer

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

func GetApplyRequestServer

func GetApplyRequestServer() *ApplyRequestServer

func NewApplyRequestServer

func NewApplyRequestServer() *ApplyRequestServer

func (*ApplyRequestServer) AcceptOnce

func (server *ApplyRequestServer) AcceptOnce() (int32, error)

func (*ApplyRequestServer) Serve

func (server *ApplyRequestServer) Serve() (int32, error)

func (*ApplyRequestServer) Stop

func (server *ApplyRequestServer) Stop() error

type AssertError

type AssertError struct {
	Err error
}

func NewAssertError

func NewAssertError(err error) *AssertError

func (*AssertError) Error

func (err *AssertError) Error() string

type ChainTester

type ChainTester struct {
	interfaces.IPCChainTesterClient
	// contains filtered or unexported fields
}

func NewChainTester

func NewChainTester() *ChainTester

func (*ChainTester) Call

func (p *ChainTester) Call(ctx context.Context, method string, args, result thrift.TStruct) (thrift.ResponseMeta, error)

func (*ChainTester) CreateAccount

func (p *ChainTester) CreateAccount(creator string, account string, owner_key string, active_key string, ram_bytes int64, res ...int64) (*JsonValue, error)

func (*ChainTester) CreateKey

func (p *ChainTester) CreateKey(keyType ...string) (*JsonValue, error)

func (*ChainTester) DeployContract

func (p *ChainTester) DeployContract(account string, wasmFile string, abiFile string) (err error)

func (*ChainTester) EnableDebugContract

func (p *ChainTester) EnableDebugContract(contract string, enable bool) error

func (*ChainTester) FreeChain

func (p *ChainTester) FreeChain() (int32, error)

func (*ChainTester) GetAccount

func (p *ChainTester) GetAccount(account string) (*JsonValue, error)

func (*ChainTester) GetBalance

func (tester *ChainTester) GetBalance(account string, extras ...string) uint64

func (*ChainTester) GetInfo

func (p *ChainTester) GetInfo() (*JsonValue, error)

func (*ChainTester) GetTableRows

func (p *ChainTester) GetTableRows(_json bool, code string, scope string, table string, lower_bound string, upper_bound string, limit int64) (*JsonValue, error)

func (*ChainTester) GetTableRowsEx

func (p *ChainTester) GetTableRowsEx(_json bool, code string, scope string, table string, lower_bound string, upper_bound string, limit int64, key_type string, index_position string, encode_type string, reverse bool, show_payer bool) (*JsonValue, error)

func (*ChainTester) PackAbi

func (p *ChainTester) PackAbi(abi string) ([]byte, error)

func (*ChainTester) ProduceBlock

func (p *ChainTester) ProduceBlock(next_block_skip_time ...int64) error

func (*ChainTester) PushAction

func (p *ChainTester) PushAction(account string, action string, arguments interface{}, permissions string) (*JsonValue, error)

func (*ChainTester) PushActions

func (p *ChainTester) PushActions(actions []*interfaces.Action) (*JsonValue, error)

func (*ChainTester) SetNativeApply

func (p *ChainTester) SetNativeApply(contract string, apply func(uint64, uint64, uint64))

type DebuggerConfig

type DebuggerConfig struct {
	DebuggerServerAddress     string
	DebuggerServerPort        string
	VMAPIServerAddress        string
	VMAPIServerPort           string
	ApplyRequestServerAddress string
	ApplyRequestServerPort    string
}

func GetDebuggerConfig

func GetDebuggerConfig() *DebuggerConfig

type IPCClient

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

func GetIPCClient

func GetIPCClient() *IPCClient

func NewIPCClient

func NewIPCClient(inputProtocol, outputProtocol thrift.TProtocol) *IPCClient

IPCClient implements TClient, and uses the standard message format for Thrift. It is not safe for concurrent use.

func (*IPCClient) Call

func (p *IPCClient) Call(ctx context.Context, method string, args, result thrift.TStruct) (thrift.ResponseMeta, error)

func (*IPCClient) Recv

func (p *IPCClient) Recv(ctx context.Context, iprot thrift.TProtocol, seqId int32, method string, result thrift.TStruct) error

func (*IPCClient) Send

func (p *IPCClient) Send(ctx context.Context, oprot thrift.TProtocol, seqId int32, method string, args thrift.TStruct) error

type JsonValue

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

func NewJsonValue

func NewJsonValue(value []byte) *JsonValue

func (*JsonValue) Get

func (b *JsonValue) Get(keys ...interface{}) (interface{}, error)

return string, []JsonValue, or map[string]JsonValue

func (*JsonValue) GetString

func (b *JsonValue) GetString(keys ...interface{}) (string, error)

func (*JsonValue) GetStringValue

func (b *JsonValue) GetStringValue() (string, bool)

func (*JsonValue) GetTime

func (b *JsonValue) GetTime(keys ...interface{}) (*time.Time, error)

func (*JsonValue) GetValue

func (b *JsonValue) GetValue() interface{}

func (JsonValue) MarshalJSON

func (b JsonValue) MarshalJSON() ([]byte, error)

func (*JsonValue) SetValue

func (b *JsonValue) SetValue(value interface{}) error

func (*JsonValue) ToString

func (b *JsonValue) ToString() string

func (*JsonValue) UnmarshalJSON

func (b *JsonValue) UnmarshalJSON(data []byte) error

type SimpleIPCServer

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

* This is not a typical SimpleIPCServer as it is not blocked after accept a socket. * It is more like a TThreadedServer that can handle different connections in different goroutines. * This will work if golang user implements a conn-pool like thing in client side.

func NewSimpleIPCServer2

func NewSimpleIPCServer2(processor thrift.TProcessor, serverTransport thrift.TServerTransport) *SimpleIPCServer

func NewSimpleIPCServer4

func NewSimpleIPCServer4(processor thrift.TProcessor, serverTransport thrift.TServerTransport, transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory) *SimpleIPCServer

func NewSimpleIPCServer6

func NewSimpleIPCServer6(processor thrift.TProcessor, serverTransport thrift.TServerTransport, inputTransportFactory thrift.TTransportFactory, outputTransportFactory thrift.TTransportFactory, inputProtocolFactory thrift.TProtocolFactory, outputProtocolFactory thrift.TProtocolFactory) *SimpleIPCServer

func NewSimpleIPCServerFactory2

func NewSimpleIPCServerFactory2(processorFactory thrift.TProcessorFactory, serverTransport thrift.TServerTransport) *SimpleIPCServer

func NewSimpleIPCServerFactory4

func NewSimpleIPCServerFactory4(processorFactory thrift.TProcessorFactory, serverTransport thrift.TServerTransport, transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory) *SimpleIPCServer

func NewSimpleIPCServerFactory6

func NewSimpleIPCServerFactory6(processorFactory thrift.TProcessorFactory, serverTransport thrift.TServerTransport, inputTransportFactory thrift.TTransportFactory, outputTransportFactory thrift.TTransportFactory, inputProtocolFactory thrift.TProtocolFactory, outputProtocolFactory thrift.TProtocolFactory) *SimpleIPCServer

func (*SimpleIPCServer) AcceptLoop

func (p *SimpleIPCServer) AcceptLoop() error

func (*SimpleIPCServer) AcceptOnce

func (p *SimpleIPCServer) AcceptOnce() (int32, error)

func (*SimpleIPCServer) EndProcessRequests

func (p *SimpleIPCServer) EndProcessRequests()

func (*SimpleIPCServer) InputProtocolFactory

func (p *SimpleIPCServer) InputProtocolFactory() thrift.TProtocolFactory

func (*SimpleIPCServer) InputTransportFactory

func (p *SimpleIPCServer) InputTransportFactory() thrift.TTransportFactory

func (*SimpleIPCServer) Listen

func (p *SimpleIPCServer) Listen() error

func (*SimpleIPCServer) OutputProtocolFactory

func (p *SimpleIPCServer) OutputProtocolFactory() thrift.TProtocolFactory

func (*SimpleIPCServer) OutputTransportFactory

func (p *SimpleIPCServer) OutputTransportFactory() thrift.TTransportFactory

func (*SimpleIPCServer) ProcessRequests

func (p *SimpleIPCServer) ProcessRequests() (int32, error)

func (*SimpleIPCServer) ProcessorFactory

func (p *SimpleIPCServer) ProcessorFactory() thrift.TProcessorFactory

func (*SimpleIPCServer) Serve

func (p *SimpleIPCServer) Serve() error

func (*SimpleIPCServer) ServerTransport

func (p *SimpleIPCServer) ServerTransport() thrift.TServerTransport

func (*SimpleIPCServer) SetForwardHeaders

func (p *SimpleIPCServer) SetForwardHeaders(headers []string)

SetForwardHeaders sets the list of header keys that will be auto forwarded while using THeaderProtocol.

"forward" means that when the server is also a client to other upstream thrift servers, the context object user gets in the processor functions will have both read and write headers set, with write headers being forwarded. Users can always override the write headers by calling SetWriteHeaderList before calling thrift client functions.

func (*SimpleIPCServer) SetLogger

func (p *SimpleIPCServer) SetLogger(logger thrift.Logger)

SetLogger sets the logger used by this SimpleIPCServer.

If no logger was set before Serve is called, a default logger using standard log library will be used.

func (*SimpleIPCServer) Stop

func (p *SimpleIPCServer) Stop() error

type TransactionError

type TransactionError struct {
	Err []byte
}

func NewTransactionError

func NewTransactionError(value []byte) *TransactionError

func (*TransactionError) Error

func (t *TransactionError) Error() string

func (*TransactionError) Json

func (t *TransactionError) Json() *JsonValue

Jump to

Keyboard shortcuts

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