Skip to content

Commit

Permalink
Fix invalid message size calculation
Browse files Browse the repository at this point in the history
Ref. #1042
  • Loading branch information
treiher committed Jun 1, 2022
1 parent 6ce3b09 commit 38022f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rflx/model/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2397,5 +2397,5 @@ def to_mapping(facts: Sequence[expr.Expr]) -> Dict[expr.Name, expr.Expr]:
return {
f.left: f.right
for f in facts
if isinstance(f, (expr.Equal, expr.GreaterEqual)) and isinstance(f.left, expr.Name)
if isinstance(f, expr.Equal) and isinstance(f.left, expr.Name)
}
8 changes: 4 additions & 4 deletions tests/unit/model/message_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2726,24 +2726,24 @@ def test_is_definite() -> None:
def test_size() -> None:
assert NULL_MESSAGE.size() == Number(0)
assert FIXED_SIZE_MESSAGE.size() == Number(200)
assert TLV_MESSAGE.size({Field("Tag"): Variable("Msg_Error")}) == Number(8)
assert TLV_MESSAGE.size({Field("Tag"): Variable("TLV::Msg_Error")}) == Number(8)
assert TLV_MESSAGE.size(
{
Field("Tag"): Variable("Msg_Data"),
Field("Tag"): Variable("TLV::Msg_Data"),
Field("Length"): Number(4),
Field("Value"): Aggregate(*[Number(0)] * 4),
}
) == Number(56)
assert TLV_MESSAGE.size(
{
Field("Tag"): Variable("Msg_Data"),
Field("Tag"): Variable("TLV::Msg_Data"),
Field("Length"): Div(Add(Size("Tag"), Size("TLV::Length")), Number(8)),
Field("Value"): Aggregate(*[Number(0)] * 3),
}
) == Number(48)
assert TLV_MESSAGE.size(
{
Field("Tag"): Variable("Msg_Data"),
Field("Tag"): Variable("TLV::Msg_Data"),
Field("Length"): Add(Div(Size("X"), Number(8)), Variable("Y")),
Field("Value"): Variable("Z"),
}
Expand Down

0 comments on commit 38022f9

Please sign in to comment.