Skip to content

Commit f3f3de4

Browse files
committed
feat(): fix GetBundleItem bug
1 parent f158334 commit f3f3de4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

client.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1112,12 +1112,14 @@ func (c *Client) GetBundleItems(bundleInId string, itemsIds []string) (items []*
11121112

11131113
// if item is in itemsIds
11141114
if utils.ContainsInSlice(itemsIds, id) {
1115-
11161115
startChunkNum := bundleItemStart / types.MAX_CHUNK_SIZE
11171116
startChunkOffset := bundleItemStart % types.MAX_CHUNK_SIZE
11181117
data := make([]byte, 0, itemBinaryLength)
11191118

11201119
for offset := startOffset + int64(startChunkNum*types.MAX_CHUNK_SIZE); offset <= startOffset+int64(bundleItemStart+itemBinaryLength); {
1120+
if offset >= endOffset {
1121+
break
1122+
}
11211123
chunk, err := c.getChunkData(offset)
11221124

11231125
if err != nil {

client_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,11 @@ func Test_getChunkData(t *testing.T) {
364364

365365
func TestClient_GetBundleItems(t *testing.T) {
366366
c := NewClient("https://arweave.net")
367-
itemsIds := []string{"UCTEOaljmuutGJId-ktPY_q_Gbal8tyJuLfyR6BeaGw"}
368-
items, err := c.GetBundleItems("47KozLIAfVMKdxq1q3D1xFZmRpkahOOBQ8boOjSydnQ", itemsIds)
367+
itemsIds := []string{"UQjYcsjcB3udqgSKgwm0jYeh6lyxsKbSJ8h0ekYecZ8"}
368+
items, err := c.GetBundleItems("5mnFoNrXKYVESgIyk9PCVPUPYhL4y5uaxOz-ShflJQk", itemsIds)
369369
assert.NoError(t, err)
370370
assert.Equal(t, 1, len(items))
371-
assert.Equal(t, "UCTEOaljmuutGJId-ktPY_q_Gbal8tyJuLfyR6BeaGw", items[0].Id)
371+
assert.Equal(t, "UQjYcsjcB3udqgSKgwm0jYeh6lyxsKbSJ8h0ekYecZ8", items[0].Id)
372372
}
373373

374374
func TestClient_GetBundleItems2(t *testing.T) {

0 commit comments

Comments
 (0)