Add test to check that bad winning post blocks are rejected
This commit is contained in:
parent
75b9fdc0a0
commit
78e7e59381
@ -361,6 +361,10 @@ func (cg *ChainGen) NextTipSet() (*MinedTipSet, error) {
|
|||||||
return mts, nil
|
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) {
|
func (cg *ChainGen) NextTipSetFromMiners(base *types.TipSet, miners []address.Address) (*MinedTipSet, error) {
|
||||||
var blks []*types.FullBlock
|
var blks []*types.FullBlock
|
||||||
|
|
||||||
|
@ -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) {
|
func (tu *syncTestUtil) loadChainToNode(to int) {
|
||||||
// utility to simulate incoming blocks without miner process
|
// utility to simulate incoming blocks without miner process
|
||||||
// TODO: should call syncer directly, this won't work correctly in all cases
|
// TODO: should call syncer directly, this won't work correctly in all cases
|
||||||
|
Loading…
Reference in New Issue
Block a user