github.com/ethersphere/bee/v2@v2.2.0/pkg/storer/internal/stampindex/export_test.go (about) 1 // Copyright 2023 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package stampindex 6 7 import "github.com/ethersphere/bee/v2/pkg/swarm" 8 9 var ( 10 ErrStampItemMarshalNamespaceInvalid = errStampItemMarshalScopeInvalid 11 ErrStampItemMarshalBatchIndexInvalid = errStampItemMarshalBatchIndexInvalid 12 ErrStampItemMarshalBatchIDInvalid = errStampItemMarshalBatchIDInvalid 13 ErrStampItemUnmarshalInvalidSize = errStampItemUnmarshalInvalidSize 14 ) 15 16 // NewItemWithValues creates a new Item with given values and fixed keys. 17 func NewItemWithValues(batchTimestamp []byte, chunkAddress swarm.Address) *Item { 18 return &Item{ 19 scope: []byte("test_namespace"), 20 BatchID: []byte{swarm.HashSize - 1: 9}, 21 StampIndex: []byte{swarm.StampIndexSize - 1: 9}, 22 StampHash: swarm.EmptyAddress.Bytes(), 23 24 StampTimestamp: batchTimestamp, 25 ChunkAddress: chunkAddress, 26 } 27 } 28 29 // NewItemWithKeys creates a new Item with given keys and zero values. 30 func NewItemWithKeys(namespace string, batchID, batchIndex, stampHash []byte) *Item { 31 return &Item{ 32 scope: append([]byte(nil), namespace...), 33 BatchID: batchID, 34 StampIndex: batchIndex, 35 StampHash: stampHash, 36 } 37 }