fix: piece: Don't return StartEport in PieceDealInfo.EndEpoch (#11832)

This commit is contained in:
Łukasz Magiera 2024-04-04 23:16:34 +02:00 committed by GitHub
parent fd64e38b39
commit 37c24bba4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 1 deletions

View File

@ -147,7 +147,7 @@ func (ds *PieceDealInfo) EndEpoch() (abi.ChainEpoch, error) {
default: default:
// note - when implementing make sure to cache any dynamically computed values // note - when implementing make sure to cache any dynamically computed values
// todo do we want a smarter mechanism here // todo do we want a smarter mechanism here
return ds.DealSchedule.StartEpoch, nil return ds.DealSchedule.EndEpoch, nil
} }
} }

View File

@ -18,6 +18,7 @@ import (
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/dtypes"
@ -242,3 +243,37 @@ func TestMissingDealIsIgnored(t *testing.T) {
assert.Equal(t, 547300, int(exp)) assert.Equal(t, 547300, int(exp))
} }
func TestBasicPolicyDDO(t *testing.T) {
cfg := fakeConfigGetter(nil)
pcp := pipeline.NewBasicPreCommitPolicy(&fakeChain{
h: abi.ChainEpoch(55),
}, cfg, 0)
pieces := []pipeline.SafeSectorPiece{
pipeline.SafePiece(api.SectorPiece{
Piece: abi.PieceInfo{
Size: abi.PaddedPieceSize(1024),
PieceCID: fakePieceCid(t),
},
DealInfo: &piece.PieceDealInfo{
PublishCid: nil,
DealID: abi.DealID(44),
DealSchedule: piece.DealSchedule{
StartEpoch: abi.ChainEpoch(100_000),
EndEpoch: abi.ChainEpoch(1500_000),
},
PieceActivationManifest: &miner.PieceActivationManifest{
Size: 0,
VerifiedAllocationKey: nil,
Notify: nil,
},
},
}),
}
exp, err := pcp.Expiration(context.Background(), pieces...)
require.NoError(t, err)
assert.Equal(t, abi.ChainEpoch(1500_000), exp)
}