From 95f344540ec6ce0f6c2be4394f444e49c7d1f291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 31 Jan 2020 02:27:38 +0100 Subject: [PATCH] Fix tests --- cmd/lotus-storage-miner/info.go | 4 ++-- node/node_test.go | 2 +- storage/sbmock/sbmock.go | 4 ++-- storage/sealing/fsm_test.go | 6 ++++++ storage/sealing/utils.go | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 6ad4b08ba..e1b4f4b32 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -67,9 +67,9 @@ var infoCmd = &cli.Command{ fmt.Printf("\tProving: %s\n", types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(sizeByte)).SizeStr()) } else { fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n", - types.BigMul(types.NewInt(secCounts.Pset - uint64(len(faults))), types.NewInt(sizeByte)).SizeStr(), + types.BigMul(types.NewInt(secCounts.Pset-uint64(len(faults))), types.NewInt(sizeByte)).SizeStr(), types.BigMul(types.NewInt(uint64(len(faults))), types.NewInt(sizeByte)).SizeStr(), - float64(10000 * uint64(len(faults)) / secCounts.Pset) / 100.) + float64(10000*uint64(len(faults))/secCounts.Pset)/100.) } // TODO: indicate whether the post worker is in use diff --git a/node/node_test.go b/node/node_test.go index b9c1f778e..0ac3a17ab 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -232,7 +232,7 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te SectorSize: 1024, WorkerThreads: 2, Miner: genMiner, - Dir: psd, + Paths: sectorbuilder.SimplePath(psd), }, namespace.Wrap(mds, datastore.NewKey("/sectorbuilder"))) if err != nil { t.Fatal(err) diff --git a/storage/sbmock/sbmock.go b/storage/sbmock/sbmock.go index 7f28e4290..4d88853f5 100644 --- a/storage/sbmock/sbmock.go +++ b/storage/sbmock/sbmock.go @@ -311,11 +311,11 @@ func (sb *SBMock) StageFakeData() (uint64, []sectorbuilder.PublicPieceInfo, erro } func (sb *SBMock) FinalizeSector(context.Context, uint64) error { - panic("implement me") + return nil } func (sb *SBMock) DropStaged(context.Context, uint64) error { - panic("implement me") + return nil } func (sb *SBMock) SectorPath(typ fs.DataType, sectorID uint64) (fs.SectorPath, error) { diff --git a/storage/sealing/fsm_test.go b/storage/sealing/fsm_test.go index 7430bb634..24145a2a1 100644 --- a/storage/sealing/fsm_test.go +++ b/storage/sealing/fsm_test.go @@ -50,6 +50,9 @@ func TestHappyPath(t *testing.T) { require.Equal(m.t, m.state.State, api.CommitWait) m.planSingle(SectorProving{}) + require.Equal(m.t, m.state.State, api.FinalizeSector) + + m.planSingle(SectorFinalized{}) require.Equal(m.t, m.state.State, api.Proving) } @@ -81,6 +84,9 @@ func TestSeedRevert(t *testing.T) { require.Equal(m.t, m.state.State, api.CommitWait) m.planSingle(SectorProving{}) + require.Equal(m.t, m.state.State, api.FinalizeSector) + + m.planSingle(SectorFinalized{}) require.Equal(m.t, m.state.State, api.Proving) } diff --git a/storage/sealing/utils.go b/storage/sealing/utils.go index f317301ba..b2221b278 100644 --- a/storage/sealing/utils.go +++ b/storage/sealing/utils.go @@ -49,11 +49,11 @@ func fillersFromRem(toFill uint64) ([]uint64, error) { func (m *Sealing) fastPledgeCommitment(size uint64, parts uint64) (commP [sectorbuilder.CommLen]byte, err error) { parts = 1 << bits.Len64(parts) // round down to nearest power of 2 - if size / parts < 127 { + if size/parts < 127 { parts = size / 127 } - piece := sectorbuilder.UserBytesForSectorSize((size + size / 127) / parts) + piece := sectorbuilder.UserBytesForSectorSize((size + size/127) / parts) out := make([]sectorbuilder.PublicPieceInfo, parts) var lk sync.Mutex