本文整理汇总了Golang中github.com/openblockchain/obc-peer/protos.Block.PreviousBlockHash方法的典型用法代码示例。如果您正苦于以下问题:Golang Block.PreviousBlockHash方法的具体用法?Golang Block.PreviousBlockHash怎么用?Golang Block.PreviousBlockHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/openblockchain/obc-peer/protos.Block
的用法示例。
在下文中一共展示了Block.PreviousBlockHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLedgerPutRawBlock
func TestLedgerPutRawBlock(t *testing.T) {
ledgerTestWrapper := createFreshDBAndTestLedgerWrapper(t)
ledger := ledgerTestWrapper.ledger
block := new(protos.Block)
block.PreviousBlockHash = []byte("foo")
block.StateHash = []byte("bar")
ledger.PutRawBlock(block, 4)
testutil.AssertEquals(t, ledgerTestWrapper.GetBlockByNumber(4), block)
}
示例2: TestLedgerPutRawBlock
func TestLedgerPutRawBlock(t *testing.T) {
ledgerTestWrapper := createFreshDBAndTestLedgerWrapper(t)
ledger := ledgerTestWrapper.ledger
block := new(protos.Block)
block.PreviousBlockHash = []byte("foo")
block.StateHash = []byte("bar")
ledger.PutRawBlock(block, 4)
testutil.AssertEquals(t, ledgerTestWrapper.GetBlockByNumber(4), block)
ledger.BeginTxBatch(1)
ledger.TxBegin("txUuid")
ledger.SetState("chaincode1", "key1", []byte("value1"))
ledger.TxFinished("txUuid", true)
transaction, _ := buildTestTx(t)
ledger.CommitTxBatch(1, []*protos.Transaction{transaction}, nil, []byte("proof"))
previousHash, _ := block.GetHash()
newBlock := ledgerTestWrapper.GetBlockByNumber(5)
if !bytes.Equal(newBlock.PreviousBlockHash, previousHash) {
t.Fatalf("Expected new block to properly set its previous hash")
}
}