-
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-2361] Create local signer mocks
https://jira.hyperledger.org/browse/FAB-2361 In preparation for splitting the config update processing out of the multichain package, the signing mocks need to be extracted and moved to the common mocks. Change-Id: Id6ee786337f8ad20b54951bf69d3ad95b6f1352c Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information
Jason Yellick
committed
Feb 18, 2017
1 parent
2ecb22a
commit 42fba98
Showing
5 changed files
with
91 additions
and
24 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright IBM Corp. 2017 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 crypto | ||
|
||
import ( | ||
cb "github.com/hyperledger/fabric/protos/common" | ||
) | ||
|
||
// FakeLocalSigner is a signer which already has identity an nonce set to fake values | ||
var FakeLocalSigner = &LocalSigner{ | ||
Identity: []byte("IdentityBytes"), | ||
Nonce: []byte("NonceValue"), | ||
} | ||
|
||
// LocalSigner is a mock implmeentation of crypto.LocalSigner | ||
type LocalSigner struct { | ||
Identity []byte | ||
Nonce []byte | ||
} | ||
|
||
// Sign returns the msg, nil | ||
func (ls *LocalSigner) Sign(msg []byte) ([]byte, error) { | ||
return msg, nil | ||
} | ||
|
||
// NewSignatureHeader returns a new signature header, nil | ||
func (ls *LocalSigner) NewSignatureHeader() (*cb.SignatureHeader, error) { | ||
return &cb.SignatureHeader{ | ||
Creator: ls.Identity, | ||
Nonce: ls.Nonce, | ||
}, nil | ||
} |
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. 2017 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 crypto | ||
|
||
import ( | ||
"testing" | ||
|
||
crypto "github.com/hyperledger/fabric/common/crypto" | ||
) | ||
|
||
func TestLocalSignerInterface(t *testing.T) { | ||
_ = crypto.LocalSigner(&LocalSigner{}) | ||
} |
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