TheThingsNetwork / lorawan-devices

Device Repository for LoRaWAN devices
Apache License 2.0
194 stars 374 forks source link

Provide a way to test the encoder and decoder #16

Closed laurensslats closed 3 years ago

laurensslats commented 3 years ago

Summary

Provide a way to test the encoder and decoder. AFAIK the encoder and decoder are not tested when running make validate fmt

Why do we need this?

Guide people in the process

What is already there? What do you see now?

make validate fmt

What is missing? What do you want to see?

A process where people can test (and create) their encoders and decoders.

How do you propose to implement this?

Add some instructions.

Can you do this yourself and submit a Pull Request?

Probably yes, with some guidance from @johanstokking and/or @benolayinka

johanstokking commented 3 years ago

The examples of the Payload Codec Definitions are tested. Their input goes in the codec, and the output is compared with the defined output.

So, if the definition is:

https://github.com/TheThingsNetwork/lorawan-devices/blob/5a4bf9a18e340996f815e586f4ccea5e6dad970a/vendor/example/windsensor-codec.yaml#L4-L11

And if the codec is:

https://github.com/TheThingsNetwork/lorawan-devices/blob/5a4bf9a18e340996f815e586f4ccea5e6dad970a/vendor/example/windsensor.js#L4-L19

Then it works.

Try changing one of the example input and output values locally and run make validate, and you'll see it fails.


We can only test with example input and output. We cannot just test the codec script if we don't know what to test against. It is not required to define examples. We can consider making that mandatory.

Please reopen if I don't understand the issue raised.