#!/usr/bin/env elixir # Test script to verify packager fixes alias DaProductApp.MercuryISO8583.Packagers.{ISOMsg, ISO87BPackager} IO.puts("Testing ISOMsg packager fix...") # Test 1: Create ISOMsg with packager and field try do msg = ISOMsg.new("0410") # Returns struct directly, not tuple msg_with_packager = ISOMsg.set_packager(msg, ISO87BPackager) msg_with_field = ISOMsg.set(msg_with_packager, 39, "96") IO.puts("✓ Created ISOMsg: MTI=#{ISOMsg.get_mti(msg_with_field)}") IO.puts("✓ Packager: #{inspect(ISOMsg.get_packager(msg_with_field))}") IO.puts("✓ Field 39: #{ISOMsg.get_field(msg_with_field, 39)}") # Test 2: Try to pack the message case ISO87BPackager.pack(msg_with_field) do {:ok, packed} -> IO.puts("✓ Successfully packed: #{byte_size(packed)} bytes") {:error, reason} -> IO.puts("✗ Pack failed: #{inspect(reason)}") end rescue e -> IO.puts("✗ Test failed with exception: #{inspect(e)}") end IO.puts("Test completed.")