Skip to content

Commit

Permalink
Merge branch 'master' into feat/retrieve-any-cid
Browse files Browse the repository at this point in the history
  • Loading branch information
masih committed Feb 23, 2022
2 parents 13b70d3 + f746f85 commit 59b99bf
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# go-fil-markets changelog

# go-fil-markets v1.19.1

- github.com/filecoin-project/go-fil-markets:
- feat(clientstates): handle payment chanel ready to go (#677) ([filecoin-project/go-fil-markets#677](https://github.com/filecoin-project/go-fil-markets/pull/677))
- release: v1.19.0 ([filecoin-project/go-fil-markets#672](https://github.com/filecoin-project/go-fil-markets/pull/672))

Contributors

| Contributor | Commits | Lines ± | Files Changed |
|-------------|---------|---------|---------------|
| Hannah Howard | 1 | +23/-5 | 6 |

# go-fil-markets v1.19.0

- github.com/filecoin-project/go-fil-markets:
Expand Down
1 change: 1 addition & 0 deletions docs/retrievalclient.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ stateDiagram-v2
DealStatusCheckFunds --> DealStatusPaymentChannelAddingFunds : ClientEventPaymentChannelAddingFunds
DealStatusPaymentChannelCreating --> DealStatusPaymentChannelAllocatingLane : ClientEventPaymentChannelReady
DealStatusPaymentChannelAddingFunds --> DealStatusOngoing : ClientEventPaymentChannelReady
DealStatusAccepted --> DealStatusPaymentChannelAllocatingLane : ClientEventPaymentChannelReady
DealStatusCheckFunds --> DealStatusOngoing : ClientEventPaymentChannelReady
DealStatusPaymentChannelAddingInitialFunds --> DealStatusPaymentChannelAllocatingLane : ClientEventPaymentChannelReady
DealStatusPaymentChannelAllocatingLane --> DealStatusFailing : ClientEventAllocateLaneErrored
Expand Down
Binary file modified docs/retrievalclient.mmd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/retrievalclient.mmd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions retrievalmarket/impl/clientstates/client_fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ var ClientEvents = fsm.Events{
// created for an earlier deal but the initial funding for this deal
// was being added, then we still need to allocate a payment channel
// lane
From(rm.DealStatusPaymentChannelCreating).To(rm.DealStatusPaymentChannelAllocatingLane).
From(rm.DealStatusPaymentChannelAddingInitialFunds).To(rm.DealStatusPaymentChannelAllocatingLane).
FromMany(rm.DealStatusPaymentChannelCreating, rm.DealStatusPaymentChannelAddingInitialFunds, rm.DealStatusAccepted).To(rm.DealStatusPaymentChannelAllocatingLane).
// If the payment channel ran out of funds and needed to be topped up,
// then the payment channel lane already exists so just move straight
// to the ongoing state
Expand Down
4 changes: 4 additions & 0 deletions retrievalmarket/impl/clientstates/client_states.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package clientstates
import (
"context"

"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p-core/peer"

Expand Down Expand Up @@ -59,6 +60,9 @@ func SetupPaymentChannelStart(ctx fsm.Context, environment ClientDealEnvironment
return ctx.Trigger(rm.ClientEventPaymentChannelCreateInitiated, msgCID)
}

if msgCID == cid.Undef {
return ctx.Trigger(rm.ClientEventPaymentChannelReady, paych)
}
return ctx.Trigger(rm.ClientEventPaymentChannelAddingFunds, msgCID, paych)
}

Expand Down
14 changes: 14 additions & 0 deletions retrievalmarket/impl/clientstates/client_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/rand"
"testing"

"github.com/ipfs/go-cid"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -141,6 +142,19 @@ func TestSetupPaymentChannel(t *testing.T) {
require.Equal(t, expectedPayCh, dealState.PaymentInfo.PayCh)
})

t.Run("payment channel fully ready", func(t *testing.T) {
envParams := testnodes.TestRetrievalClientNodeParams{
AddFundsOnly: true,
PayCh: expectedPayCh,
AddFundsCID: cid.Undef,
}
dealState := makeDealState(retrievalmarket.DealStatusAccepted)
runSetupPaymentChannel(t, envParams, dealState)
require.Empty(t, dealState.Message)
require.Equal(t, dealState.Status, retrievalmarket.DealStatusPaymentChannelAllocatingLane)
require.Equal(t, expectedPayCh, dealState.PaymentInfo.PayCh)
})

t.Run("when create payment channel fails", func(t *testing.T) {
dealState := makeDealState(retrievalmarket.DealStatusAccepted)
envParams := testnodes.TestRetrievalClientNodeParams{
Expand Down

0 comments on commit 59b99bf

Please sign in to comment.