testrelayer

package
v0.0.9-3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEmptyRelay added in v0.0.3

func NewEmptyRelay(reqHeader, resHeader *sessiontypes.SessionHeader, supplierOperatorAddr string) *servicetypes.Relay

NewEmptyRelay creates a new relay structure for the given req & res headers WITHOUT any payload or signatures.

func NewMockOneTimeMiner

func NewMockOneTimeMiner(
	ctx context.Context,
	t *testing.T,
	expectedRelaysObs relayer.RelaysObservable,
	returnedMinedRelaysObs relayer.MinedRelaysObservable,
) *mockrelayer.MockMiner

NewMockOneTimeMiner creates a new mock Miner. This mock Miner will expect a call to MinedRelays with the given context and expectedRelayObs args. When that call is made, returnedMinedRelaysObs is returned.

func NewMockOneTimeRelayerProxy

func NewMockOneTimeRelayerProxy(
	ctx context.Context,
	t *testing.T,
	returnedRelaysObs relayer.RelaysObservable,
) *mockrelayer.MockRelayerProxy

NewMockOneTimeRelayerProxy creates a new mock RelayerProxy. This mock RelayerProxy will expect a call to ServedRelays with the given context, and when that call is made, returnedRelaysObs is returned. It also expects a call to Start and Stop with the given context.

func NewMockOneTimeRelayerSessionsManager

func NewMockOneTimeRelayerSessionsManager(
	ctx context.Context,
	t *testing.T,
	expectedMinedRelaysObs relayer.MinedRelaysObservable,
) *mockrelayer.MockRelayerSessionsManager

NewMockOneTimeRelayerSessionsManager creates a new mock RelayerSessionsManager. This mock RelayerSessionsManager will expect a call to InsertRelays with the given context and expectedMinedRelaysObs args. When that call is made, returnedMinedRelaysObs is returned. It also expects a call to Start with the given context, and stop.

func NewSignedEmptyRelay added in v0.0.3

func NewSignedEmptyRelay(
	ctx context.Context,
	t *testing.T,
	supplierOperatorKeyUid, supplierOperatorAddr string,
	reqHeader, resHeader *sessiontypes.SessionHeader,
	keyRing keyring.Keyring,
	ringClient crypto.RingClient,
) *servicetypes.Relay

NewSignedEmptyRelay creates a new relay structure for the given req & res headers. It signs the relay request on behalf of application in the reqHeader. It signs the relay response on behalf of supplier provided..

func NewSignedMinedRelay added in v0.0.3

func NewSignedMinedRelay(
	t *testing.T,
	ctx context.Context,
	session *sessiontypes.Session,
	appAddr, supplierOperatorAddr, supplierOperatorKeyUid string,
	keyRing keyring.Keyring,
	ringClient crypto.RingClient,
) *relayer.MinedRelay

NewSignedMinedRelay returns a new "mined relay" with the given session data, as well as the bytes and the hash fields populated.

IT DOES populate the signature fields and should only be used in contexts where a fully signed mined relay is needed for testing purposes.

TODO_IMPROVE: It does not (yet) verify against and adhere to the actual relay mining difficulty of the service at hand.

TODO_TECHDEBT(@bryanchriswhite): Move the pre-mind relays in 'pkg/relayer/miner/relay_fixtures_test.go' to 'testutil', making any necessary adjustments the utils or docs as well.

func NewUnsignedMinedRelay added in v0.0.3

func NewUnsignedMinedRelay(
	t *testing.T,
	session *sessiontypes.Session,
	supplierOperatorAddress string,
) *relayer.MinedRelay

NewUnsignedMinedRelay returns a new mined relay with the given session data, as well as the bytes and the hash fields populated.

It DOES NOT populate the signature fields and should only be used in contexts where a partial mined relay is enough for testing purposes.

TODO_IMPROVE: It does not (yet) verify against and adhere to the actual relay mining difficulty of the service at hand.

TODO_TECHDEBT(@bryanchriswhite): Move the pre-mind relays in 'pkg/relayer/miner/relay_fixtures_test.go' to 'testutil', making any necessary adjustments the utils or docs as well.

func SignRelayRequest added in v0.0.3

func SignRelayRequest(
	ctx context.Context,
	t *testing.T,
	relay *servicetypes.Relay,
	appAddr string,
	keyRing keyring.Keyring,
	ringClient crypto.RingClient,
)

TODO_TECHDEBT(@red-0ne): Centralize this logic in the relayer package. SignRelayRequest signs the relay request (updates relay.Req.Meta.Signature) on behalf of appAddr using the clients provided.

func SignRelayResponse added in v0.0.3

func SignRelayResponse(
	_ context.Context,
	t *testing.T,
	relay *servicetypes.Relay,
	supplierOperatorKeyUid, supplierOperatorAddr string,
	keyRing keyring.Keyring,
)

TODO_TECHDEBT(@red-0ne): Centralize this logic in the relayer package. in the relayer package? SignRelayResponse signs the relay response (updates relay.Res.Meta.SupplierOperatorSignature) on behalf of supplierOperatorAddr using the clients provided.

Types

This section is empty.

Jump to

Keyboard shortcuts

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