test

package
v3.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package test contains testing utilities usable by all subpackages of networkserver including itself.

Index

Constants

View Source
const (
	DefaultEU868JoinAcceptDelay = ttnpb.RX_DELAY_5
	DefaultEU868RX1Delay        = ttnpb.RX_DELAY_1
	DefaultEU868RX2Frequency    = 869525000
)

Variables

View Source
var (
	DefaultGatewayAntennaIdentifiers = [...]ttnpb.GatewayAntennaIdentifiers{
		{
			GatewayIdentifiers: ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-0"},
			AntennaIndex:       3,
		},
		{
			GatewayIdentifiers: ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-1"},
			AntennaIndex:       1,
		},
		{
			GatewayIdentifiers: ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-2"},
		},
		{
			GatewayIdentifiers: ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-3"},
			AntennaIndex:       2,
		},
		{
			GatewayIdentifiers: ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-4"},
		},
	}

	DefaultRxMetadata = [...]*ttnpb.RxMetadata{
		{
			GatewayIdentifiers:     ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-1"},
			Snr:                    -9,
			UplinkToken:            []byte("token-gtw-1"),
			DownlinkPathConstraint: ttnpb.DOWNLINK_PATH_CONSTRAINT_NONE,
		},
		{
			GatewayIdentifiers:     ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-3"},
			Snr:                    -5.3,
			UplinkToken:            []byte("token-gtw-3"),
			DownlinkPathConstraint: ttnpb.DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER,
		},
		{
			GatewayIdentifiers:     ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-5"},
			Snr:                    12,
			UplinkToken:            []byte("token-gtw-5"),
			DownlinkPathConstraint: ttnpb.DOWNLINK_PATH_CONSTRAINT_NEVER,
		},
		{
			GatewayIdentifiers:     ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-0"},
			Snr:                    5.2,
			UplinkToken:            []byte("token-gtw-0"),
			DownlinkPathConstraint: ttnpb.DOWNLINK_PATH_CONSTRAINT_NONE,
		},
		{
			GatewayIdentifiers:     ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-2"},
			Snr:                    6.3,
			UplinkToken:            []byte("token-gtw-2"),
			DownlinkPathConstraint: ttnpb.DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER,
		},
		{
			GatewayIdentifiers:     ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-4"},
			Snr:                    -7,
			UplinkToken:            []byte("token-gtw-4"),
			DownlinkPathConstraint: ttnpb.DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER,
		},
	}

	DefaultApplicationDownlinkQueue = []*ttnpb.ApplicationDownlink{
		{
			CorrelationIds: []string{"correlation-app-down-1", "correlation-app-down-2"},
			FCnt:           0x22,
			FPort:          0x1,
			FrmPayload:     []byte("testPayload"),
			Priority:       ttnpb.TxSchedulePriority_HIGHEST,
			SessionKeyId:   []byte{0x11, 0x22, 0x33, 0x44},
		},
		{
			CorrelationIds: []string{"correlation-app-down-3", "correlation-app-down-4"},
			FCnt:           0x23,
			FPort:          0x1,
			FrmPayload:     []byte("testPayload"),
			Priority:       ttnpb.TxSchedulePriority_HIGHEST,
			SessionKeyId:   []byte{0x11, 0x22, 0x33, 0x44},
		},
	}
)
View Source
var DataUplinkCorrelationIDs = [...]string{
	"data-uplink-correlation-id-1",
	"data-uplink-correlation-id-2",
	"data-uplink-correlation-id-3",
}
View Source
var DefaultEU868Channels = [...]*ttnpb.MACParameters_Channel{
	{
		UplinkFrequency:   868100000,
		DownlinkFrequency: 868100000,
		MinDataRateIndex:  ttnpb.DATA_RATE_0,
		MaxDataRateIndex:  ttnpb.DATA_RATE_5,
		EnableUplink:      true,
	},
	{
		UplinkFrequency:   868300000,
		DownlinkFrequency: 868300000,
		MinDataRateIndex:  ttnpb.DATA_RATE_0,
		MaxDataRateIndex:  ttnpb.DATA_RATE_5,
		EnableUplink:      true,
	},
	{
		UplinkFrequency:   868500000,
		DownlinkFrequency: 868500000,
		MinDataRateIndex:  ttnpb.DATA_RATE_0,
		MaxDataRateIndex:  ttnpb.DATA_RATE_5,
		EnableUplink:      true,
	},
}
View Source
var DefaultUS915Channels = func() []*ttnpb.MACParameters_Channel {
	var chs []*ttnpb.MACParameters_Channel
	for i := 0; i < 64; i++ {
		chs = append(chs, &ttnpb.MACParameters_Channel{
			UplinkFrequency:  uint64(902300000 + 200000*i),
			MinDataRateIndex: ttnpb.DATA_RATE_0,
			MaxDataRateIndex: ttnpb.DATA_RATE_3,
			EnableUplink:     true,
		})
	}
	for i := 0; i < 8; i++ {
		chs = append(chs, &ttnpb.MACParameters_Channel{
			UplinkFrequency:  uint64(903000000 + 1600000*i),
			MinDataRateIndex: ttnpb.DATA_RATE_4,
			MaxDataRateIndex: ttnpb.DATA_RATE_4,
			EnableUplink:     true,
		})
	}
	for i := 0; i < 72; i++ {
		chs[i].DownlinkFrequency = uint64(923300000 + 600000*(i%8))
	}
	return chs
}()
View Source
var SessionKeysOptions = test.SessionKeysOptions

Functions

func AES128KeyPtr

func AES128KeyPtr(key types.AES128Key) *types.AES128Key

func AppendMACCommanders

func AppendMACCommanders(queue []*ttnpb.MACCommand, cmds ...MACCommander) []*ttnpb.MACCommand

func Band added in v3.12.0

func Band(fpID string, phyVer ttnpb.PHYVersion) band.Band

func CopyBytes

func CopyBytes(b []byte) []byte

CopyBytes returns a deep copy of []byte.

func CopyDownlinkMessage

func CopyDownlinkMessage(pb *ttnpb.DownlinkMessage) *ttnpb.DownlinkMessage

CopyDownlinkMessage returns a deep copy of ttnpb.DownlinkMessage pb.

func CopyDownlinkMessages

func CopyDownlinkMessages(pbs ...*ttnpb.DownlinkMessage) []*ttnpb.DownlinkMessage

CopyDownlinkMessages returns a deep copy of ...*ttnpb.DownlinkMessage pbs.

func CopyMessage

func CopyMessage(pb *ttnpb.Message) *ttnpb.Message

CopyMessage returns a deep copy of *ttnpb.Message pb.

func CopySession added in v3.12.0

func CopySession(pb *ttnpb.Session) *ttnpb.Session

CopySession returns a deep copy of *ttnpb.Session pb.

func CopyStrings

func CopyStrings(ss []string) []string

CopyStrings returns a deep copy of []string.

func CopyUplinkMessages

func CopyUplinkMessages(pbs ...*ttnpb.UplinkMessage) []*ttnpb.UplinkMessage

CopyUplinkMessages returns a deep copy of ...*ttnpb.UplinkMessage pbs.

func DurationPtr

func DurationPtr(v time.Duration) *time.Duration

func ForEachBand

func ForEachBand(tb testing.TB, f func(func(...string) string, *band.Band, ttnpb.PHYVersion))

func ForEachBandMACVersion

func ForEachBandMACVersion(tb testing.TB, f func(func(...string) string, *band.Band, ttnpb.PHYVersion, ttnpb.MACVersion))

func ForEachClass

func ForEachClass(tb testing.TB, f func(func(...string) string, ttnpb.Class))

func ForEachClassLoRaWANVersionPair

func ForEachClassLoRaWANVersionPair(tb testing.TB, f func(func(...string) string, ttnpb.Class, ttnpb.MACVersion, ttnpb.PHYVersion))

func ForEachClassMACVersion

func ForEachClassMACVersion(tb testing.TB, f func(func(...string) string, ttnpb.Class, ttnpb.MACVersion))

func ForEachFrequencyPlan

func ForEachFrequencyPlan(tb testing.TB, f func(func(...string) string, string, *frequencyplans.FrequencyPlan))

func ForEachFrequencyPlanLoRaWANVersionPair

func ForEachFrequencyPlanLoRaWANVersionPair(tb testing.TB, f func(func(...string) string, string, *frequencyplans.FrequencyPlan, *band.Band, ttnpb.MACVersion, ttnpb.PHYVersion))

func ForEachLoRaWANVersionPair

func ForEachLoRaWANVersionPair(tb testing.TB, f func(func(...string) string, ttnpb.MACVersion, ttnpb.PHYVersion))

func ForEachMACVersion

func ForEachMACVersion(tb testing.TB, f func(func(...string) string, ttnpb.MACVersion))

func MACStatePtr added in v3.12.0

func MACStatePtr(v ttnpb.MACState) *ttnpb.MACState
func MakeDataDownlink(conf DataDownlinkConfig) *ttnpb.DownlinkMessage
func MakeDataUplink(conf DataUplinkConfig) *ttnpb.UplinkMessage

func MakeDefaultEU868CurrentChannels

func MakeDefaultEU868CurrentChannels() []*ttnpb.MACParameters_Channel

func MakeDefaultEU868CurrentMACParameters

func MakeDefaultEU868CurrentMACParameters(phyVersion ttnpb.PHYVersion) ttnpb.MACParameters

func MakeDefaultEU868DesiredChannels

func MakeDefaultEU868DesiredChannels() []*ttnpb.MACParameters_Channel

func MakeDefaultEU868DesiredMACParameters

func MakeDefaultEU868DesiredMACParameters(phyVersion ttnpb.PHYVersion) ttnpb.MACParameters

func MakeDefaultEU868MACState

func MakeDefaultEU868MACState(class ttnpb.Class, macVersion ttnpb.MACVersion, phyVersion ttnpb.PHYVersion) *ttnpb.MACState

func MakeDefaultUS915CurrentChannels

func MakeDefaultUS915CurrentChannels() []*ttnpb.MACParameters_Channel

func MakeDefaultUS915CurrentMACParameters

func MakeDefaultUS915CurrentMACParameters(ver ttnpb.PHYVersion) ttnpb.MACParameters

func MakeDefaultUS915FSB2DesiredChannels

func MakeDefaultUS915FSB2DesiredChannels() []*ttnpb.MACParameters_Channel

func MakeDefaultUS915FSB2DesiredMACParameters

func MakeDefaultUS915FSB2DesiredMACParameters(ver ttnpb.PHYVersion) ttnpb.MACParameters

func MakeDefaultUS915FSB2MACState

func MakeDefaultUS915FSB2MACState(class ttnpb.Class, macVersion ttnpb.MACVersion, phyVersion ttnpb.PHYVersion) *ttnpb.MACState

func MakeDownlinkMACBuffer

func MakeDownlinkMACBuffer(phy *band.Band, cmds ...MACCommander) []byte

func MakeSessionKeys

func MakeSessionKeys(macVersion ttnpb.MACVersion, wrapKeys, withID bool, opts ...test.SessionKeysOption) *ttnpb.SessionKeys

func MakeTestCaseName

func MakeTestCaseName(parts ...string) string

func MakeUplinkMACBuffer

func MakeUplinkMACBuffer(phy *band.Band, cmds ...MACCommander) []byte

func MakeUplinkMessage

func MakeUplinkMessage(conf UplinkMessageConfig) *ttnpb.UplinkMessage

func MakeUplinkSettings

func MakeUplinkSettings(dr ttnpb.DataRate, drIdx ttnpb.DataRateIndex, freq uint64) ttnpb.TxSettings

func MustComputeUplinkCMACF

func MustComputeUplinkCMACF(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, b ...byte) [4]byte
func MustEncryptDownlink(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, isFOpts bool, b ...byte) []byte
func MustEncryptUplink(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, isFOpts bool, b ...byte) []byte

func SetMockClock added in v3.12.0

func SetMockClock(clock *test.MockClock) func()

func WithDeviceDataUplinkConfig

func WithDeviceDataUplinkConfig(dev *ttnpb.EndDevice, pending bool, drIdx ttnpb.DataRateIndex, chIdx uint8, fCntDelta uint32) func(DataUplinkConfig) DataUplinkConfig

func WithMatchedUplinkSettings

func WithMatchedUplinkSettings(msg *ttnpb.UplinkMessage, chIdx uint8, drIdx ttnpb.DataRateIndex) *ttnpb.UplinkMessage

Types

type DataDownlinkConfig

type DataDownlinkConfig struct {
	DecodePayload bool

	Confirmed  bool
	MACVersion ttnpb.MACVersion
	DevAddr    types.DevAddr
	FCtrl      ttnpb.FCtrl
	FCnt       uint32
	ConfFCntUp uint32
	FPort      uint8
	FRMPayload []byte
	FOpts      []byte

	Request ttnpb.TxRequest

	SessionKeys *ttnpb.SessionKeys
}

type DataUplinkConfig

type DataUplinkConfig struct {
	DecodePayload bool
	Matched       bool

	Confirmed      bool
	MACVersion     ttnpb.MACVersion
	DevAddr        types.DevAddr
	FCtrl          ttnpb.FCtrl
	FCnt           uint32
	ConfFCntDown   uint32
	FPort          uint8
	FRMPayload     []byte
	FOpts          []byte
	DataRate       ttnpb.DataRate
	DataRateIndex  ttnpb.DataRateIndex
	Frequency      uint64
	ChannelIndex   uint8
	RxMetadata     []*ttnpb.RxMetadata
	CorrelationIDs []string
	ReceivedAt     time.Time

	SessionKeys *ttnpb.SessionKeys
}

type MACCommander

type MACCommander interface {
	MACCommand() *ttnpb.MACCommand
}

type UplinkMessageConfig

type UplinkMessageConfig struct {
	RawPayload     []byte
	Payload        *ttnpb.Message
	DataRate       ttnpb.DataRate
	DataRateIndex  ttnpb.DataRateIndex
	Frequency      uint64
	ChannelIndex   uint8
	ReceivedAt     time.Time
	RxMetadata     []*ttnpb.RxMetadata
	CorrelationIDs []string
}

Directories

Path Synopsis
Package test contains testing utilities usable by all subpackages of networkserver excluding itself.
Package test contains testing utilities usable by all subpackages of networkserver excluding itself.

Jump to

Keyboard shortcuts

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