Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more tests
  • Loading branch information
svyatonik committed Feb 9, 2023
commit e3fe021e1a01ecfaef16370f1bcfb759b9c058a1
4 changes: 4 additions & 0 deletions modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2094,6 +2094,10 @@ mod tests {
storage(max_entries - 1).extra_proof_size_bytes(),
relayer_entry().encode().len() as u64
);
Comment on lines +2108 to +2111
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit1: I hope encoded_size_hint() used in extra_proof_size_bytes() is consistent in its return value and this test will be robust - worst case it will intermittently fail and we'll worry about that then.

nit2: I would add another one for extra safety (especially since previous test only verifies generic post_dispatch_weight.proof_size() < pre_dispatch_weight.proof_size() without checking/knowing how much smaller it should be.

Suggested change
assert_eq!(
storage(max_entries - 1).extra_proof_size_bytes(),
relayer_entry().encode().len() as u64
);
assert_eq!(
storage(max_entries - 1).extra_proof_size_bytes(),
relayer_entry().encode().len() as u64
);
assert_eq!(
storage(max_entries - 2).extra_proof_size_bytes(),
2 * relayer_entry().encode().len() as u64
);

(above could also be a loop, but testing at least two values is good enough imo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit1: I hope encoded_size_hint() used in extra_proof_size_bytes() is consistent in its return value and this test will be robust - worst case it will intermittently fail and we'll worry about that then.

I'm not sure exactly what you mean here, but both expressions in the extra_proof_size_bytes are using values, returned from the max_encoded_len. So iiuc they are somewhat consistent :)

nit2: I would add another one for extra safety (especially since previous test only verifies generic post_dispatch_weight.proof_size() < pre_dispatch_weight.proof_size() without checking/knowing how much smaller it should be.

Done

assert_eq!(
storage(max_entries - 2).extra_proof_size_bytes(),
2 * relayer_entry().encode().len() as u64
);

// when we have more than `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers
// (shall not happen in practice)
Expand Down