github.com/danil/iso8583@v0.21.0/codec8583/mastercard_format_test.go (about) 1 package codec8583_test 2 3 import ( 4 "bytes" 5 "encoding/json" 6 "fmt" 7 "io/ioutil" 8 "runtime" 9 "strconv" 10 "testing" 11 12 "github.com/danil/iso8583/codec8583" 13 ) 14 15 var MastercardFormatTestCases = []struct { 16 encoded []byte 17 decoded iso8583Msg 18 line int 19 benchmark bool 20 }{ 21 { 22 encoded: iso8583Bytes[0], 23 decoded: iso8583Msg{MTIMessageTypeIndicator: "0100", PANPrimaryAccountNumber2: "5321XXXXXXXX6334", ProcessingCode3: "000000", AmountTransaction4: "000000020126", AmountCardholderBilling6: "000000000310", TransmissionDateTime7: "1008053137", ConversionRateCardholderBilling10: "70154259", SystemTraceAuditNumber11: "196842", LocalTransactionTime12: "083137", LocalTransactionDate13: "1008", ExpirationDate14: "2312", SettlementDate15: "1008", CurrencyConversionDate16: "1008", MerchantTypeOrMerchantCategoryCode18: "5411", POSPointOfServiceEntryMode22: "071", ApplicationPANSequenceNumber23: "001", AcquiringInstitutionIdentificationCode32: "005037", ForwardingInstitutionIdentificationCode33: "200154", Track2Data35: "5321XXXXXXXX6334D23122011969100000377", RetrievalReferenceNumber37: "519939727023", CardAcceptorTerminalIdentification41: "10747007", CardAcceptorIdentificationCode42: "990000026622 ", CardAcceptorNameLocation43: "PYATEROCHKA 7904 Podolsk RUS", AdditionalDataPrivate48: "2fLz8PLw8Pbx8PXw8PDw8Q==", CurrencyCodeTransaction49: "643", CurrencyCodeCardholderBilling51: "840", ICCData55: "XyoCBkOCAhmAhAegAAAABBAQlQUAAACAAJoDGRAInAEAnwIGAAAAAgEmnwMGAAAAAAAAnxASARCgQAMiAAAAAAAAAAAAAAD/nxoCBkOfJggCXxqRiyDckZ8nAYCfMwPgCMifNAMfAwCfNgIBYJ83BM8lmh8=", ReservedPrivate1_61: "0000010000300643142103", ReservedPrivate3_63: "TNWGAP405"}, 24 line: func() int { _, _, l, _ := runtime.Caller(1); return l }(), 25 benchmark: true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0x8, 0xee, 0xf1, 0x98, 0xfd, 0x3d, 0x57, 0xd7, 0xd, 0x9f, 0x27, 0x1, 0x80, 0x9f, 0x33, 0x3, 0xe0, 0x8, 0xc8, 0x9f, 0x34, 0x3, 0x1f, 0x3, 0x0, 0x9f, 0x36, 0x2, 0x2, 0x3, 0x9f, 0x37, 0x4, 0x64, 0x75, 0x32, 0xb8, 0xf0, 0xf2, 0xf2, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf0, 0xf0, 0xf0, 0xf0, 0xf3, 0xf0, 0xf0, 0xf6, 0xf4, 0xf3, 0xf6, 0xf4, 0xf4, 0xf0, 0xf4, 0xf7, 0xf0, 0xf0, 0xf9, 0xe3, 0xd5, 0xe6, 0xd8, 0xc2, 0xd7, 0xc5, 0xf0, 0xf0}, 29 decoded: iso8583Msg{MTIMessageTypeIndicator: "0100", PANPrimaryAccountNumber2: "5321XXXXXXXX9412", ProcessingCode3: "000000", AmountTransaction4: "000000012390", AmountCardholderBilling6: "000000000191", TransmissionDateTime7: "1008053137", ConversionRateCardholderBilling10: "70154259", SystemTraceAuditNumber11: "196854", LocalTransactionTime12: "083137", LocalTransactionDate13: "1008", ExpirationDate14: "2309", SettlementDate15: "1008", CurrencyConversionDate16: "1008", MerchantTypeOrMerchantCategoryCode18: "5411", POSPointOfServiceEntryMode22: "071", ApplicationPANSequenceNumber23: "001", AcquiringInstitutionIdentificationCode32: "005037", ForwardingInstitutionIdentificationCode33: "200154", Track2Data35: "5321XXXXXXXX9412D23092011562000000495", RetrievalReferenceNumber37: "519939727047", CardAcceptorTerminalIdentification41: "11337281", CardAcceptorIdentificationCode42: "990000031650 ", CardAcceptorNameLocation43: "MAGNIT MM ARAKCHINKA Omsk RUS", AdditionalDataPrivate48: "2fLz8PLw8Pbx8PXw8PDw8Q==", CurrencyCodeTransaction49: "643", CurrencyCodeCardholderBilling51: "840", ICCData55: "XyoCBkOCAhmAhAegAAAABBAQlQUAAACAAJoDGRAInAEAnw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 0xf7, 0xf3, 0xf3, 0xf4, 0xf1, 0xf1, 0xf0, 0xf0, 0xf1, 0xf4, 0xf3, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xe6, 0xf6, 0xf1, 0xf0, 0xf5, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf6, 0xf4, 0xf0, 0xf4, 0xf0, 0xf3, 0xf0, 0xf0, 0xf7, 0xf1, 0xf0, 0xf8, 0xf5, 0xf0, 0xc3, 0x40, 0xf5, 0xf1, 0xe5, 0x40, 0xf7, 0xf2, 0xf1, 0xf0, 0x10, 0x76, 0xa0, 0x98, 0x3d, 0x46, 0xb3, 0xcc, 0x0, 0x10, 0xf6, 0xf4, 0xf3, 0xf8, 0xf4, 0xf0, 0xf0, 0xf3, 0xf7, 0xf0, 0xf1, 0xf3, 0xf3, 0xf0, 0xf1, 0xf2, 0xf9, 0xf5, 0xf0, 0xf0, 0xf1, 0xc3, 0xf8, 0xd1, 0xd4, 0xc7, 0xf0, 0xf3, 0xd8, 0xd6, 0xd6, 0xe5, 0xe9, 0xf2, 0xf1, 0xf4, 0xc5, 0xc7, 0xc6, 0xe8, 0xe3, 0xe3, 0xf2, 0xc7, 0xc2, 0xc3, 0xf0, 0xf2, 0xf2, 0xf1, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf3, 0xf0, 0xf0, 0xf6, 0xf4, 0xf3, 0xf6, 0xf2, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf9, 0xe3, 0xd5, 0xe6, 0xd8, 0xc4, 0xc4, 0xd9, 0xf0, 0xf4}, 34 decoded: iso8583Msg{MTIMessageTypeIndicator: "0100", PANPrimaryAccountNumber2: "5321XXXXXXXX9653", ProcessingCode3: "000000", AmountTransaction4: "000000003200", AmountCardholderBilling6: "000000000049", TransmissionDateTime7: "1008053137", ConversionRateCardholderBilling10: "70154259", SystemTraceAuditNumber11: "331205", LocalTransactionTime12: "092118", LocalTransactionDate13: "1008", ExpirationDate14: "2401", SettlementDate15: "1008", CurrencyConversionDate16: "1008", MerchantTypeOrMerchantCategoryCode18: "4131", POSPointOfServiceEntryMode22: "072", AcquiringInstitutionIdentificationCode32: "007326", ForwardingInstitutionIdentificationCode33: "200009", RetrievalReferenceNumber37: "008932631205", CardAcceptorTerminalIdentification41: "149683 ", CardAcceptorIdentificationCode42: "149683 ", CardAcceptorNameLocation43: "ISET TRANSPORT 824 EKATERINBURG RUS", AdditionalDataPrivate48: "5/L28PPx8PPz8PT0xvmnwdmY0dOBxaTGosHmkaP3ptHm9uTxTpKTo9el9eSZ5oGRpcLxhvDBon7z8/T48PHw8cPw8vH29fT08/Px+fXw9/H58PPz9vDz8PTy8vD58Pbx8fXw8fHw8PPw8vfz8/Tx8fDw8fTz8PDw8PDm9vHw9fDw8PDx9vTw9PDz8PD38fD49fDDQPXx5UD38vHwEHagmD1Gs8wAEA==", CurrencyCodeTransaction49: "643", CurrencyCodeCardholderBilling51: "840", ReservedISO56: "013301295001C8JMG03QOOVZ214EGFYTT2GBC", ReservedPrivate1_61: "1000000000300643620000", ReservedPrivate3_63: "TNWQDDR04"}, 35 line: func() int { _, _, l, _ := runtime.Caller(1); return l }(), 36 }, 37 { 38 encoded: []byte{0xf0, 0xf1, 0xf0, 0xf0, 0x76, 0x7f, 0x46, 0x1, 0xa8, 0xe1, 0xa2, 0xa, 0xf1, 0xf6, 0xf5, 0xf3, 0xf2, 0xf1, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xf3, 0xf4, 0xf9, 0xf4, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf1, 0xf7, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf2, 0xf6, 0xf2, 0xf1, 0xf0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f4, 0xf4, 0xf0, 0xf0, 0xf9, 0xe3, 0xd5, 0xe6, 0xd8, 0xf2, 0xe9, 0xe8, 0xf0, 0xf4}, 39 decoded: iso8583Msg{MTIMessageTypeIndicator: "0100", PANPrimaryAccountNumber2: "5321XXXXXXXX3494", ProcessingCode3: "000000", AmountTransaction4: "000000017000", AmountCardholderBilling6: "000000000262", TransmissionDateTime7: "1008053137", ConversionRateCardholderBilling10: "70154259", SystemTraceAuditNumber11: "741844", LocalTransactionTime12: "083133", LocalTransactionDate13: "1008", ExpirationDate14: "2301", SettlementDate15: "1008", CurrencyConversionDate16: "1008", MerchantTypeOrMerchantCategoryCode18: "5814", POSPointOfServiceEntryMode22: "072", ApplicationPANSequenceNumber23: "000", AcquiringInstitutionIdentificationCode32: "014113", ForwardingInstitutionIdentificationCode33: "200392", Track2Data35: "5321XXXXXXXX3494D23012011163800000991", RetrievalReferenceNumber37: "100860525254", CardAcceptorTerminalIdentification41: "91002605", CardAcceptorIdentificationCode42: "91001343 ", CardAcceptorNameLocation43: "CAFE SANKT-PETERBU RUS", AdditionalDataPrivate48: "xvLz8PLw8Pbx8PXw8PDw8Q==", CurrencyCodeTransaction49: "643", CurrencyCodeCardholderBilling51: "840", ICCData55: "ggIZgJUFAAAAgAGaAxkQCJwBAF8qAgZDnwIGAAAAAXAAnwMGAAAAAAAAnxASARCgQAMiAAAAAAAAAAAAAAD/nxoCBkOfJgj2NiX3pkxM6J8nAYCfMwPgCMifNgIJLJ83BBxEof2fQQMCUlSfNAMfAwKfNQEihAegAAAABBAQ", ReservedPrivate1_61: "0000010000300643199044", ReservedPrivate3_63: "TNWQ2ZY04"}, 40 line: func() int { _, _, l, _ := runtime.Caller(1); return l }(), 41 }, 42 } 43 44 func TestMastercardFormat(t *testing.T) { 45 _, testFile, _, _ := runtime.Caller(0) 46 for _, tc := range MastercardFormatTestCases { 47 tc := tc 48 t.Run(strconv.Itoa(tc.line), func(t *testing.T) { 49 t.Parallel() 50 linkToExample := fmt.Sprintf("%s:%d", testFile, tc.line) 51 dec := iso8583Msg{} 52 err := codec8583.MastercardUnmarshaler.Unmarshal(tc.encoded, &dec) 53 if err != nil { 54 t.Fatalf("unexpected error: %#v - %s", err, linkToExample) 55 } 56 if dec != tc.decoded { 57 t.Errorf("[decoded message] expected: %#v, received: %#v - %s", tc.decoded, dec, linkToExample) 58 } 59 enc, err := codec8583.MastercardMarshaler.Marshal(&dec) 60 if err != nil { 61 t.Fatalf("unexpected error: %#v - %s", err, linkToExample) 62 } 63 if !bytes.Equal(enc, tc.encoded) { 64 t.Errorf("[encoded message] expected %#v, received: %#v - %s", tc.encoded, enc, linkToExample) 65 } 66 }) 67 } 68 } 69 70 func TestMastercardFormatByMastercardJSON(t *testing.T) { 71 jsonFile := "mastercard.json" 72 p, err := ioutil.ReadFile(jsonFile) 73 if err != nil { 74 t.Fatalf("unexpected error: %#v", err) 75 } 76 var messages []iso8583Msg 77 if err := json.Unmarshal(p, &messages); err != nil { 78 t.Fatalf("unexpected error: %#v", err) 79 } 80 for i, msg := range messages { 81 msg := msg 82 linkToExample := fmt.Sprintf("%s:%d", jsonFile, i+1) 83 t.Run(linkToExample, func(t *testing.T) { 84 t.Parallel() 85 enc, err := codec8583.MastercardMarshaler.Marshal(&msg) 86 if err != nil { 87 t.Fatalf("unexpected error: %#v - %s", err, linkToExample) 88 } 89 dec := iso8583Msg{} 90 err = codec8583.MastercardUnmarshaler.Unmarshal(enc, &dec) 91 if err != nil { 92 t.Fatalf("unexpected error: %#v - %s", err, linkToExample) 93 } 94 if dec != msg { 95 t.Errorf("[decoded message] expected: %#v, received: %#v - %s", msg, dec, linkToExample) 96 } 97 }) 98 } 99 } 100 101 func TestMastercardFormatByNSPKJSON(t *testing.T) { 102 jsonFile := "nspk.json" 103 p, err := ioutil.ReadFile(jsonFile) 104 if err != nil { 105 t.Fatalf("unexpected error: %#v", err) 106 } 107 var messages []iso8583Msg 108 if err := json.Unmarshal(p, &messages); err != nil { 109 t.Fatalf("unexpected error: %#v", err) 110 } 111 for i, msg := range messages { 112 msg := msg 113 linkToExample := fmt.Sprintf("%s:%d", jsonFile, i+1) 114 t.Run(linkToExample, func(t *testing.T) { 115 t.Parallel() 116 enc, err := codec8583.MastercardMarshaler.Marshal(&msg) 117 if err != nil { 118 t.Fatalf("unexpected error: %#v - %s", err, linkToExample) 119 } 120 dec := iso8583Msg{} 121 err = codec8583.MastercardUnmarshaler.Unmarshal(enc, &dec) 122 if err != nil { 123 t.Fatalf("unexpected error: %#v - %s", err, linkToExample) 124 } 125 if dec != msg { 126 t.Errorf("[decoded message] expected: %#v, received: %#v - %s", msg, dec, linkToExample) 127 } 128 }) 129 } 130 } 131 132 func BenchmarkMastercardMarshalerMarshal(b *testing.B) { 133 for _, tc := range MastercardFormatTestCases { 134 if !tc.benchmark { 135 continue 136 } 137 b.Run(strconv.Itoa(tc.line), func(b *testing.B) { 138 for i := 0; i < b.N; i++ { 139 _, err := codec8583.MastercardMarshaler.Marshal(&tc.decoded) 140 if err != nil { 141 fmt.Println(err) 142 } 143 } 144 }) 145 } 146 } 147 148 func BenchmarkMastercardUnmarshalerUnmarshal(b *testing.B) { 149 for _, tc := range MastercardFormatTestCases { 150 if !tc.benchmark { 151 continue 152 } 153 b.Run(strconv.Itoa(tc.line), func(b *testing.B) { 154 for i := 0; i < b.N; i++ { 155 dec := iso8583Msg{} 156 err := codec8583.MastercardUnmarshaler.Unmarshal(tc.encoded, &dec) 157 if err != nil { 158 fmt.Println(err) 159 } 160 } 161 }) 162 } 163 }