2023-04-20 15:53:37 +00:00
|
|
|
package internal
|
2023-03-05 07:33:51 +00:00
|
|
|
|
|
|
|
import (
|
2023-04-25 09:14:04 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
pgipfsethdb "github.com/cerc-io/ipfs-ethdb/v5/postgres/v0"
|
2023-03-05 07:33:51 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
"github.com/multiformats/go-multihash"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Keccak256ToCid(codec uint64, h []byte) (cid.Cid, error) {
|
|
|
|
buf, err := multihash.Encode(h, multihash.KECCAK_256)
|
|
|
|
if err != nil {
|
|
|
|
return cid.Cid{}, err
|
|
|
|
}
|
|
|
|
return cid.NewCidV1(codec, buf), nil
|
|
|
|
}
|
2023-04-25 09:14:04 +00:00
|
|
|
|
|
|
|
// returns a cache config with unique name (groupcache names are global)
|
|
|
|
func MakeCacheConfig(t testing.TB) pgipfsethdb.CacheConfig {
|
|
|
|
return pgipfsethdb.CacheConfig{
|
|
|
|
Name: t.Name(),
|
|
|
|
Size: 3000000, // 3MB
|
|
|
|
ExpiryDuration: time.Hour,
|
|
|
|
}
|
|
|
|
}
|