fix: read lane state from chain as well as datastore

This commit is contained in:
Dirk McCormick 2020-09-15 20:06:33 +02:00
parent e2ecc35dff
commit 594ec8855c
4 changed files with 7 additions and 16 deletions

View File

@ -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"
@ -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}
}

View File

@ -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")

View File

@ -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)

View File

@ -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"
@ -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)
@ -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)