diff --git a/storagemarket/impl/providerstates/provider_states.go b/storagemarket/impl/providerstates/provider_states.go index 0bc539ba1..8f4c125c7 100644 --- a/storagemarket/impl/providerstates/provider_states.go +++ b/storagemarket/impl/providerstates/provider_states.go @@ -111,7 +111,7 @@ func ValidateDealProposal(ctx fsm.Context, environment ProviderDealEnvironment, // This doesn't guarantee that the client won't withdraw / lock those funds // but it's a decent first filter - if clientMarketBalance.Available.LessThan(proposal.TotalStorageFee()) { + if clientMarketBalance.Available.LessThan(proposal.ClientBalanceRequirement()) { return ctx.Trigger(storagemarket.ProviderEventDealRejected, xerrors.New("clientMarketBalance.Available too small")) } diff --git a/storagemarket/impl/providerstates/provider_states_test.go b/storagemarket/impl/providerstates/provider_states_test.go index d87bec3c4..68606d9cd 100644 --- a/storagemarket/impl/providerstates/provider_states_test.go +++ b/storagemarket/impl/providerstates/provider_states_test.go @@ -117,7 +117,19 @@ func TestValidateDealProposal(t *testing.T) { }, "Not enough funds": { nodeParams: nodeParams{ - ClientMarketBalance: abi.NewTokenAmount(150 * 10000), + ClientMarketBalance: big.NewInt(200*10000 - 1), + }, + dealInspector: func(t *testing.T, deal storagemarket.MinerDeal, env *fakeEnvironment) { + tut.AssertDealState(t, storagemarket.StorageDealRejecting, deal.State) + require.Equal(t, "deal rejected: clientMarketBalance.Available too small", deal.Message) + }, + }, + "Not enough funds due to client collateral": { + nodeParams: nodeParams{ + ClientMarketBalance: big.NewInt(200*10000 + 99), + }, + dealParams: dealParams{ + ClientCollateral: big.NewInt(100), }, dealInspector: func(t *testing.T, deal storagemarket.MinerDeal, env *fakeEnvironment) { tut.AssertDealState(t, storagemarket.StorageDealRejecting, deal.State) @@ -968,6 +980,7 @@ type dealParams struct { DataRef *storagemarket.DataRef StoragePricePerEpoch abi.TokenAmount ProviderCollateral abi.TokenAmount + ClientCollateral abi.TokenAmount PieceSize abi.PaddedPieceSize StartEpoch abi.ChainEpoch EndEpoch abi.ChainEpoch @@ -1081,6 +1094,9 @@ func makeExecutor(ctx context.Context, if !dealParams.ProviderCollateral.Nil() { proposal.ProviderCollateral = dealParams.ProviderCollateral } + if !dealParams.ClientCollateral.Nil() { + proposal.ClientCollateral = dealParams.ClientCollateral + } if dealParams.StartEpoch != abi.ChainEpoch(0) { proposal.StartEpoch = dealParams.StartEpoch }