Skip to content

Commit

Permalink
[FAB-1775] Store most recent block in mock struct
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1775

Store the results of the most recent `CreateNextBlock()` and
`WriteBlock()` calls in the mock `ConsenterSupport` structure so as to
make these values easier to retrieve (and some tests easier to write*).

* I will be using this in a test on [FAB-1623].

Change-Id: If678308e25f73112809867768c4b89052fd3f283
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Jan 21, 2017
1 parent 4b0176a commit 19ad687
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions orderer/mocks/multichain/multichain.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ type ConsenterSupport struct {

// ChainIDVal is the value returned by ChainID()
ChainIDVal string

// NextBlockVal stores the block created by the most recent CreateNextBlock() call
NextBlockVal *cb.Block

// WriteBlockVal stores the block created by the most recent WriteBlock() call
WriteBlockVal *cb.Block
}

// BlockCutter returns BlockCutterVal
Expand All @@ -64,6 +70,7 @@ func (mcs *ConsenterSupport) CreateNextBlock(data []*cb.Envelope) *cb.Block {
mtxs[i] = utils.MarshalOrPanic(data[i])
}
block.Data = &cb.BlockData{Data: mtxs}
mcs.NextBlockVal = block
return block
}

Expand All @@ -77,6 +84,7 @@ func (mcs *ConsenterSupport) WriteBlock(block *cb.Block, _committers []filter.Co
}
mcs.Batches <- umtxs
block.Metadata.Metadata[cb.BlockMetadataIndex_ORDERER] = utils.MarshalOrPanic(&cb.Metadata{Value: encodedMetadataValue})
mcs.WriteBlockVal = block
return block
}

Expand Down

0 comments on commit 19ad687

Please sign in to comment.