Skip to content

Commit

Permalink
fix: Ignore stream close error in ProposeDeal (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k authored May 30, 2023
1 parent 9331225 commit 62ac6f5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
3 changes: 1 addition & 2 deletions shared_testutil/test_network_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ type TestStorageDealStream struct {
responseWriter StorageDealResponseWriter

CloseCount int
CloseError error
}

// TestStorageDealStreamParams are parameters used to setup a TestStorageDealStream.
Expand Down Expand Up @@ -485,7 +484,7 @@ func (tsds TestStorageDealStream) RemotePeer() peer.ID { return tsds.p }
// Close closes the stream (does nothing for mocked stream)
func (tsds *TestStorageDealStream) Close() error {
tsds.CloseCount += 1
return tsds.CloseError
return nil
}

// TrivialStorageDealProposalReader succeeds trivially, returning an empty proposal.
Expand Down
3 changes: 2 additions & 1 deletion storagemarket/impl/clientstates/client_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func ProposeDeal(ctx fsm.Context, environment ClientDealEnvironment, deal storag

err = s.Close()
if err != nil {
return ctx.Trigger(storagemarket.ClientEventStreamCloseError, err)
// doesn't really matter but log the error
log.Debugw("failed to close deal stream", "error", err)
}

tok, _, err := environment.Node().GetChainHead(ctx.Context())
Expand Down
11 changes: 0 additions & 11 deletions storagemarket/impl/clientstates/client_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,6 @@ func TestProposeDeal(t *testing.T) {
},
})
})
t.Run("closing the stream fails", func(t *testing.T) {
ds := tut.NewTestStorageDealStream(tut.TestStorageDealStreamParams{})
ds.CloseError = xerrors.Errorf("failed to close stream")
runAndInspect(t, storagemarket.StorageDealFundsReserved, clientstates.ProposeDeal, testCase{
envParams: envParams{dealStream: ds},
inspector: func(deal storagemarket.ClientDeal, env *fakeEnvironment) {
tut.AssertDealState(t, storagemarket.StorageDealError, deal.State)
assert.Equal(t, "error attempting to close stream: failed to close stream", deal.Message)
},
})
})
t.Run("getting chain head fails", func(t *testing.T) {
ds := tut.NewTestStorageDealStream(tut.TestStorageDealStreamParams{})
runAndInspect(t, storagemarket.StorageDealFundsReserved, clientstates.ProposeDeal, testCase{
Expand Down

0 comments on commit 62ac6f5

Please sign in to comment.