package peer

import "bytes"

type TestIFace struct {
	out *bytes.Buffer // Toward the network.
	in  *bytes.Buffer // From the network
}

func NewTestIFace() *TestIFace {
	return &TestIFace{
		out: &bytes.Buffer{},
		in:  &bytes.Buffer{},
	}
}

func (iface *TestIFace) Write(b []byte) (int, error) {
	return iface.in.Write(b)
}

func (iface *TestIFace) Read(b []byte) (int, error) {
	return iface.out.Read(b)
}

func (iface *TestIFace) UserWrite(b []byte) (int, error) {
	return iface.out.Write(b)
}

func (iface *TestIFace) UserRead(b []byte) (int, error) {
	return iface.in.Read(b)
}
