Documentation
¶
Index ¶
- func GenerateRelayRequest(test *TestBehavior, privKey *secp256k1.PrivKey, serviceId string, ...) *servicetypes.RelayRequest
- func GetAddressFromPrivateKey(test *TestBehavior, privKey *secp256k1.PrivKey) string
- func GetApplicationRingSignature(t *testing.T, req *servicetypes.RelayRequest, appPrivateKey *secp256k1.PrivKey) []byte
- func GetRelayResponseError(t *testing.T, res *http.Response) (errCode int32, errMsg string)
- func MarshalAndSend(test *TestBehavior, ...) (errCode int32, errorMessage string)
- func PrepareJsonRPCRequestPayload() []byte
- func WithDefaultApplication(appPrivateKey *secp256k1.PrivKey) func(*TestBehavior)
- func WithDefaultSessionSupplier(supplierKeyName string, serviceId string, appPrivateKey *secp256k1.PrivKey) func(*TestBehavior)
- func WithDefaultSupplier(supplierKeyName string, ...) func(*TestBehavior)
- func WithRelayerProxyDependenciesForBlockHeight(keyName string, blockHeight int64) func(*TestBehavior)
- func WithServicesConfigMap(servicesConfigMap map[string]*config.RelayMinerServerConfig) func(*TestBehavior)
- func WithSuccessiveSessions(supplierKeyName string, serviceId string, appPrivateKey *secp256k1.PrivKey, ...) func(*TestBehavior)
- type JSONRpcError
- type JSONRpcErrorReply
- type TestBehavior
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRelayRequest ¶
func GenerateRelayRequest( test *TestBehavior, privKey *secp256k1.PrivKey, serviceId string, blockHeight int64, payload []byte, ) *servicetypes.RelayRequest
GenerateRelayRequest generates a relay request with the provided parameters
func GetAddressFromPrivateKey ¶
func GetAddressFromPrivateKey(test *TestBehavior, privKey *secp256k1.PrivKey) string
GetAddressFromPrivateKey returns the address of the provided private key
func GetApplicationRingSignature ¶
func GetApplicationRingSignature( t *testing.T, req *servicetypes.RelayRequest, appPrivateKey *secp256k1.PrivKey, ) []byte
GetApplicationRingSignature crafts a ring signer for test purposes and uses it to sign the relay request
func GetRelayResponseError ¶
GetRelayResponseError returns the error code and message from the relay response. If the response is not an error, it returns `0, ""`.
func MarshalAndSend ¶
func MarshalAndSend( test *TestBehavior, servicesConfigMap map[string]*config.RelayMinerServerConfig, serviceEndpoint string, serviceId string, request *servicetypes.RelayRequest, ) (errCode int32, errorMessage string)
MarshalAndSend marshals the request and sends it to the provided service.
func PrepareJsonRPCRequestPayload ¶
func PrepareJsonRPCRequestPayload() []byte
PrepareJsonRPCRequestPayload prepares a hard-coded JsonRPC payload for a specific request.
func WithDefaultApplication ¶
func WithDefaultApplication(appPrivateKey *secp256k1.PrivKey) func(*TestBehavior)
WithDefaultApplication creates the default staked application actor for the test
func WithDefaultSessionSupplier ¶
func WithDefaultSessionSupplier( supplierKeyName string, serviceId string, appPrivateKey *secp256k1.PrivKey, ) func(*TestBehavior)
WithDefaultSessionSupplier adds the default staked supplier to the application's current session If the supplierKeyName is empty, the supplier will not be staked so we can test the case where the supplier is not in the application's session's supplier list.
func WithDefaultSupplier ¶
func WithDefaultSupplier( supplierKeyName string, supplierEndpoints map[string][]*sharedtypes.SupplierEndpoint, ) func(*TestBehavior)
WithDefaultSupplier creates the default staked supplier for the test
func WithRelayerProxyDependenciesForBlockHeight ¶
func WithRelayerProxyDependenciesForBlockHeight( keyName string, blockHeight int64, ) func(*TestBehavior)
WithRelayerProxyDependenciesForBlockHeight creates the dependencies for the relayer proxy from the TestBehavior.mocks so they have the right interface and can be used by the dependency injection framework. blockHeight being the block height that will be returned by the block client's LastNBlock method
func WithServicesConfigMap ¶
func WithServicesConfigMap( servicesConfigMap map[string]*config.RelayMinerServerConfig, ) func(*TestBehavior)
WithServicesConfigMap creates the services that the relayer proxy will proxy requests to. It creates an HTTP server for each service and starts listening on the provided host.
func WithSuccessiveSessions ¶
func WithSuccessiveSessions( supplierKeyName string, serviceId string, appPrivateKey *secp256k1.PrivKey, sessionsCount int, ) func(*TestBehavior)
WithSuccessiveSessions creates sessions with SessionNumber 0 through SessionCount -1 and adds all of them to the sessionMap. Each session is configured for the same serviceId and application provided.
Types ¶
type JSONRpcError ¶
JSONRpcError is the error struct for the JSON RPC response
type JSONRpcErrorReply ¶
type JSONRpcErrorReply struct { Id int32 `json:"id"` Jsonrpc string `json:"jsonrpc"` Error *JSONRpcError }
JSONRpcErrorReply is the error reply struct for the JSON RPC response
type TestBehavior ¶
type TestBehavior struct { // Deps is exported so it can be used by the dependency injection framework // from the pkg/relayer/proxy/proxy_test.go Deps depinject.Config // contains filtered or unexported fields }
TestBehavior is a struct that holds the test context and mocks for the relayer proxy tests. It is used to provide the context needed by the instrumentation functions in order to isolate specific execution paths of the subject under test.
func NewRelayerProxyTestBehavior ¶
func NewRelayerProxyTestBehavior( ctx context.Context, t *testing.T, behaviors ...func(*TestBehavior), ) *TestBehavior
NewRelayerProxyTestBehavior creates a TestBehavior with the provided set of behavior function that are used to instrument the tested subject's dependencies and isolate specific execution pathways.