-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-1771] Add chain config mock structure
https://jira.hyperledger.org/browse/FAB-1771 This changeset adds a mock structure for the chainconfig.Descriptor. It also fixes a bug in the chainconfig.DescriptorImpl as it did not actually implement the interface. Change-Id: Iab2041dc07c6fc19b586485608068f417619cd16 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information
Jason Yellick
committed
Jan 20, 2017
1 parent
8c6fe20
commit 0372dae
Showing
4 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright IBM Corp. 2016 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package chainconfig | ||
|
||
import "github.com/hyperledger/fabric/common/util" | ||
|
||
func nearIdentityHash(input []byte) []byte { | ||
return util.ConcatenateBytes([]byte("Hash("), input, []byte("")) | ||
} | ||
|
||
// Descriptor is a mock implementation of sharedconfig.Descriptor | ||
type Descriptor struct { | ||
// HashingAlgorithmVal is returned as the result of HashingAlgorithm() | ||
HashingAlgorithmVal func([]byte) []byte | ||
// BlockDataHashingStructureWidthVal is returned as the result of BlockDataHashingStructureWidth() | ||
BlockDataHashingStructureWidthVal uint32 | ||
// OrdererAddressesVal is returned as the result of OrdererAddresses() | ||
OrdererAddressesVal []string | ||
} | ||
|
||
// HashingAlgorithm returns the HashingAlgorithmVal | ||
func (scm *Descriptor) HashingAlgorithm() func([]byte) []byte { | ||
return scm.HashingAlgorithmVal | ||
} | ||
|
||
// BlockDataHashingStructureWidth returns the BlockDataHashingStructureWidthVal | ||
func (scm *Descriptor) BlockDataHashingStructureWidth() uint32 { | ||
return scm.BlockDataHashingStructureWidthVal | ||
} | ||
|
||
// OrdererAddresses returns the OrdererAddressesVal | ||
func (scm *Descriptor) OrdererAddresses() []string { | ||
return scm.OrdererAddressesVal | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright IBM Corp. 2016 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package chainconfig | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/common/chainconfig" | ||
) | ||
|
||
func TestChainConfigInterface(t *testing.T) { | ||
_ = chainconfig.Descriptor(&Descriptor{}) | ||
} |