Documentation ¶
Overview ¶
Package test contains testing utilities usable by all subpackages of networkserver including itself.
Index ¶
- Constants
- Variables
- func AppendMACCommanders(queue []*ttnpb.MACCommand, cmds ...MACCommander) []*ttnpb.MACCommand
- func Band(fpID string, phyVer ttnpb.PHYVersion) band.Band
- func CopyBytes(b []byte) []byte
- func CopyStrings(ss []string) []string
- func DurationPtr(v time.Duration) *time.Duration
- func ForEachBand(tb testing.TB, f func(func(...string) string, *band.Band, ttnpb.PHYVersion))
- func ForEachBandMACVersion(tb testing.TB, ...)
- func ForEachClass(tb testing.TB, f func(func(...string) string, ttnpb.Class))
- func ForEachClassLoRaWANVersionPair(tb testing.TB, ...)
- func ForEachClassMACVersion(tb testing.TB, f func(func(...string) string, ttnpb.Class, ttnpb.MACVersion))
- func ForEachFrequencyPlan(tb testing.TB, ...)
- func ForEachFrequencyPlanLoRaWANVersionPair(tb testing.TB, ...)
- func ForEachLoRaWANVersionPair(tb testing.TB, ...)
- func ForEachMACVersion(tb testing.TB, f func(func(...string) string, ttnpb.MACVersion))
- func MakeDataDownlink(conf *DataDownlinkConfig) *ttnpb.DownlinkMessage
- func MakeDataUplink(conf DataUplinkConfig) *ttnpb.UplinkMessage
- func MakeDefaultEU868CurrentChannels() []*ttnpb.MACParameters_Channel
- func MakeDefaultEU868CurrentMACParameters(phyVersion ttnpb.PHYVersion) *ttnpb.MACParameters
- func MakeDefaultEU868DesiredChannels() []*ttnpb.MACParameters_Channel
- func MakeDefaultEU868DesiredMACParameters(phyVersion ttnpb.PHYVersion) *ttnpb.MACParameters
- func MakeDefaultEU868MACState(class ttnpb.Class, macVersion ttnpb.MACVersion, phyVersion ttnpb.PHYVersion) *ttnpb.MACState
- func MakeDefaultUS915CurrentChannels() []*ttnpb.MACParameters_Channel
- func MakeDefaultUS915CurrentMACParameters(ver ttnpb.PHYVersion) *ttnpb.MACParameters
- func MakeDefaultUS915FSB2DesiredChannels() []*ttnpb.MACParameters_Channel
- func MakeDefaultUS915FSB2DesiredMACParameters(ver ttnpb.PHYVersion) *ttnpb.MACParameters
- func MakeDefaultUS915FSB2MACState(class ttnpb.Class, macVersion ttnpb.MACVersion, phyVersion ttnpb.PHYVersion) *ttnpb.MACState
- func MakeDownlinkMACBuffer(phy *band.Band, cmds ...MACCommander) []byte
- func MakeSessionKeys(macVersion ttnpb.MACVersion, wrapKeys, withID bool, ...) *ttnpb.SessionKeys
- func MakeTestCaseName(parts ...string) string
- func MakeUplinkMACBuffer(phy *band.Band, cmds ...MACCommander) []byte
- func MakeUplinkMessage(conf UplinkMessageConfig) *ttnpb.UplinkMessage
- func MakeUplinkSettings(dr *ttnpb.DataRate, _ ttnpb.DataRateIndex, freq uint64) *ttnpb.TxSettings
- func MustComputeUplinkCMACF(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, b ...byte) [4]byte
- func MustEncryptDownlink(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, ...) []byte
- func MustEncryptUplink(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, ...) []byte
- func SetMockClock(clock *test.MockClock) func()
- func WithDeviceDataUplinkConfig(dev *ttnpb.EndDevice, pending bool, drIdx ttnpb.DataRateIndex, chIdx uint8, ...) func(DataUplinkConfig) DataUplinkConfig
- type DataDownlinkConfig
- type DataUplinkConfig
- type MACCommander
- type UplinkMessageConfig
Constants ¶
View Source
const ( DefaultEU868JoinAcceptDelay = ttnpb.RxDelay_RX_DELAY_5 DefaultEU868RX1Delay = ttnpb.RxDelay_RX_DELAY_1 DefaultEU868RX2Frequency = 869525000 )
Variables ¶
View Source
var ( DefaultClassBCGatewayIdentifiers = [...]*ttnpb.ClassBCGatewayIdentifiers{ { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-0"}, AntennaIndex: 3, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-1"}, AntennaIndex: 1, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-2"}, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-3"}, AntennaIndex: 2, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-4"}, }, } DefaultTxSettings = &ttnpb.TxSettings{ DataRate: &ttnpb.DataRate{ Modulation: &ttnpb.DataRate_Lora{ Lora: &ttnpb.LoRaDataRate{ Bandwidth: 125000, SpreadingFactor: 7, CodingRate: band.Cr4_5, }, }, }, } DefaultRxMetadata = [...]*ttnpb.RxMetadata{ { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-1"}, Snr: -9, ChannelRssi: -99, UplinkToken: []byte("token-gtw-1"), DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_NONE, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-3"}, Snr: -5.3, ChannelRssi: -95.3, UplinkToken: []byte("token-gtw-3"), DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-5"}, Snr: 12, ChannelRssi: -22, UplinkToken: []byte("token-gtw-5"), DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_NEVER, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-0"}, Snr: 5.2, ChannelRssi: -15.2, UplinkToken: []byte("token-gtw-0"), DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_NONE, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-2"}, Snr: 6.3, ChannelRssi: -16.3, UplinkToken: []byte("token-gtw-2"), DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: "gateway-test-4"}, Snr: -7, ChannelRssi: -17, UplinkToken: []byte("token-gtw-4"), DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_PREFER_OTHER, }, } PacketBrokerRxMetadata = [...]*ttnpb.RxMetadata{ { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: cluster.PacketBrokerGatewayID.GatewayId}, Snr: 4.2, ChannelRssi: -14.2, UplinkToken: []byte("token-pb-1"), PacketBroker: &ttnpb.PacketBrokerMetadata{ ForwarderNetId: test.DefaultNetID.Bytes(), ForwarderClusterId: "test-cluster", }, DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_NEVER, }, { GatewayIds: &ttnpb.GatewayIdentifiers{GatewayId: cluster.PacketBrokerGatewayID.GatewayId}, Snr: 1.8, ChannelRssi: -21.8, UplinkToken: []byte("token-pb-2"), PacketBroker: &ttnpb.PacketBrokerMetadata{ ForwarderNetId: test.DefaultNetID.Bytes(), ForwarderClusterId: "other-cluster", }, DownlinkPathConstraint: ttnpb.DownlinkPathConstraint_DOWNLINK_PATH_CONSTRAINT_NEVER, }, } 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.DataRateIndex_DATA_RATE_0, MaxDataRateIndex: ttnpb.DataRateIndex_DATA_RATE_5, EnableUplink: true, }, { UplinkFrequency: 868300000, DownlinkFrequency: 868300000, MinDataRateIndex: ttnpb.DataRateIndex_DATA_RATE_0, MaxDataRateIndex: ttnpb.DataRateIndex_DATA_RATE_5, EnableUplink: true, }, { UplinkFrequency: 868500000, DownlinkFrequency: 868500000, MinDataRateIndex: ttnpb.DataRateIndex_DATA_RATE_0, MaxDataRateIndex: ttnpb.DataRateIndex_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.DataRateIndex_DATA_RATE_0, MaxDataRateIndex: ttnpb.DataRateIndex_DATA_RATE_3, EnableUplink: true, }) } for i := 0; i < 8; i++ { chs = append(chs, &ttnpb.MACParameters_Channel{ UplinkFrequency: uint64(903000000 + 1600000*i), MinDataRateIndex: ttnpb.DataRateIndex_DATA_RATE_4, MaxDataRateIndex: ttnpb.DataRateIndex_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 AppendMACCommanders ¶
func AppendMACCommanders(queue []*ttnpb.MACCommand, cmds ...MACCommander) []*ttnpb.MACCommand
func CopyStrings ¶
CopyStrings returns a deep copy of []string.
func ForEachBand ¶
func ForEachBandMACVersion ¶
func ForEachBandMACVersion(tb testing.TB, f func(func(...string) string, *band.Band, ttnpb.PHYVersion, ttnpb.MACVersion))
func ForEachClassLoRaWANVersionPair ¶
func ForEachClassLoRaWANVersionPair(tb testing.TB, f func(func(...string) string, ttnpb.Class, ttnpb.MACVersion, ttnpb.PHYVersion))
func ForEachClassMACVersion ¶
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 MakeDataDownlink ¶
func MakeDataDownlink(conf *DataDownlinkConfig) *ttnpb.DownlinkMessage
func MakeDataUplink ¶
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 MakeUplinkMACBuffer ¶
func MakeUplinkMACBuffer(phy *band.Band, cmds ...MACCommander) []byte
func MakeUplinkMessage ¶
func MakeUplinkMessage(conf UplinkMessageConfig) *ttnpb.UplinkMessage
func MakeUplinkSettings ¶
func MakeUplinkSettings(dr *ttnpb.DataRate, _ ttnpb.DataRateIndex, freq uint64) *ttnpb.TxSettings
MakeUplinkSettings builds the ttnpb.TxSettings for an uplink.
func MustComputeUplinkCMACF ¶
func MustEncryptDownlink ¶
func MustEncryptUplink ¶
func SetMockClock ¶ added in v3.12.0
func WithDeviceDataUplinkConfig ¶
func WithDeviceDataUplinkConfig(dev *ttnpb.EndDevice, pending bool, drIdx ttnpb.DataRateIndex, chIdx uint8, fCntDelta uint32) func(DataUplinkConfig) DataUplinkConfig
Types ¶
type DataDownlinkConfig ¶
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
}
Click to show internal directories.
Click to hide internal directories.