Skip to content

Commit c6d067f

Browse files
committed
[FAB-11173] FabToken Validation Plugin
This change-set in accordance to FAB-11173 does the following: Under core/handlers/validation/builtin, a new skeleton implementation of PluginFactory and Plugin will be introduced. The new FabtokenPluginFactory will return instances of the new FabTokenValidation whose default implementation returns no error. Tests have been included to verify the above behaviour. Change-Id: I869e5f492eace02ceb843d7e6366a768464ba746 Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent c430183 commit c6d067f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package token
8+
9+
import (
10+
"github.com/hyperledger/fabric/core/handlers/validation/api"
11+
"github.com/hyperledger/fabric/protos/common"
12+
)
13+
14+
type ValidationFactory struct {
15+
}
16+
17+
func (*ValidationFactory) New() validation.Plugin {
18+
return &ValidationPlugin{}
19+
}
20+
21+
type ValidationPlugin struct {
22+
}
23+
24+
func (v *ValidationPlugin) Init(dependencies ...validation.Dependency) error {
25+
return nil
26+
}
27+
28+
func (v *ValidationPlugin) Validate(block *common.Block, namespace string, txPosition int, actionPosition int, contextData ...validation.ContextDatum) error {
29+
return nil
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package token_test
8+
9+
import (
10+
"testing"
11+
12+
"github.com/hyperledger/fabric/core/handlers/validation/token"
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestValidationFactory_New(t *testing.T) {
17+
factory := &token.ValidationFactory{}
18+
plugin := factory.New()
19+
assert.NotNil(t, plugin)
20+
}
21+
22+
func TestValidation_Validate(t *testing.T) {
23+
factory := &token.ValidationFactory{}
24+
plugin := factory.New()
25+
26+
err := plugin.Init()
27+
assert.NoError(t, err)
28+
29+
// Validate returns nil, no matter what!
30+
err = plugin.Validate(nil, "", 0, 0, nil)
31+
assert.NoError(t, err)
32+
}

0 commit comments

Comments
 (0)