package walletmq

import "testing"

func TestWalletOutboxMessageRoundTrip(t *testing.T) {
	encoded, err := EncodeWalletOutboxMessage(WalletOutboxMessage{
		AppCode:        "lalu",
		EventID:        "event-1",
		EventType:      "WalletRechargeRecorded",
		TransactionID:  "tx-1",
		CommandID:      "cmd-1",
		UserID:         1001,
		AssetType:      "COIN",
		AvailableDelta: 100,
		PayloadJSON:    `{"recharge_sequence":1}`,
		OccurredAtMS:   1_700_000_000_000,
	})
	if err != nil {
		t.Fatalf("EncodeWalletOutboxMessage failed: %v", err)
	}

	decoded, err := DecodeWalletOutboxMessage(encoded)
	if err != nil {
		t.Fatalf("DecodeWalletOutboxMessage failed: %v", err)
	}
	if decoded.MessageType != MessageTypeWalletOutboxEvent || decoded.EventID != "event-1" || decoded.PayloadJSON == "" {
		t.Fatalf("decoded message mismatch: %+v", decoded)
	}
}
