fdlkjsjkldsfhjkds

This commit is contained in:
Elichai Turkel 2021-01-19 11:43:13 +02:00
parent 799eb7515c
commit 84f8a19b98
No known key found for this signature in database
GPG Key ID: 9383CDE9E8E66A7F

View File

@ -58,6 +58,17 @@ func TestValidateAndInsertPruningPoint(t *testing.T) {
return consensushashing.BlockHash(block) return consensushashing.BlockHash(block)
} }
// make 2 blocks on the side.
side, _, err := tcSyncee.AddBlock([]*externalapi.DomainHash{params.GenesisHash}, &externalapi.DomainCoinbaseData{ScriptPublicKey: &externalapi.ScriptPublicKey{}, ExtraData: []byte{1,2}}, nil)
if err != nil {
t.Fatal(err)
}
// make 2 blocks on the side.
_, _, err = tcSyncee.AddBlock([]*externalapi.DomainHash{side}, nil, nil)
if err != nil {
t.Fatal(err)
}
tipHash := params.GenesisHash tipHash := params.GenesisHash
for i := 0; i < finalityDepth-2; i++ { for i := 0; i < finalityDepth-2; i++ {
tipHash = addBlock([]*externalapi.DomainHash{tipHash}) tipHash = addBlock([]*externalapi.DomainHash{tipHash})
@ -184,6 +195,37 @@ func TestValidateAndInsertPruningPoint(t *testing.T) {
if !synceePruningPoint.Equal(pruningPoint) { if !synceePruningPoint.Equal(pruningPoint) {
t.Fatalf("The syncee pruning point has not changed as exepcted") t.Fatalf("The syncee pruning point has not changed as exepcted")
} }
pruningPointOld := pruningPoint
// Add blocks until the pruning point changes
for {
block, _, err := tcSyncer.BuildBlockWithParents([]*externalapi.DomainHash{tipHash}, nil, nil)
if err != nil {
t.Fatalf("BuildBlockWithParents: %+v", err)
}
_, err = tcSyncer.ValidateAndInsertBlock(block)
if err != nil {
t.Fatalf("ValidateAndInsertBlock: %+v", err)
}
_, err = tcSyncee.ValidateAndInsertBlock(block)
if err != nil {
t.Fatalf("ValidateAndInsertBlock: %+v", err)
}
tipHash = consensushashing.BlockHash(block)
pruningPoint, err := tcSyncer.PruningPoint()
if err != nil {
t.Fatalf("PruningPoint: %+v", err)
}
if !pruningPoint.Equal(pruningPointOld) {
break
}
}
}) })
} }