diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2022-06-25 22:17:59 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2022-06-25 22:17:59 +0200 |
commit | 92bc3e9a534f2960d584b5e6698c7122a9ee2f87 (patch) | |
tree | 09b9295232a6f9c021fe72063cb19cc3c3d63aea | |
parent | 5e63d0a516de660ed215b0f8ebe8d3e5d697f19e (diff) |
Test: guard attach code match
-rw-r--r-- | src/pairing.cpp | 4 | ||||
-rw-r--r-- | test/attach.test | 6 | ||||
-rw-r--r-- | test/sync.test | 6 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/pairing.cpp b/src/pairing.cpp index e1e04cc..91e0b0f 100644 --- a/src/pairing.cpp +++ b/src/pairing.cpp @@ -204,8 +204,8 @@ string PairingServiceBase::confirmationNumber(const vector<uint8_t> & digest) { uint32_t confirm; memcpy(&confirm, digest.data(), sizeof(confirm)); - string ret(7, '\0'); - snprintf(ret.data(), ret.size(), "%06d", ntohl(confirm) % 1000000); + string ret(6, '\0'); + snprintf(ret.data(), ret.size() + 1, "%06d", ntohl(confirm) % 1000000); return ret; } diff --git a/test/attach.test b/test/attach.test index 3cbe63e..bfd8ba1 100644 --- a/test/attach.test +++ b/test/attach.test @@ -31,9 +31,9 @@ test: expect /attach-response-failed 1/ from p2 send "attach-to 1" to p2 - expect /attach-request 1 .*/ from p1 - expect /attach-response 1 .*/ from p2 - # TODO: check code match + expect /attach-request 1 ([0-9]*)/ from p1 capture code1 + expect /attach-response 1 ([0-9]*)/ from p2 capture code2 + guard code1 == code2 send "attach-accept 1" to p1 send "attach-accept 1" to p2 diff --git a/test/sync.test b/test/sync.test index eb0c446..06d1a92 100644 --- a/test/sync.test +++ b/test/sync.test @@ -20,9 +20,9 @@ test: /peer 1 id Device1 Owner/ send "attach-to 1" to p2 - expect /attach-request 1 .*/ from p1 - expect /attach-response 1 .*/ from p2 - # TODO: check code match + expect /attach-request 1 ([0-9]*)/ from p1 capture code1 + expect /attach-response 1 ([0-9]*)/ from p2 capture code2 + guard code1 == code2 send "attach-accept 1" to p1 send "attach-accept 1" to p2 |