diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 206b6c8cf..01b874f92 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -361,6 +361,10 @@ func (cg *ChainGen) NextTipSet() (*MinedTipSet, error) { return mts, nil } +func (cg *ChainGen) SetWinningPoStProver(m address.Address, wpp WinningPoStProver) { + cg.eppProvs[m] = wpp +} + func (cg *ChainGen) NextTipSetFromMiners(base *types.TipSet, miners []address.Address) (*MinedTipSet, error) { var blks []*types.FullBlock diff --git a/chain/sync_test.go b/chain/sync_test.go index efb601041..bf06f908b 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -433,6 +433,42 @@ func TestSyncBadTimestamp(t *testing.T) { } } +type badWpp struct{} + +func (wpp badWpp) GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error) { + return []uint64{1}, nil +} + +func (wpp badWpp) ComputeProof(context.Context, []abi.SectorInfo, abi.PoStRandomness) ([]abi.PoStProof, error) { + return []abi.PoStProof{ + abi.PoStProof{ + PoStProof: abi.RegisteredPoStProof_StackedDrgWinning2KiBV1, + ProofBytes: []byte("evil"), + }, + }, nil +} + +func TestSyncBadWinningPoSt(t *testing.T) { + H := 10 + tu := prepSyncTest(t, H) + + client := tu.addClientNode() + + require.NoError(t, tu.mn.LinkAll()) + tu.connect(client, 0) + tu.waitUntilSync(0, client) + + base := tu.g.CurTipset + + tu.g.SetWinningPoStProver(tu.g.Miners[0], &badWpp{}) + tu.g.SetWinningPoStProver(tu.g.Miners[1], &badWpp{}) + a1 := tu.mineOnBlock(base, 0, nil, false, true) + + fmt.Println(a1) + + t.Fatal("WIP: TODO") +} + func (tu *syncTestUtil) loadChainToNode(to int) { // utility to simulate incoming blocks without miner process // TODO: should call syncer directly, this won't work correctly in all cases