@@ -78,7 +78,7 @@ func TestStructFieldHelpers(t *testing.T) {
78
78
c := common .PointerTo (cVal )
79
79
d := common .PointerTo (dVal )
80
80
e := []uint64 {40 , 41 }
81
- f := common . PointerTo ( []uint64 {50 , 51 })
81
+ f := & []uint64 {50 , 51 }
82
82
83
83
tests := []foo {
84
84
{a , b , c , d , e , f }, // 000 (which of d/e/f are nil)
@@ -91,6 +91,7 @@ func TestStructFieldHelpers(t *testing.T) {
91
91
{a , b , c , nil , nil , nil }, // 111
92
92
// Empty and nil slices are treated differently when optional
93
93
{a , b , c , nil , []uint64 {}, nil },
94
+ {a , b , c , nil , nil , & []uint64 {}},
94
95
}
95
96
96
97
for _ , obj := range tests {
@@ -189,17 +190,28 @@ func TestNillable(t *testing.T) {
189
190
C * []uint64 `rlp:"nil"`
190
191
}
191
192
192
- aMatrix := []* uint64 {nil , common.PointerTo [uint64 ](0 )}
193
- bMatrix := []* inner {nil , {0 }}
194
- cMatrix := []* []uint64 {nil , {}, {0 }}
195
-
193
+ // Unlike the `rlp:"optional"` tag, there is no interplay between nil-tagged
194
+ // fields so we don't need the Cartesian product of all possible
195
+ // combinations.
196
196
var tests []outer
197
- for _ , a := range aMatrix {
198
- for _ , b := range bMatrix {
199
- for _ , c := range cMatrix {
200
- tests = append (tests , outer {a , b , c })
201
- }
202
- }
197
+ for _ , a := range []* uint64 {
198
+ nil ,
199
+ common.PointerTo [uint64 ](0 ),
200
+ } {
201
+ tests = append (tests , outer {a , nil , nil })
202
+ }
203
+ for _ , b := range []* inner {
204
+ nil ,
205
+ {0 },
206
+ } {
207
+ tests = append (tests , outer {nil , b , nil })
208
+ }
209
+ for _ , c := range []* []uint64 {
210
+ nil ,
211
+ {},
212
+ {0 },
213
+ } {
214
+ tests = append (tests , outer {nil , nil , c })
203
215
}
204
216
205
217
// When a Nillable encounters an empty list it MUST set the field to nil,
0 commit comments