Skip to content

Commit

Permalink
fix(rebase): fix issues after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahhoward committed Jun 3, 2022
1 parent f90542e commit 4478974
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 36 deletions.
11 changes: 5 additions & 6 deletions impl/initiating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func TestDataTransferInitiating(t *testing.T) {
events: make(chan datatransfer.EventCode, len(verify.expectedEvents)),
}
ev.setup(t, dt)
h.stor = h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.voucher = testutil.NewTestTypedVoucher()
h.voucherResult = testutil.NewTestTypedVoucher()
require.NoError(t, err)
Expand Down Expand Up @@ -581,11 +581,10 @@ func TestDataTransferRestartInitiating(t *testing.T) {
ev.setup(t, dt)

// setup voucher processing
h.stor = testutil.AllSelector()
h.voucher = testutil.NewFakeDTType()
require.NoError(t, h.dt.RegisterVoucherType(h.voucher, h.voucherValidator))
h.voucherResult = testutil.NewFakeDTType()
err = h.dt.RegisterVoucherResultType(h.voucherResult)
h.stor = selectorparse.CommonSelector_ExploreAllRecursively
h.voucher = testutil.NewTestTypedVoucher()
require.NoError(t, h.dt.RegisterVoucherType(h.voucher.Type, h.voucherValidator))
h.voucherResult = testutil.NewTestTypedVoucher()
require.NoError(t, err)
h.baseCid = testutil.GenerateCids(1)[0]

Expand Down
1 change: 0 additions & 1 deletion itest/gstestdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/ipfs/go-unixfs/importer/balanced"
ihelper "github.com/ipfs/go-unixfs/importer/helpers"
"github.com/ipld/go-ipld-prime"
"github.com/ipld/go-ipld-prime/datamodel"
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/protocol"
Expand Down
4 changes: 2 additions & 2 deletions itest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,10 @@ func TestAutoRestartAfterBouncingInitiator(t *testing.T) {
var chid datatransfer.ChannelID
if isPush {
// Open a push channel
chid, err = initiator.OpenPushDataChannel(ctx, responderHost.ID(), &voucher, rootCid, gsData.AllSelector)
chid, err = initiator.OpenPushDataChannel(ctx, responderHost.ID(), voucher, rootCid, selectorparse.CommonSelector_ExploreAllRecursively)
} else {
// Open a pull channel
chid, err = initiator.OpenPullDataChannel(ctx, responderHost.ID(), &voucher, rootCid, gsData.AllSelector)
chid, err = initiator.OpenPullDataChannel(ctx, responderHost.ID(), voucher, rootCid, selectorparse.CommonSelector_ExploreAllRecursively)
}
require.NoError(t, err)

Expand Down
6 changes: 2 additions & 4 deletions message/message1_1prime/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,11 @@ func fromMessage(tresp *TransferMessage1_1) (datatransfer.Message, error) {

// FromNetWrraped can read a network stream to deserialize a message + transport ID
func FromNetWrapped(r io.Reader) (datatransfer.TransportID, datatransfer.Message, error) {
builder := Prototype.WrappedTransferMessage.Representation().NewBuilder()
err := dagcbor.Decode(builder, r)
tm, err := ipldutils.FromReader(r, &WrappedTransferMessage1_1{})
if err != nil {
return "", nil, err
}
node := builder.Build()
wtresp := bindnode.Unwrap(node).(*WrappedTransferMessage1_1)
wtresp := tm.(*WrappedTransferMessage1_1)
msg, err := fromMessage(&wtresp.Message)
return datatransfer.TransportID(wtresp.TransportID), msg, err
}
Expand Down
12 changes: 6 additions & 6 deletions message/message1_1prime/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ func TestToNetFromNetEquivalency(t *testing.T) {
isPull := false
id := datatransfer.TransferID(rand.Int31())
accepted := false
voucher := testutil.NewFakeDTType()
voucherResult := testutil.NewFakeDTType()
request, err := message1_1.NewRequest(id, false, isPull, voucher.Type(), voucher, baseCid, selector)
voucher := testutil.NewTestTypedVoucher()
voucherResult := testutil.NewTestTypedVoucher()
request, err := message1_1.NewRequest(id, false, isPull, &voucher, baseCid, selector)
require.NoError(t, err)
wrequest := request.WrappedForTransport(transportID)
buf := new(bytes.Buffer)
Expand All @@ -536,10 +536,10 @@ func TestToNetFromNetEquivalency(t *testing.T) {
require.Equal(t, deserializedRequest.IsPull(), request.IsPull())
require.Equal(t, deserializedRequest.IsRequest(), request.IsRequest())
require.Equal(t, deserializedRequest.BaseCid(), request.BaseCid())
testutil.AssertEqualFakeDTVoucher(t, request, deserializedRequest)
testutil.AssertEqualTestVoucher(t, request, deserializedRequest)
testutil.AssertEqualSelector(t, request, deserializedRequest)

response, err := message1_1.NewResponse(id, accepted, false, voucherResult.Type(), voucherResult)
response, err := message1_1.NewResponse(id, accepted, false, &voucherResult)
require.NoError(t, err)
wresponse := response.WrappedForTransport(transportID)
err = wresponse.ToNet(buf)
Expand All @@ -556,7 +556,7 @@ func TestToNetFromNetEquivalency(t *testing.T) {
require.Equal(t, deserializedResponse.IsRequest(), response.IsRequest())
require.Equal(t, deserializedResponse.IsUpdate(), response.IsUpdate())
require.Equal(t, deserializedResponse.IsPaused(), response.IsPaused())
testutil.AssertEqualFakeDTVoucherResult(t, response, deserializedResponse)
testutil.AssertEqualTestVoucherResult(t, response, deserializedResponse)

request = message1_1.CancelRequest(id)
wrequest = request.WrappedForTransport(transportID)
Expand Down
4 changes: 2 additions & 2 deletions message/message1_1prime/schema.ipldsch
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type TransferMessage1_1 struct {
Response nullable TransferResponse
}

type WrappedTransferMessage struct {
type WrappedTransferMessage1_1 struct {
TransportID TransportID (rename "ID")
Message TransferMessage (rename "Msg")
Message TransferMessage1_1 (rename "Msg")
}
8 changes: 6 additions & 2 deletions message/message1_1prime/transfer_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type WrappedTransferMessage1_1 struct {
Message TransferMessage1_1
}

func (wtm *WrappedTransferMessage1_1) toIPLD() schema.TypedNode {
return bindnode.Wrap(&wtm, Prototype.WrappedTransferMessage.Type())
func (wtm *WrappedTransferMessage1_1) BindnodeSchema() string {
return string(embedSchema)
}

func (wtm *WrappedTransferMessage1_1) toIPLD() (schema.TypedNode, error) {
return ipldutils.ToNode(wtm)
}
14 changes: 11 additions & 3 deletions message/message1_1prime/transfer_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type WrappedTransferRequest1_1 struct {
TransportID string
}

func (trsp *WrappedTransferRequest1_1) toIPLD() schema.TypedNode {
func (trsp *WrappedTransferRequest1_1) toIPLD() (schema.TypedNode, error) {
msg := WrappedTransferMessage1_1{
TransportID: trsp.TransportID,
Message: TransferMessage1_1{
Expand All @@ -187,9 +187,17 @@ func (trsp *WrappedTransferRequest1_1) toIPLD() schema.TypedNode {
}

func (trq *WrappedTransferRequest1_1) ToIPLD() (datamodel.Node, error) {
return trq.toIPLD().Representation(), nil
msg, err := trq.toIPLD()
if err != nil {
return nil, err
}
return msg.Representation(), nil
}

func (trq *WrappedTransferRequest1_1) ToNet(w io.Writer) error {
return dagcbor.Encode(trq.toIPLD().Representation(), w)
i, err := trq.toIPLD()
if err != nil {
return err
}
return ipldutils.NodeToWriter(i, w)
}
17 changes: 8 additions & 9 deletions message/message1_1prime/transfer_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (trsp *TransferResponse1_1) MessageForVersion(version datatransfer.MessageV
}

func (trsp *TransferResponse1_1) WrappedForTransport(transportID datatransfer.TransportID) datatransfer.Message {
return &WrappedTransferRepsponse1_1{trsp, string(transportID)}
return &WrappedTransferResponse1_1{trsp, string(transportID)}
}
func (trsp *TransferResponse1_1) toIPLD() (schema.TypedNode, error) {
msg := TransferMessage1_1{
Expand Down Expand Up @@ -124,14 +124,14 @@ func (trsp *TransferResponse1_1) ToNet(w io.Writer) error {
return ipldutils.NodeToWriter(i, w)
}

// WrappedTransferRepsponse1_1 is used to serialize a response along with a
// WrappedTransferResponse1_1 is used to serialize a response along with a
// transport id
type WrappedTransferRepsponse1_1 struct {
type WrappedTransferResponse1_1 struct {
*TransferResponse1_1
TransportID string
}

func (trsp *WrappedTransferRepsponse1_1) toIPLD() (schema.TypedNode, error) {
func (trsp *WrappedTransferResponse1_1) toIPLD() (schema.TypedNode, error) {
msg := WrappedTransferMessage1_1{
TransportID: trsp.TransportID,
Message: TransferMessage1_1{
Expand All @@ -143,19 +143,18 @@ func (trsp *WrappedTransferRepsponse1_1) toIPLD() (schema.TypedNode, error) {
return msg.toIPLD()
}

func (trq *WrappedTransferRepsponse1_1) ToIPLD() (datamodel.Node, error) {
func (trsp *WrappedTransferResponse1_1) ToIPLD() (datamodel.Node, error) {
msg, err := trsp.toIPLD()
if err != nil {
return err
return nil, err
}
return msg.Representation(), nil
}

func (trq *WrappedTransferRepsponse1_1) ToNet(w io.Writer) error {
func (trsp *WrappedTransferResponse1_1) ToNet(w io.Writer) error {
msg, err := trsp.toIPLD()
if err != nil {
return err
}
return ipldutils.NodeToWriter(i, w)
return ipldutils.NodeToWriter(msg, w)
}

2 changes: 1 addition & 1 deletion message/message1_1prime/transfer_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestResponseMessageForVersion(t *testing.T) {
require.True(t, resp.IsValidationResult())

wrappedOut := out.WrappedForTransport(datatransfer.LegacyTransportID)
require.Equal(t, &message1_1.WrappedTransferRepsponse1_1{
require.Equal(t, &message1_1.WrappedTransferResponse1_1{
TransferResponse1_1: response.(*message1_1.TransferResponse1_1),
TransportID: string(datatransfer.LegacyTransportID),
}, wrappedOut)
Expand Down

0 comments on commit 4478974

Please sign in to comment.