Skip to content

Commit a2ea2fd

Browse files
authored
Merge pull request #1683 from moov-io/feat-txp-addenda
feat: support TXP Addenda05 strings
2 parents 27093fe + dae1585 commit a2ea2fd

File tree

9 files changed

+965
-132
lines changed

9 files changed

+965
-132
lines changed

.github/workflows/fuzz.yml

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ permissions:
88
contents: read
99

1010
jobs:
11-
fuzz-ach:
12-
name: Fuzz ACH
11+
fuzz:
12+
name: Fuzz
1313
runs-on: ubuntu-latest
14-
timeout-minutes: 12
14+
timeout-minutes: 15
15+
strategy:
16+
matrix:
17+
command:
18+
- "go test ./addenda/... -fuzz Fuzz -fuzztime 10m"
19+
- "go test ./test/fuzz/... -fuzz ACH -fuzztime 10m"
20+
- "go test ./test/fuzz/... -fuzz JSON -fuzztime 10m"
1521

1622
steps:
1723
- name: Set up Go 1.x
@@ -25,55 +31,11 @@ jobs:
2531
with:
2632
fetch-depth: 0
2733

28-
- uses: actions/cache@v5
29-
with:
30-
path: |
31-
~/.cache/go-build
32-
~/go/pkg/mod
33-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
34-
restore-keys: |
35-
${{ runner.os }}-go-
36-
3734
- name: Fuzz
38-
run: |
39-
go test ./test/fuzz/... -fuzz ACH -fuzztime 10m
40-
41-
- name: Report Failures
42-
if: ${{ failure() }}
43-
run: |
44-
find ./test/fuzz/testdata/fuzz/ -type f | xargs -n1 tail -n +1 -v
45-
46-
fuzz-json:
47-
name: Fuzz JSON
48-
runs-on: ubuntu-latest
49-
timeout-minutes: 12
50-
51-
steps:
52-
- name: Set up Go 1.x
53-
uses: actions/setup-go@v6
54-
with:
55-
go-version: stable
56-
id: go
57-
58-
- name: Check out code into the Go module directory
59-
uses: actions/checkout@v6
60-
with:
61-
fetch-depth: 0
62-
63-
- uses: actions/cache@v5
64-
with:
65-
path: |
66-
~/.cache/go-build
67-
~/go/pkg/mod
68-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
69-
restore-keys: |
70-
${{ runner.os }}-go-
71-
72-
- name: Fuzz
73-
run: |
74-
go test ./test/fuzz/... -fuzz JSON -fuzztime 10m
35+
run: ${{ matrix.command }}
7536

7637
- name: Report Failures
7738
if: ${{ failure() }}
7839
run: |
40+
find ./addenda/testdata/fuzz/ -type f | xargs -n1 tail -n +1 -v
7941
find ./test/fuzz/testdata/fuzz/ -type f | xargs -n1 tail -n +1 -v

addenda/fuzz_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Licensed to The Moov Authors under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. The Moov Authors licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package addenda
19+
20+
import (
21+
"testing"
22+
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func FuzzParseTXP(f *testing.F) {
27+
examples := []string{
28+
"123456789*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
29+
"TXP**941*250901*T*1000\\",
30+
"TXP*123#456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
31+
"TXP*123-456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
32+
"TXP*123.456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
33+
"TXP*123456789**250901*T*1000\\",
34+
"TXP*123456789*606*960331*T*100000*P*12000*I*4567*SML2A\\",
35+
"TXP*123456789*941**T*1000\\",
36+
"TXP*123456789*941*2509*T*1000\\",
37+
"TXP*123456789*941*250901**1000\\",
38+
"TXP*123456789*941*250901*1*1000*2*500***VERIFIED\\",
39+
"TXP*123456789*941*250901*1*1000*2*500\\",
40+
"TXP*123456789*941*250901*T* 1000 \\",
41+
"TXP*123456789*941*250901*T*1000****VERIFIED\\",
42+
"TXP*123456789*941*250901*T*1000*VERIFIED\\",
43+
"TXP*123456789*941*250901*T*1000*\\",
44+
"TXP*123456789*941*250901*T*100000\\",
45+
"TXP*123456789*941*250901*T*\\",
46+
"TXP*123456789*941*2509011*T*1000\\",
47+
"TXP*123456789*941*ABCDEF*T*1000\\",
48+
"TXP*123456789*94105*960301*1*10000*2*5000*3*15000\\",
49+
"TXP*123456789*FEDERAL*20231231*500000*1*25000*VERIFIED\\",
50+
"TXP*123456789*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED",
51+
"TXP*123456789*FEDERAL*20231231*TAX2023Q4*500000*1*25000*2**VERIFIED\\",
52+
"TXP*123456789*FEDERAL*20231231*TAX2023Q4*500000*1*25000*2*10000*VERIFIED_WITH_VERY_LONG_VERIFICATION_STRING\\",
53+
"TXP*123456789*FEDERAL*20231231*TAX2023Q4\\",
54+
"TXP*123456789*STATE*20231231*TAX2023Q4*500000*S**VERIFIED\\",
55+
"TXP*12345678934*526*960930*T*100000***SML2A\\",
56+
"TXP*123:456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
57+
"TXP*123@456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
58+
"TXP*123\n456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
59+
"TXP*123\t456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\",
60+
"TXP*888999000*STATE*20231231*S*200000*2*10000**CONFIRMED\\",
61+
"txp*123456789*941*250901*T*1000\\",
62+
}
63+
64+
for i := range examples {
65+
f.Add(examples[i])
66+
}
67+
68+
f.Fuzz(func(t *testing.T, input string) {
69+
require.NotPanics(t, func() {
70+
rec, _ := ParseTXP(input)
71+
if rec != nil {
72+
rec.String()
73+
}
74+
})
75+
})
76+
}

0 commit comments

Comments
 (0)