Skip to content

feat: add documentation, unit tests, integration tests, and CI workflows#2

Merged
tmthecoder merged 10 commits intomainfrom
feat/docs-and-tests
Feb 8, 2026
Merged

feat: add documentation, unit tests, integration tests, and CI workflows#2
tmthecoder merged 10 commits intomainfrom
feat/docs-and-tests

Conversation

@tmthecoder
Copy link
Copy Markdown
Owner

@tmthecoder tmthecoder commented Feb 8, 2026

Summary

  • Rustdoc added to key public modules (lib, protocol, header, body, message)
  • Inline unit tests (#[cfg(test)]) added to 11 source files covering: byte_helper, header, flags, command_code, dialect, capabilities, security_mode, filetime, error_response, empty/echo, message
  • Doc comment placement fix — moved doc comments above #[derive] to prevent proc-macro tag serialization breakage
  • smbclient integration tests (tests/smbclient.rs) — 6 ignored tests for negotiate, session setup, tree connect, and resilience
  • GitHub Actions CI — 4 workflow files: check/clippy, unit tests, integration tests, docs

smb-derive: Macro Correctness & Documentation

  • Rustdoc added to all 4 creator modules, all attribute structs, field mapping types, and public functions
  • 25 integration tests covering all derive macros (SMBFromBytes, SMBToBytes, SMBByteSize, SMBEnumFromBytes) and all field attribute types (smb_direct, smb_buffer, smb_vector, smb_string, smb_enum, smb_skip, smb_byte_tag, smb_string_tag, smb_discriminator)
  • 6 latent correctness bugs fixed (none were triggered by current usage patterns, but all are real logic errors):
    • StringTag::smb_from_bytesposition() returns relative offset but was used as absolute index in starts_with
    • Vector::smb_to_bytes — alignment closure hardcoded 8 instead of using the align parameter
    • smb_enum_from_bytes NamedStruct arm — emitted literal variant_ident instead of interpolating #variant_ident
    • ByteTag::smb_from_bytes — no bounds check before scanning; panics instead of returning Err on malformed input
    • SMBString::smb_to_bytes — used UTF-8 .len() for the wire length field instead of encode_utf16().count() * 2
    • SMBString::smb_to_bytesencode_utf16() iterator was not collected before iteration
  • Removed all debug println! statements (3 compile-time, 1 runtime)

Known remaining macro limitations (documented in tests with workarounds)

  • Single-field structs with parent attrs (smb_byte_tag/smb_string_tag) generate broken variable references in SMBToBytes
  • Tuple structs generate self.val_0 instead of self.0 in SMBToBytes

Test Results

47 passed, 4 expected failures documenting known bugs:

  • byte_helper: bit shift 54 instead of 56 for u64 high byte
  • error_response: smb_from_bytes always returns UnknownError
  • filetime: round-trip broken due to buggy u64 helpers

smb-derive: 25 passed, 0 failed

…d CI workflows

- Add rustdoc to key public modules (lib, protocol, header, body, message)
- Add inline #[cfg(test)] unit tests to 11 source files covering:
  byte_helper, header, flags, command_code, dialect, capabilities,
  security_mode, filetime, error_response, empty/echo, message
- Move doc comments above #[derive] to fix proc-macro tag serialization
- Create smbclient-based integration tests (tests/smbclient.rs)
- Add GitHub Actions workflows: check, unit-tests, integration-tests, docs

Test results: 47 passed, 4 expected failures (known bugs:
u64 bit-shift 54 vs 56, error_response parse always returns UnknownError,
filetime round-trip depends on buggy u64 helpers)
- smb-core, smb-derive, smb: edition 2021 → 2024
- Restore let-chains syntax in smb-derive/src/field.rs (stable in 2024)
- Remove explicit `ref` in match patterns (implicit in 2024)
  - smb-derive/src/field_mapping.rs
  - smb/src/server/message_handler.rs
- Fix StringTag::smb_from_bytes using relative offset as absolute index
- Fix Vector::smb_to_bytes alignment closure hardcoding 8 instead of align param
- Fix smb_enum_from_bytes NamedStruct arm missing #variant_ident interpolation
- Fix ByteTag::smb_from_bytes missing bounds check (panic → Err on malformed input)
- Fix SMBString::smb_to_bytes UTF-16 length using UTF-8 byte count instead of UTF-16 byte count
- Fix encode_utf16() iterator not collected in string serialization
- Remove all debug println! statements (compile-time and runtime)
- Add rustdoc to all 4 creator modules (FromBytes, ToBytes, ByteSize, EnumFromBytes)
- Add rustdoc to all attribute structs and field mapping types
- Add 25 integration tests covering all derive macros and field attribute types
- Add smb-core and num_enum as dev-dependencies for test support
Base automatically changed from feat/smb2-signing-errors-ipc to main February 8, 2026 19:59
- smb-core: replace needless .as_bytes().len() with .len() on String
- smb-derive: prefix unused variables with underscore
- smb-derive: allow dead_code on DiscriminatedEnum variant
- smb-derive: elide needless explicit lifetimes
@tmthecoder tmthecoder merged commit a7b90a9 into main Feb 8, 2026
3 of 5 checks passed
@tmthecoder tmthecoder deleted the feat/docs-and-tests branch February 8, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant