Created
February 6, 2020 15:48
-
-
Save igor-egorov/243d29bb0bcecb26891c62edd53bdf42 to your computer and use it in GitHub Desktop.
empty cid array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package adt_test | |
import ( | |
"context" | |
"encoding/hex" | |
"fmt" | |
"github.com/filecoin-project/specs-actors/actors/util/adt" | |
block "github.com/ipfs/go-block-format" | |
cid "github.com/ipfs/go-cid" | |
cbor "github.com/ipfs/go-ipld-cbor" | |
"testing" | |
) | |
type mockBlocks struct { | |
data map[cid.Cid]block.Block | |
} | |
func newMockBlocks() *mockBlocks { | |
return &mockBlocks{make(map[cid.Cid]block.Block)} | |
} | |
func (mb *mockBlocks) Get(c cid.Cid) (block.Block, error) { | |
d, ok := mb.data[c] | |
if ok { | |
return d, nil | |
} | |
return nil, fmt.Errorf("Not Found") | |
} | |
func (mb *mockBlocks) Put(b block.Block) error { | |
mb.data[b.Cid()] = b | |
return nil | |
} | |
type aaa struct { | |
cbor.BasicIpldStore | |
} | |
func (mb *aaa) Context() context.Context { | |
return context.Background() | |
} | |
func Test(t *testing.T) { | |
var arr, _ = adt.MakeEmptyArray(&aaa{*cbor.NewCborStore(newMockBlocks())}) | |
root := arr.Root() | |
fmt.Printf("%v\n", hex.EncodeToString(root.Bytes())) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment