File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ func (part *Part) ValidateBasic() error {
37
37
if int64 (part .Index ) < part .Proof .Total - 1 && len (part .Bytes ) != int (BlockPartSizeBytes ) {
38
38
return ErrPartInvalidSize
39
39
}
40
+ if int64 (part .Index ) != part .Proof .Index {
41
+ return fmt .Errorf ("part index %d != proof index %d" , part .Index , part .Proof .Index )
42
+ }
40
43
if err := part .Proof .ValidateBasic (); err != nil {
41
44
return fmt .Errorf ("wrong Proof: %w" , err )
42
45
}
Original file line number Diff line number Diff line change @@ -137,19 +137,27 @@ func TestPartValidateBasic(t *testing.T) {
137
137
pt .Index = 1
138
138
pt .Bytes = make ([]byte , BlockPartSizeBytes - 1 )
139
139
pt .Proof .Total = 2
140
+ pt .Proof .Index = 1
140
141
}, false },
141
142
{"Too small inner part" , func (pt * Part ) {
142
143
pt .Index = 0
143
144
pt .Bytes = make ([]byte , BlockPartSizeBytes - 1 )
145
+ pt .Proof .Index = 1
144
146
pt .Proof .Total = 2
145
- }, true },
147
+ },
148
+
149
+ true },
146
150
{"Too big proof" , func (pt * Part ) {
147
151
pt .Proof = merkle.Proof {
148
152
Total : 2 ,
149
153
Index : 1 ,
150
154
LeafHash : make ([]byte , 1024 * 1024 ),
151
155
}
152
156
}, true },
157
+ {"Index mismatch" , func (pt * Part ) {
158
+ pt .Index = 1
159
+ pt .Proof .Index = 0
160
+ }, true },
153
161
}
154
162
155
163
for _ , tc := range testCases {
You can’t perform that action at this time.
0 commit comments