Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
add docs to PutBlock
  • Loading branch information
evan-forbes committed Mar 10, 2021
1 parent 06f639e commit 5b9ebda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ func mustPush(rowTree *nmt.NamespacedMerkleTree, id namespace.ID, data []byte) {
}
}

// PutBlock add
// PutBlock posts and pins erasured block data to IPFS using the provided
// ipld.NodeAdder. Note: the erasured data is currently recomputed
func (b *Block) PutBlock(ctx context.Context, api format.NodeAdder) error {
if api == nil {
return errors.New("no ipfs node adder provided")
Expand Down
5 changes: 4 additions & 1 deletion types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,10 @@ func TestPutBlock(t *testing.T) {
expectErr bool
errString string
}{
{"basic", generateRandomData(16), false, ""},
{"no leaves", generateRandomData(0), false, ""},
{"single leaf", generateRandomData(1), false, ""},
{"16 leaves", generateRandomData(16), false, ""},
{"max square size", generateRandomData(MaxSquareSize), false, ""},
}
ctx := context.Background()
for _, tc := range testCases {
Expand Down

0 comments on commit 5b9ebda

Please sign in to comment.