beacondbtest

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IA311 = addr.MustIAFrom(1, 0xff0000000311)
	IA330 = addr.MustIAFrom(1, 0xff0000000330)
	IA331 = addr.MustIAFrom(1, 0xff0000000331)
	IA332 = addr.MustIAFrom(1, 0xff0000000332)
	IA333 = addr.MustIAFrom(1, 0xff0000000333)
	IA334 = addr.MustIAFrom(2, 0xff0000000334)

	Info1 = []IfInfo{
		{
			IA:     IA311,
			Next:   IA330,
			Egress: 10,
		},
	}

	Info2 = []IfInfo{
		{
			IA:     IA330,
			Next:   IA331,
			Egress: 4,
		},
		{
			IA:      IA331,
			Next:    IA332,
			Ingress: 1,
			Egress:  4,
			Peers:   []PeerEntry{{IA: IA311, Ingress: 4}},
		},
	}

	Info3 = []IfInfo{
		{
			IA:     IA330,
			Next:   IA331,
			Egress: 5,
		},
		{
			IA:      IA331,
			Next:    IA332,
			Ingress: 2,
			Egress:  3,
			Peers:   []PeerEntry{{IA: IA311, Ingress: 6}},
		},
		{
			IA:      IA332,
			Next:    IA333,
			Ingress: 1,
			Egress:  7,
		},
	}

	Info4 = []IfInfo{
		{
			IA:     IA334,
			Next:   IA330,
			Egress: 10,
		},
	}
)

Functions

func AllocBeacon

func AllocBeacon(
	t *testing.T,
	ases []IfInfo,
	inIfId uint16,
	infoTS uint32,
) (beacon.Beacon, []byte)

func CheckResult

func CheckResult(t *testing.T, results []beacon.Beacon, expected beacon.Beacon)

CheckResult checks that the expected beacon is returned in results, and that it is the only returned beacon

func CheckResults

func CheckResults(t *testing.T, results []beacon.Beacon, expectedBeacons []beacon.Beacon)

CheckResults checks whether results and expectedBeacons are equivalent.

func InsertBeacon

func InsertBeacon(t *testing.T, db beacon.DB, ases []IfInfo,
	inIfId uint16, infoTS uint32, allowed beacon.Usage) beacon.Beacon

func Test

func Test(t *testing.T, db Testable)

Test should be used to test any implementation of the BeaconDB interface. An implementation of the BeaconDB interface should at least have one test method that calls this test-suite.

Types

type IfInfo

type IfInfo struct {
	IA      addr.IA
	Next    addr.IA
	Ingress common.IFIDType
	Egress  common.IFIDType
	Peers   []PeerEntry
}

type PeerEntry

type PeerEntry struct {
	IA      addr.IA
	Ingress common.IFIDType
}

type Testable

type Testable interface {
	beacon.DB
	// Prepare should reset the internal state so that the DB is empty and is
	// ready to be tested.
	Prepare(t *testing.T, ctx context.Context)
}

Testable extends the beacon db interface with methods that are needed for testing.

Jump to

Keyboard shortcuts

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