Skip to content

Commit

Permalink
Stop using the pinning option as a default (#276)
Browse files Browse the repository at this point in the history
* change test to stop pinning and use the max square size

* remove pinning from the default block proposal

* remove the pinning option from the get leaf test
  • Loading branch information
evan-forbes authored Apr 9, 2021
1 parent 2b2ce8a commit 2c90de4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ func (cs *State) defaultDecideProposal(height int64, round int32) {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*1500)
defer cancel()
// TODO: post data to IPFS in a goroutine
err := block.PutBlock(ctx, cs.IpfsAPI.Dag().Pinning())
err := block.PutBlock(ctx, cs.IpfsAPI.Dag())
if err != nil {
cs.Logger.Error(fmt.Sprintf("failure to post block data to IPFS: %s", err.Error()))
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/ipld/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestGetLeafData(t *testing.T) {

// create the context and batch needed for node collection from the tree
ctx := context.Background()
batch := format.NewBatch(ctx, ipfsAPI.Dag().Pinning())
batch := format.NewBatch(ctx, ipfsAPI.Dag())

// generate random data for the nmt
data := generateRandNamespacedRawData(16, types.NamespaceSize, types.ShareSize)
Expand Down
17 changes: 5 additions & 12 deletions types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
gogotypes "github.com/gogo/protobuf/types"
coreapi "github.com/ipfs/go-ipfs/core/coreapi"
coremock "github.com/ipfs/go-ipfs/core/mock"
"github.com/ipfs/interface-go-ipfs-core/path"
"github.com/lazyledger/lazyledger-core/p2p/ipld/plugin/nodes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1340,6 +1339,9 @@ func TestPutBlock(t *testing.T) {
t.Error(err)
}

maxOriginalSquareSize := MaxSquareSize / 2
maxShareCount := maxOriginalSquareSize * maxOriginalSquareSize

testCases := []struct {
name string
blockData Data
Expand All @@ -1349,7 +1351,7 @@ func TestPutBlock(t *testing.T) {
{"no leaves", generateRandomMsgOnlyData(0), false, ""},
{"single leaf", generateRandomMsgOnlyData(1), false, ""},
{"16 leaves", generateRandomMsgOnlyData(16), false, ""},
{"max square size", generateRandomMsgOnlyData(MaxSquareSize), false, ""},
{"max square size", generateRandomMsgOnlyData(maxShareCount), false, ""},
}
ctx := context.Background()
for _, tc := range testCases {
Expand All @@ -1358,7 +1360,7 @@ func TestPutBlock(t *testing.T) {
block := &Block{Data: tc.blockData}

t.Run(tc.name, func(t *testing.T) {
err = block.PutBlock(ctx, ipfsAPI.Dag().Pinning())
err = block.PutBlock(ctx, ipfsAPI.Dag())
if tc.expectErr {
require.Error(t, err)
require.Contains(t, err.Error(), tc.errString)
Expand All @@ -1378,15 +1380,6 @@ func TestPutBlock(t *testing.T) {
t.Error(err)
}

// check if cid was successfully pinned to IPFS
_, pinned, err := ipfsAPI.Pin().IsPinned(ctx, path.IpldPath(cid))
if err != nil {
t.Error(err)
}
if !pinned {
t.Errorf("failure to pin cid %s to IPFS", cid.String())
}

// retrieve the data from IPFS
_, err = ipfsAPI.Dag().Get(timeoutCtx, cid)
if err != nil {
Expand Down

0 comments on commit 2c90de4

Please sign in to comment.