Documentation ¶
Overview ¶
Package test contains testing utilities usable by all subpackages of networkserver including itself.
Index ¶
- Constants
- Variables
- func AES128KeyPtr(key types.AES128Key) *types.AES128Key
- func AppendMACCommanders(queue []*ttnpb.MACCommand, cmds ...MACCommander) []*ttnpb.MACCommand
- func CopyBytes(b []byte) []byte
- func CopyDownlinkMessage(pb *ttnpb.DownlinkMessage) *ttnpb.DownlinkMessage
- func CopyDownlinkMessages(pbs ...*ttnpb.DownlinkMessage) []*ttnpb.DownlinkMessage
- func CopyMessage(pb *ttnpb.Message) *ttnpb.Message
- func CopySessionKeys(pb *ttnpb.SessionKeys) *ttnpb.SessionKeys
- func CopyStrings(ss []string) []string
- func CopyUplinkMessages(pbs ...*ttnpb.UplinkMessage) []*ttnpb.UplinkMessage
- 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 FrequencyPlan(id string) *frequencyplans.FrequencyPlan
- func MakeABPIdentifiers(withDevEUI bool) *ttnpb.EndDeviceIdentifiers
- 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 MakeOTAAIdentifiers(devAddr *types.DevAddr) *ttnpb.EndDeviceIdentifiers
- func MakeSessionKeys(macVersion ttnpb.MACVersion, withAppSKey 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, drIdx 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, isFOpts bool, ...) []byte
- func MustEncryptUplink(key types.AES128Key, devAddr types.DevAddr, fCnt uint32, isFOpts bool, ...) []byte
- func WithDeviceDataUplinkConfig(dev *ttnpb.EndDevice, pending bool, drIdx ttnpb.DataRateIndex, chIdx uint8, ...) func(DataUplinkConfig) DataUplinkConfig
- func WithMatchedUplinkSettings(msg *ttnpb.UplinkMessage, chIdx uint8, drIdx ttnpb.DataRateIndex) *ttnpb.UplinkMessage
- type DataDownlinkConfig
- type DataUplinkConfig
- type MACCommander
- type UplinkMessageConfig
Constants ¶
View Source
const ( AppIDString = "test-app-id" DevID = "test-dev-id" )
View Source
const ( DefaultEU868JoinAcceptDelay = ttnpb.RX_DELAY_5 DefaultEU868RX1Delay = ttnpb.RX_DELAY_1 DefaultEU868RX2Frequency = 869525000 )
Variables ¶
View Source
var ( ErrTestInternal = errors.DefineInternal("test_internal", "test error") ErrTestNotFound = errors.DefineNotFound("test_not_found", "test error") FNwkSIntKey = types.AES128Key{0x42, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} NwkSEncKey = types.AES128Key{0x42, 0x42, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} SNwkSIntKey = types.AES128Key{0x42, 0x42, 0x42, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} AppSKey = types.AES128Key{0x42, 0x42, 0x42, 0x42, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} JoinEUI = types.EUI64{0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} DevEUI = types.EUI64{0x42, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} DevAddr = types.DevAddr{0x42, 0x00, 0x00, 0x00} AppID = ttnpb.ApplicationIdentifiers{ApplicationID: AppIDString} NetID = test.Must(types.NewNetID(2, []byte{1, 2, 3})).(types.NetID) )
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 GatewayAntennaIdentifiers = [...]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"}, }, }
View Source
var RxMetadata = [...]*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, }, }
Functions ¶
func AppendMACCommanders ¶
func AppendMACCommanders(queue []*ttnpb.MACCommand, cmds ...MACCommander) []*ttnpb.MACCommand
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 ¶
CopyMessage returns a deep copy of *ttnpb.Message pb.
func CopySessionKeys ¶
func CopySessionKeys(pb *ttnpb.SessionKeys) *ttnpb.SessionKeys
CopySessionKeys returns a deep copy of ttnpb.SessionKeys pb.
func CopyStrings ¶
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 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 FrequencyPlan ¶
func FrequencyPlan(id string) *frequencyplans.FrequencyPlan
func MakeABPIdentifiers ¶
func MakeABPIdentifiers(withDevEUI bool) *ttnpb.EndDeviceIdentifiers
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 MakeOTAAIdentifiers ¶
func MakeOTAAIdentifiers(devAddr *types.DevAddr) *ttnpb.EndDeviceIdentifiers
func MakeSessionKeys ¶
func MakeSessionKeys(macVersion ttnpb.MACVersion, withAppSKey bool) *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, drIdx ttnpb.DataRateIndex, freq uint64) ttnpb.TxSettings
func MustComputeUplinkCMACF ¶
func MustEncryptDownlink ¶
func MustEncryptUplink ¶
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 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.