test

package
v0.0.0-...-7bd1b19 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChannelIDOracle = &channelIDOracle{
	parameters: []types.ChannelParameters{},
	ids:        []types.ID{},
}
View Source
var ValidSignatures = &validSignatures{
	validDataSignatures:         []DataSignature{},
	validChannelStateSignatures: []ChannelStateSignature{},
}

Functions

func AddChannelStateSignature

func AddChannelStateSignature(address address.Address, sig gpwallet.Sig, channelState types.ChannelState)

func AddDataSignature

func AddDataSignature(address address.Address, sig gpwallet.Sig, msg []byte)

func GetRandomByteSlice

func GetRandomByteSlice(minLength int, maxLength int, rng *rand.Rand) []byte

GetRandomByteSlice returns a byte slice of a random length in [minLength, maxLength] filled with random values.

func MakeRandomAddress

func MakeRandomAddress(rng *rand.Rand) address.Address

func MakeRandomSignature

func MakeRandomSignature(rng *rand.Rand) gpwallet.Sig

func MakeRemoteAccount

func MakeRemoteAccount(address address.Address, remote wallet.Remote) wallet.RemoteAccount

func MakeTooFewAddressBytes

func MakeTooFewAddressBytes(rng *rand.Rand) []byte

func MakeTooFewPubKeyBytes

func MakeTooFewPubKeyBytes(rng *rand.Rand) []byte

func MakeTooLongSignature

func MakeTooLongSignature(rng *rand.Rand) gpwallet.Sig

func MakeTooManyAddressBytes

func MakeTooManyAddressBytes(rng *rand.Rand) []byte

func MakeTooManyPubKeyBytes

func MakeTooManyPubKeyBytes(rng *rand.Rand) []byte

func MakeTooShortSignature

func MakeTooShortSignature(rng *rand.Rand) gpwallet.Sig

func NewRemoteWallet

func NewRemoteWallet(remote wallet.Remote) *wallet.RemoteWallet

func VerifyChannelStateSig

func VerifyChannelStateSig(sig ChannelStateSignature) bool

func VerifyDataSig

func VerifyDataSig(sig DataSignature) bool

Types

type ChannelStateSignature

type ChannelStateSignature struct {
	Address      address.Address
	Signature    gpwallet.Sig
	ChannelState types.ChannelState
}

func (ChannelStateSignature) Equal

type DataSignature

type DataSignature struct {
	Address   address.Address
	Signature gpwallet.Sig
	Message   []byte
}

func (DataSignature) Equal

func (d DataSignature) Equal(other DataSignature) bool

type GenericRemote

type GenericRemote struct {
	AvailableAddresses []address.Address
	// contains filtered or unexported fields
}

GenericRemote is a mock remote that suits the generic go-perun wallet tests. Signatures are generated randomly and all valid signature t-tuples are collected globally in ValidSignatures. This means that GenericRemote verifies a signature as valid, iff it has been signed by ANY Generic remote before. GenericRemote uses the ChannelIDOracle to come up with a random channel id that is then fixed to that ChannelParameters.

func NewGenericRemote

func NewGenericRemote(availableAddresses []address.Address, rng *rand.Rand) *GenericRemote

NewGenericRemote returns a new generic remote instance. Every GenericRemote instance needs to receive an exclusive rand.Rand instance for concurrent safety!

func (*GenericRemote) CallEndpoint

func (g *GenericRemote) CallEndpoint(endpoint string, request interface{}, response interface{}) error

func (*GenericRemote) SetCallEndpoint

func (g *GenericRemote) SetCallEndpoint(f func(string, interface{}, interface{}) error)

type MockRemote

type MockRemote struct {
	MockAddress         address.Address
	MockPubKeyBytes     [address.PubKeyLength]byte
	MockPubKeyHashBytes [address.PubKeyHashLength]byte
	// UnavailableAddress is a valid wallet.PubKey that has associated account (private key) in this remote wallet.
	UnavailableAddress address.Address
	// InvalidPubKeyBytes is invalid because it is not exactly wallet.PubKeyLength bytes long.
	InvalidPubKeyBytes []byte

	MockSignature       []byte
	MockSignatureString string
	// OtherSignature is a correctly encoded signature that is not valid for any (message, public key) pair.
	OtherSignature       []byte
	OtherSignatureString string

	// InvalidSignatureLonger is a signature that has a length longer than wallet.SignatureLength.
	InvalidSignatureLonger []byte
	// InvalidSignatureShorter is a signature that has a length shorter than wallet.SignatureLength.
	InvalidSignatureShorter []byte

	MockMessage       []byte
	MockMessageString string

	MockChannelState types.ChannelState
	// contains filtered or unexported fields
}

MockRemote should only be instantiated using NewMockRemote. The default implementation has one valid signature tuple: (MockMessage, MockSignature, MockAddress).

func NewMockRemote

func NewMockRemote(rng *rand.Rand) *MockRemote

func (*MockRemote) CallEndpoint

func (m *MockRemote) CallEndpoint(endpoint string, request interface{}, response interface{}) error

func (*MockRemote) SetCallEndpoint

func (m *MockRemote) SetCallEndpoint(f func(string, interface{}, interface{}) error)

type OtherAddressImpl

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

func NewOtherAddressImpl

func NewOtherAddressImpl(t *testing.T) *OtherAddressImpl

func (*OtherAddressImpl) Equal

func (n *OtherAddressImpl) Equal(address pw.Address) bool

func (*OtherAddressImpl) MarshalBinary

func (n *OtherAddressImpl) MarshalBinary() (data []byte, err error)

func (*OtherAddressImpl) String

func (n *OtherAddressImpl) String() string

func (*OtherAddressImpl) UnmarshalBinary

func (n *OtherAddressImpl) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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