[riot-notifications] [RIOT-OS/RIOT] sys/net/dhcpv6: Add IA_NA support to the DHCPv6 client (#16228)

Jan Romann notifications at github.com
Tue Aug 10 23:11:44 CEST 2021


@JKRhb commented on this pull request.



> +
+def check_ia_pd_addr(ia_pd_addr, global_pfx):
+    """Check if the expected IA_PD address has been assigned"""
+    return ia_pd_addr.startswith(global_pfx)
+
+
+def check_global_addrs(ia_na_addr, ia_pd_addr, global_pfx):
+    """Perform IA_NA check for the first and IA_PD for the second address"""
+    return check_ia_na_addr(ia_na_addr) and check_ia_pd_addr(ia_pd_addr, global_pfx)
+
+
+def test_global_addrs(global_addr_1, global_addr_2, global_pfx):
+    """Assert that one global address is the IA_NA and the other one is the IA_PD address"""
+    result_1 = check_global_addrs(global_addr_1, global_addr_2, global_pfx)
+    result_2 = check_global_addrs(global_addr_2, global_addr_1, global_pfx)
+    assert result_1 != result_2

> as both value lists should contain at least one true value

Ah, I see! I am actually not sure if this is the case as `check_global_addrs` should only return `True` (or two `True` values) if the first address has been assigned by IA_NA and the second one by IA_PD (or – in the case of `result_2` – vice versa as the inputs are flipped). Otherwise you should get a `False` (or two `False` values). Therefore using

```python
assert any(result_1.values())
assert any(result_2.values())
```

should actually result in a failed assertion in one (and only one) of the two cases. Therefore, I think using only 

```python
assert result_1 != result_2
```

should be sufficient if the rest of the test implemetation is correct, with the extended return value of `check_global_addrs` providing addtional safety. I hope I am not missing anything, though :D

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16228#discussion_r686325265
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210810/af812ab5/attachment.htm>


More information about the notifications mailing list