Skip to content

Commit 88b2b12

Browse files
committed
optimize unit test
1 parent 3a8bd37 commit 88b2b12

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

ledger/chain/chain_test.go

+4-17
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,6 @@ func TestCheckHash2(t *testing.T) {
326326
func TestChainForkRollBack(t *testing.T) {
327327
c, accountMap, _ := SetUp(t, 3, 100, 2)
328328
curSnapshotBlock := c.GetLatestSnapshotBlock()
329-
fmt.Println(curSnapshotBlock.Height)
330-
TearDown(c)
331-
332-
// height
333-
height := uint64(30)
334-
upgrade.CleanupUpgradeBox()
335-
upgrade.InitUpgradeBox(upgrade.NewEmptyUpgradeBox().AddPoint(1, height))
336-
337-
c, accountMap, _ = SetUp(t, 10, 0, 0)
338329

339330
defer func() {
340331
TearDown(c)
@@ -343,12 +334,8 @@ func TestChainForkRollBack(t *testing.T) {
343334
}
344335
}()
345336

346-
curSnapshotBlocknew := c.GetLatestSnapshotBlock()
347-
348-
fmt.Println(curSnapshotBlocknew.Height, curSnapshotBlocknew.Height == height-1)
349-
if curSnapshotBlocknew.Height != height-1 {
350-
t.Fatal(fmt.Sprintf("not equal %+v, %d", curSnapshotBlocknew, height-1))
351-
}
337+
upgrade.CleanupUpgradeBox()
338+
upgrade.InitUpgradeBox(upgrade.NewEmptyUpgradeBox().AddPoint(1, curSnapshotBlock.Height+1))
352339

353340
InsertAccountBlocks(nil, c, accountMap, 5)
354341

@@ -377,8 +364,8 @@ func TestChainForkRollBack(t *testing.T) {
377364
return sc
378365
}
379366
sb := &ledger.SnapshotBlock{
380-
PrevHash: curSnapshotBlocknew.Hash,
381-
Height: curSnapshotBlocknew.Height + 1,
367+
PrevHash: curSnapshotBlock.Hash,
368+
Height: curSnapshotBlock.Height + 1,
382369
Timestamp: &timeNow,
383370
SnapshotContent: createSnaoshotContent(),
384371
}

producer/producer_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func TestSnapshot(t *testing.T) {
4747

4848
helper.ErrFailf(t, err, "random account err")
4949

50-
sv := verifier.NewSnapshotVerifier(c, cs)
50+
// sv := verifier.NewSnapshotVerifier(c, cs)
5151
av := verifier.NewVerifier(c).Init(cs, cs.SBPReader(), nil)
5252
p := NewProducer(c, net.Mock(c), coinbase, cs, p1)
5353

54-
p1.Init(net.Mock(c), sv, av, cs.SBPReader().GetPeriodTimeIndex(), cs.SBPReader().GetNodeCount())
54+
p1.Init(net.Mock(c), av, cs.SBPReader())
5555
p.Init()
5656

5757
address := coinbase.Address()
@@ -94,13 +94,13 @@ func TestProducer_Init(t *testing.T) {
9494
p1, _ := pool.NewPool(c)
9595
coinbase, _ := wallet.RandomAccount()
9696
cs := genConsensus(c, p1, t)
97-
sv := verifier.NewSnapshotVerifier(c, cs)
97+
// sv := verifier.NewSnapshotVerifier(c, cs)
9898
av := verifier.NewVerifier(c).Init(cs, cs.SBPReader(), nil)
9999
p := NewProducer(c, net.Mock(c), coinbase, cs, p1)
100100

101101
c.Start()
102102

103-
p1.Init(net.Mock(c), sv, av, cs.SBPReader().GetPeriodTimeIndex(), cs.SBPReader().GetNodeCount())
103+
p1.Init(net.Mock(c), av, cs.SBPReader())
104104
p.Init()
105105
p1.Start()
106106
p.Start()

0 commit comments

Comments
 (0)