From 6732758d0f6974ecde5f04b104e2ebdf684e41b9 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Fri, 19 Feb 2021 16:08:43 -0500 Subject: [PATCH] Tweak mock ProveCommits to respect proof sizes --- api/test/tape.go | 4 +++- extern/sector-storage/mock/mock.go | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/api/test/tape.go b/api/test/tape.go index 466bdd829..5640ada6e 100644 --- a/api/test/tape.go +++ b/api/test/tape.go @@ -18,7 +18,9 @@ import ( ) func TestTapeFix(t *testing.T, b APIBuilder, blocktime time.Duration) { - t.Run("before", func(t *testing.T) { testTapeFix(t, b, blocktime, false) }) + // The "before" case is disabled, because we need the builder to mock 32 GiB sectors to accurately repro this case + // TODO: Make the mock sector size configurable and reenable this + //t.Run("before", func(t *testing.T) { testTapeFix(t, b, blocktime, false) }) t.Run("after", func(t *testing.T) { testTapeFix(t, b, blocktime, true) }) } func testTapeFix(t *testing.T, b APIBuilder, blocktime time.Duration, after bool) { diff --git a/extern/sector-storage/mock/mock.go b/extern/sector-storage/mock/mock.go index 9365ffb5c..82fce4b19 100644 --- a/extern/sector-storage/mock/mock.go +++ b/extern/sector-storage/mock/mock.go @@ -236,7 +236,12 @@ func (mgr *SectorMgr) SealCommit1(ctx context.Context, sid storage.SectorRef, ti } func (mgr *SectorMgr) SealCommit2(ctx context.Context, sid storage.SectorRef, phase1Out storage.Commit1Out) (proof storage.Proof, err error) { - var out [1920]byte + plen, err := sid.ProofType.ProofSize() + if err != nil { + return nil, err + } + + out := make([]byte, plen) for i := range out[:len(phase1Out)] { out[i] = phase1Out[i] ^ byte(sid.ID.Number&0xff) } @@ -464,7 +469,12 @@ func (mgr *SectorMgr) ReturnFetch(ctx context.Context, callID storiface.CallID, } func (m mockVerif) VerifySeal(svi proof2.SealVerifyInfo) (bool, error) { - if len(svi.Proof) != 1920 { + plen, err := svi.SealProof.ProofSize() + if err != nil { + return false, err + } + + if len(svi.Proof) != int(plen) { return false, nil }