mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-20 22:06:42 +00:00

* Add stability-tests * Fix requires * Fix golint errors * Update README.md * Remove payloadHash from everywhere * don't run vet on kaspad in stability-tests/install_and_test
24 lines
724 B
Go
24 lines
724 B
Go
package main
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/consensushashing"
|
|
"github.com/kaspanet/kaspad/stability-tests/common/rpc"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func checkTopBlockIsTip(rpcClient *rpc.Client, topBlock *externalapi.DomainBlock) error {
|
|
selectedTipHashResponse, err := rpcClient.GetSelectedTipHash()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
topBlockHash := consensushashing.BlockHash(topBlock)
|
|
if selectedTipHashResponse.SelectedTipHash != topBlockHash.String() {
|
|
return errors.Errorf("selectedTipHash is '%s' while expected to be topBlock's hash `%s`",
|
|
selectedTipHashResponse.SelectedTipHash, topBlockHash)
|
|
}
|
|
|
|
return nil
|
|
}
|