make test do something useful again
This commit is contained in:
parent
8e56fffb33
commit
028a5c4942
@ -76,18 +76,22 @@ func testSplitStore(t *testing.T, cfg *Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make some tipsets, but not enough to cause compaction
|
// make some tipsets, but not enough to cause compaction
|
||||||
mkBlock := func(curTs *types.TipSet, i int) *types.TipSet {
|
mkBlock := func(curTs *types.TipSet, i int, stateRoot blocks.Block) *types.TipSet {
|
||||||
blk := mock.MkBlock(curTs, uint64(i), uint64(i))
|
blk := mock.MkBlock(curTs, uint64(i), uint64(i))
|
||||||
|
|
||||||
blk.Messages = garbage.Cid()
|
blk.Messages = garbage.Cid()
|
||||||
blk.ParentMessageReceipts = garbage.Cid()
|
blk.ParentMessageReceipts = garbage.Cid()
|
||||||
blk.ParentStateRoot = garbage.Cid()
|
blk.ParentStateRoot = stateRoot.Cid()
|
||||||
blk.Timestamp = uint64(time.Now().Unix())
|
blk.Timestamp = uint64(time.Now().Unix())
|
||||||
|
|
||||||
sblk, err := blk.ToStorageBlock()
|
sblk, err := blk.ToStorageBlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
err = ss.Put(stateRoot)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
err = ss.Put(sblk)
|
err = ss.Put(sblk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -106,7 +110,8 @@ func testSplitStore(t *testing.T, cfg *Config) {
|
|||||||
|
|
||||||
curTs := genTs
|
curTs := genTs
|
||||||
for i := 1; i < 5; i++ {
|
for i := 1; i < 5; i++ {
|
||||||
curTs = mkBlock(curTs, i)
|
stateRoot := blocks.NewBlock([]byte{byte(i), 3, 3, 7})
|
||||||
|
curTs = mkBlock(curTs, i, stateRoot)
|
||||||
waitForCompaction()
|
waitForCompaction()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,25 +132,26 @@ func testSplitStore(t *testing.T, cfg *Config) {
|
|||||||
t.Errorf("expected %d blocks, but got %d", 2, coldCnt)
|
t.Errorf("expected %d blocks, but got %d", 2, coldCnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if hotCnt != 6 {
|
if hotCnt != 10 {
|
||||||
t.Errorf("expected %d blocks, but got %d", 6, hotCnt)
|
t.Errorf("expected %d blocks, but got %d", 10, hotCnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// trigger a compaction
|
// trigger a compaction
|
||||||
for i := 5; i < 10; i++ {
|
for i := 5; i < 10; i++ {
|
||||||
curTs = mkBlock(curTs, i)
|
stateRoot := blocks.NewBlock([]byte{byte(i), 3, 3, 7})
|
||||||
|
curTs = mkBlock(curTs, i, stateRoot)
|
||||||
waitForCompaction()
|
waitForCompaction()
|
||||||
}
|
}
|
||||||
|
|
||||||
coldCnt = countBlocks(cold)
|
coldCnt = countBlocks(cold)
|
||||||
hotCnt = countBlocks(hot)
|
hotCnt = countBlocks(hot)
|
||||||
|
|
||||||
if coldCnt != 2 {
|
if coldCnt != 5 {
|
||||||
t.Errorf("expected %d cold blocks, but got %d", 2, coldCnt)
|
t.Errorf("expected %d cold blocks, but got %d", 5, coldCnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if hotCnt != 11 {
|
if hotCnt != 17 {
|
||||||
t.Errorf("expected %d hot blocks, but got %d", 11, hotCnt)
|
t.Errorf("expected %d hot blocks, but got %d", 17, hotCnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we can revert without panicking.
|
// Make sure we can revert without panicking.
|
||||||
|
Loading…
Reference in New Issue
Block a user