Skip to content

Commit

Permalink
fix: read lane state from chain as well as datastore
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc committed Oct 1, 2020
1 parent e2ecc35 commit 594ec88
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion paychmgr/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/crypto"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -56,7 +57,6 @@ func (sm *mockStateManager) setAccountAddress(a address.Address, lookup address.
func (sm *mockStateManager) setPaychState(a address.Address, actor *types.Actor, state paych.State) {
sm.lk.Lock()
defer sm.lk.Unlock()

sm.paychState[a] = mockPchState{actor, state}
}

Expand Down
3 changes: 0 additions & 3 deletions paychmgr/paych.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,6 @@ func (ca *channelAccessor) laneState(state paych.State, ch address.Address) (map
return nil, err
}

// Note: we use a map instead of an array to store laneStates because the
// client sets the lane ID (the index) and potentially they could use a
// very large index.
for _, v := range vouchers {
for range v.Voucher.Merges {
return nil, xerrors.Errorf("paych merges not handled yet")
Expand Down
2 changes: 0 additions & 2 deletions paychmgr/paych_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,6 @@ func testSetupMgrWithChannel(t *testing.T) *testScaffold {
mock := newMockManagerAPI()
mock.setAccountAddress(fromAcct, from)
mock.setAccountAddress(toAcct, to)
//mock.setAccountState(fromAcct, account.State{Address: from})
//mock.setAccountState(toAcct, account.State{Address: to})

// Create channel in state
balance := big.NewInt(20)
Expand Down
16 changes: 6 additions & 10 deletions paychmgr/paychvoucherfunds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"testing"

"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
paychmock "github.com/filecoin-project/lotus/chain/actors/builtin/paych/mock"

"github.com/filecoin-project/lotus/chain/types"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
tutils "github.com/filecoin-project/specs-actors/support/testing"
"github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore"
Expand All @@ -36,8 +37,8 @@ func TestPaychAddVoucherAfterAddFunds(t *testing.T) {
defer mock.close()

// Add the from signing key to the wallet
mock.setAccountState(fromAcct, account.State{Address: from})
mock.setAccountState(toAcct, account.State{Address: to})
mock.setAccountAddress(fromAcct, from)
mock.setAccountAddress(toAcct, to)
mock.addSigningKey(fromKeyPrivate)

mgr, err := newManager(store, mock)
Expand All @@ -59,12 +60,7 @@ func TestPaychAddVoucherAfterAddFunds(t *testing.T) {
Nonce: 0,
Balance: createAmt,
}
mock.setPaychState(ch, act, paych.State{
From: fromAcct,
To: toAcct,
SettlingAt: abi.ChainEpoch(0),
MinSettleHeight: abi.ChainEpoch(0),
})
mock.setPaychState(ch, act, paychmock.NewMockPayChState(fromAcct, toAcct, abi.ChainEpoch(0), make(map[uint64]paych.LaneState)))

// Wait for create response to be processed by manager
_, err = mgr.GetPaychWaitReady(ctx, createMsgCid)
Expand Down

0 comments on commit 594ec88

Please sign in to comment.