altintx / chromadex

chromadex
12 stars 4 forks source link

Write unit tests for this and python version #1

Open bewest opened 10 years ago

bewest commented 10 years ago

Would be nice to get some unit tests to share between this and https://github.com/compbrain/dexcom_reader

The python version might be easier to digest.

Also see: https://github.com/alexandre-normand/blood-shepherd and https://github.com/alexandre-normand/bloodSheltie

HTH!!!!

I hope to help out with this, I have a similar (very broken because of async flow control) experiment with Asante Pump, and also have a decent version of the MM Carelink driver. Likewise, I had discovered the Chrome APIs as well as lots of advice from all over to just stuff logic like this into an "authorized" WebView and share the code across as many platforms as possible.

I think this kind of project is the right way to go, due to flexibility, etc.

altintx commented 10 years ago

Python version is a big help, thanks!

I don't see unit tests in there. Are you hoping we can dev for same API so future tests can be shared?

altintx commented 10 years ago

Feel like my "dexcom" interface is pretty stable at this point. Still have a bug resulting in completely wrong #cgmthen and completely wrong dates occurring, which may necessitate API changes. But I don't think so. @atsjj started to work on some unit testing stuff but it hasn't landed yet. In a bigger picture sense, any idea how we could go about covering both our apps with similarish tests?

atsjj commented 10 years ago

The unit testing framework is in place, thanks to the work and inspiration from stefanpenner/ember-cli.

One of the issues I'm working through right now is the best way to mock the Chrome API that is at the heart of the driver. It makes testing difficult and without mocking it, we can't have Travis doing CI.

As far as the project goes, there is a failing unit test as an example. There is a test loader that will automatically require all -test.js modules written. It's QUnit, so it runs in the browser.

altintx commented 10 years ago

The chrome.serial stuff?

I can capture that input and output for you if it'd help? I guess the input is already there via the Uint8Arrays. Replacing dexcom.readSerial with known values seems like the easiest option to me. Assuming that's what you're talking about?

atsjj commented 10 years ago

The I/O may be useful, but it's more about mocking the methods used to acquire a serial connection via the Chrome APIs. Ideally, those should be mocked so a non-Chrome test environment can be used application as a whole.

altintx commented 10 years ago

Valid serial response for getEGVDataPageRange 0x010e0001c7000000ad010000a593

Valid serial response for getLastFourPages 0x014608013c3f0000260000000402aa0100000000000000000000000000004c9465254f0a6c5d4f0a500014ca0591264f0a985e4f0a520014a499bd274f0ac45f4f0a5300143e65e9284f0af0604f0a5400147484152a4f0a1c624f0a5700149703412b4f0a48634f0a5900148d596d2c4f0a74644f0a56001452f3992d4f0aa0654f0a53001490d1c52e4f0acc664f0a4f0014ed9bf12f4f0af8674f0a4b0014835b1d314f0a24694f0a490014eb9f49324f0a506a4f0a480014fcd275334f0a7c6b4f0a4e0014aa7aa1344f0aa86c4f0a5300148ee6cd354f0ad46d4f0a560014f7ecf9364f0a006f4f0a590014e1d425384f0a2c704f0a5c0014748e51394f0a58714f0a5f0014b3527d3a4f0a84724f0a6100148eb9a93b4f0ab0734f0a60001415f5d53c4f0adc744f0a5d0014700f013e4f0a08764f0a5f0014777d2d3f4f0a34774f0a620014338259404f0a60784f0a5e001440bf85414f0a8c794f0a610014325db1424f0ab87a4f0a6000146623dd434f0ae47b4f0a5800141dc009454f0a107d4f0a590014282e35464f0a3c7e4f0a5b0014740f61474f0a687f4f0a5c0014ffcb8d484f0a94804f0a5e0014ae4eb9494f0ac0814f0a5f00142ad6e54a4f0aec824f0a6000142d9e114c4f0a18844f0a61001462da3d4d4f0a44854f0a64001438fa694e4f0a70864f0a63001463d8954f4f0a9c874f0a6400146ffcc1504f0ac8884f0a65001485a7ffffffffffff623f0000260000000402ab010000000000000000000000000000f33ced514f0af4894f0a65001435df19534f0a208b4f0a650014286945544f0a4c8c4f0a66001493e771554f0a788d4f0a6400145d959d564f0aa48e4f0a660014db03c9574f0ad08f4f0a6500146675f5584f0afc904f0a67001423a2215a4f0a28924f0a6d001485794d5b4f0a54934f0a6d00140c98795c4f0a80944f0a6b0014bfd0a55d4f0aac954f0a6b00144cadd15e4f0ad8964f0a6a0014214afd5f4f0a04984f0a6a001471ef29614f0a30994f0a690014a03655624f0a5c9a4f0a690014a5e081634f0a889b4f0a6a0014bddaad644f0ab49c4f0a6c0014f3eed9654f0ae09d4f0a6a001432b705674f0a0c9f4f0a670014aa8131684f0a38a04f0a660014ef3c5d694f0a64a14f0a650014c0ea896a4f0a90a24f0a6300141400b56b4f0abca34f0a6100148274e16c4f0ae8a44f0a600014f7fc0d6e4f0a14a64f0a5f001496a9396f4f0a40a74f0a5e0014123165704f0a6ca84f0a6100141e0191714f0a98a94f0a610014daa6bd724f0ac4aa4f0a5b0014de3ae9734f0af0ab4f0a5b0014dfc814754f0a1bad4f0a5e0014059740764f0a47ae4f0a6300148d976c774f0a73af4f0a5f001454cc98784f0a9fb04f0a5c0014c535c4794f0acbb14f0a5e001430b8f17a4f0af8b24f0a5f001469071c7c4f0a23b44f0a6000146756487d4f0a4fb54f0a6000145cddffffffffffff883f0000260000000402ac0100000000000000000000000000006c66747e4f0a7bb64f0a5f001422dfa07f4f0aa7b74f0a5e0014f718cc804f0ad3b84f0a5d001461b1f8814f0affb94f0a5c0014293e24834f0a2bbb4f0a5b0014500550844f0a57bc4f0a5a001404da7c854f0a83bd4f0a5b0014ca1ea8864f0aafbe4f0a5700141ce1d4874f0adbbf4f0a57001405c600894f0a07c14f0a570014cee02c8a4f0a33c24f0a5500147930588b4f0a5fc34f0a5500143811848c4f0a8bc44f0a530014009cb08d4f0ab7c54f0a5200143324dc8e4f0ae3c64f0a5300141b5a08904f0a0fc84f0a4c0014059b34914f0a3bc94f0a4c0014252561924f0a68ca4f0a51009443608c934f0a93cb4f0a51009494628c934f0a93cb4f0a508014b4dfb8944f0abfcc4f0a4d00143883e4954f0aebcd4f0a4a00143de510974f0a17cf4f0a4900142bf73c984f0a43d04f0a4a0014af5568994f0a6fd14f0a4600141976949a4f0a9bd24f0a43001469cdc09b4f0ac7d34f0a430014df1fec9c4f0af3d44f0a4400140c8f189e4f0a1fd64f0a430014a176449f4f0a4bd74f0a430014349570a04f0a77d84f0a4400146b8b9ca14f0aa3d94f0a450014da82c8a24f0acfda4f0a4700144b32f4a34f0afbdb4f0a4a00143ace20a54f0a27dd4f0a4c0014c4584ca64f0a53de4f0a500014284978a74f0a7fdf4f0a540014902da4a84f0aabe04f0a550014bd4dffffffffffffae3f00000f0000000402ad0100000000000000000000000000000f80d0a94f0ad7e14f0a550014875bfcaa4f0a03e34f0a540014238f28ac4f0a2fe44f0a520014e57354ad4f0a5be54f0a5000149c3a80ae4f0a87e64f0a500014b39facaf4f0ab3e74f0a530014fe2dd8b04f0adfe84f0a5800148fd104b24f0a0bea4f0a5c0014a6b330b34f0a37eb4f0a5c0014a53c5cb44f0a63ec4f0a5c001429de88b54f0a8fed4f0a5b0014d1f2b4b64f0abbee4f0a5900145b77e0b74f0ae7ef4f0a560014dc890cb94f0a13f14f0a5300146dbb38ba4f0a3ff24f0a530014df56fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff347

As far as I know, valid responses always start with 01 and the final 2 bytes are always some kind of checksum based around calculateCRC16. What I don't know is what portion of the packet should be checksumed to confirm validity.

altintx commented 10 years ago

getEGVDataPageRange seems to come up with same response every time.

Another valid getLastFourPages response 0x014608013c3f0000260000000402aa0100000000000000000000000000004c9465254f0a6c5d4f0a500014ca0591264f0a985e4f0a520014a499bd274f0ac45f4f0a5300143e65e9284f0af0604f0a5400147484152a4f0a1c624f0a5700149703412b4f0a48634f0a5900148d596d2c4f0a74644f0a56001452f3992d4f0aa0654f0a53001490d1c52e4f0acc664f0a4f0014ed9bf12f4f0af8674f0a4b0014835b1d314f0a24694f0a490014eb9f49324f0a506a4f0a480014fcd275334f0a7c6b4f0a4e0014aa7aa1344f0aa86c4f0a5300148ee6cd354f0ad46d4f0a560014f7ecf9364f0a006f4f0a590014e1d425384f0a2c704f0a5c0014748e51394f0a58714f0a5f0014b3527d3a4f0a84724f0a6100148eb9a93b4f0ab0734f0a60001415f5d53c4f0adc744f0a5d0014700f013e4f0a08764f0a5f0014777d2d3f4f0a34774f0a620014338259404f0a60784f0a5e001440bf85414f0a8c794f0a610014325db1424f0ab87a4f0a6000146623dd434f0ae47b4f0a5800141dc009454f0a107d4f0a590014282e35464f0a3c7e4f0a5b0014740f61474f0a687f4f0a5c0014ffcb8d484f0a94804f0a5e0014ae4eb9494f0ac0814f0a5f00142ad6e54a4f0aec824f0a6000142d9e114c4f0a18844f0a61001462da3d4d4f0a44854f0a64001438fa694e4f0a70864f0a63001463d8954f4f0a9c874f0a6400146ffcc1504f0ac8884f0a65001485a7ffffffffffff623f0000260000000402ab010000000000000000000000000000f33ced514f0af4894f0a65001435df19534f0a208b4f0a650014286945544f0a4c8c4f0a66001493e771554f0a788d4f0a6400145d959d564f0aa48e4f0a660014db03c9574f0ad08f4f0a6500146675f5584f0afc904f0a67001423a2215a4f0a28924f0a6d001485794d5b4f0a54934f0a6d00140c98795c4f0a80944f0a6b0014bfd0a55d4f0aac954f0a6b00144cadd15e4f0ad8964f0a6a0014214afd5f4f0a04984f0a6a001471ef29614f0a30994f0a690014a03655624f0a5c9a4f0a690014a5e081634f0a889b4f0a6a0014bddaad644f0ab49c4f0a6c0014f3eed9654f0ae09d4f0a6a001432b705674f0a0c9f4f0a670014aa8131684f0a38a04f0a660014ef3c5d694f0a64a14f0a650014c0ea896a4f0a90a24f0a6300141400b56b4f0abca34f0a6100148274e16c4f0ae8a44f0a600014f7fc0d6e4f0a14a64f0a5f001496a9396f4f0a40a74f0a5e0014123165704f0a6ca84f0a6100141e0191714f0a98a94f0a610014daa6bd724f0ac4aa4f0a5b0014de3ae9734f0af0ab4f0a5b0014dfc814754f0a1bad4f0a5e0014059740764f0a47ae4f0a6300148d976c774f0a73af4f0a5f001454cc98784f0a9fb04f0a5c0014c535c4794f0acbb14f0a5e001430b8f17a4f0af8b24f0a5f001469071c7c4f0a23b44f0a6000146756487d4f0a4fb54f0a6000145cddffffffffffff883f0000260000000402ac0100000000000000000000000000006c66747e4f0a7bb64f0a5f001422dfa07f4f0aa7b74f0a5e0014f718cc804f0ad3b84f0a5d001461b1f8814f0affb94f0a5c0014293e24834f0a2bbb4f0a5b0014500550844f0a57bc4f0a5a001404da7c854f0a83bd4f0a5b0014ca1ea8864f0aafbe4f0a5700141ce1d4874f0adbbf4f0a57001405c600894f0a07c14f0a570014cee02c8a4f0a33c24f0a5500147930588b4f0a5fc34f0a5500143811848c4f0a8bc44f0a530014009cb08d4f0ab7c54f0a5200143324dc8e4f0ae3c64f0a5300141b5a08904f0a0fc84f0a4c0014059b34914f0a3bc94f0a4c0014252561924f0a68ca4f0a51009443608c934f0a93cb4f0a51009494628c934f0a93cb4f0a508014b4dfb8944f0abfcc4f0a4d00143883e4954f0aebcd4f0a4a00143de510974f0a17cf4f0a4900142bf73c984f0a43d04f0a4a0014af5568994f0a6fd14f0a4600141976949a4f0a9bd24f0a43001469cdc09b4f0ac7d34f0a430014df1fec9c4f0af3d44f0a4400140c8f189e4f0a1fd64f0a430014a176449f4f0a4bd74f0a430014349570a04f0a77d84f0a4400146b8b9ca14f0aa3d94f0a450014da82c8a24f0acfda4f0a4700144b32f4a34f0afbdb4f0a4a00143ace20a54f0a27dd4f0a4c0014c4584ca64f0a53de4f0a500014284978a74f0a7fdf4f0a540014902da4a84f0aabe04f0a550014bd4dffffffffffffae3f0000110000000402ad0100000000000000000000000000001b1fd0a94f0ad7e14f0a550014875bfcaa4f0a03e34f0a540014238f28ac4f0a2fe44f0a520014e57354ad4f0a5be54f0a5000149c3a80ae4f0a87e64f0a500014b39facaf4f0ab3e74f0a530014fe2dd8b04f0adfe84f0a5800148fd104b24f0a0bea4f0a5c0014a6b330b34f0a37eb4f0a5c0014a53c5cb44f0a63ec4f0a5c001429de88b54f0a8fed4f0a5b0014d1f2b4b64f0abbee4f0a5900145b77e0b74f0ae7ef4f0a560014dc890cb94f0a13f14f0a5300146dbb38ba4f0a3ff24f0a530014df5664bb4f0a6bf34f0a5100142adb90bc4f0a97f44f0a5000142d26ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7cd9