Skip to content

Commit d7bffaf

Browse files
committed
FAB-3506: Endorser Scaffolding
This is the scaffolding for building behave tests around endorsers and peers in general. Change-Id: Ic033fcc9389508b69be20747dbe5be60003b65ba Signed-off-by: Latitia M Haskins <[email protected]>
1 parent e24aedf commit d7bffaf

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

test/feature/endorser.feature

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: Endorser Peer
2+
As a user I want to run and validate an endorsing peer
3+
4+
Scenario Outline: Test basic chaincode deploy
5+
Given I have a bootstrapped fabric network of type <type>
6+
When a user deploys chaincode
7+
Then the chaincode is deployed
8+
When a user queries on the chaincode
9+
Then a user receives expected response
10+
Examples:
11+
| type |
12+
| solo |
13+
| kafka |

test/feature/steps/__init__.py

Whitespace-only changes.

test/feature/steps/basic_impl.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright IBM Corp. 2016 All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
from behave import *
17+
import time
18+
19+
@given(u'I wait "{seconds}" seconds')
20+
@when(u'I wait "{seconds}" seconds')
21+
@then(u'I wait "{seconds}" seconds')
22+
def step_impl(context, seconds):
23+
time.sleep(float(seconds))
24+
25+
@given(u'I have a bootstrapped fabric network of')
26+
def step_impl(context):
27+
bootstrapped_impl(context, "solo")
28+
29+
@given(u'I have a bootstrapped fabric network of type {type}')
30+
def bootstrapped_impl(context, type):
31+
pass

test/feature/steps/endorser_impl.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright IBM Corp. 2016 All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
from behave import *
17+
import json
18+
19+
20+
@when(u'a user deploys chaincode at path {path} with {args} with name {name}')
21+
def deploy_impl(context, path, args, name):
22+
pass
23+
24+
@when(u'a user deploys chaincode at path {path} with {args}')
25+
def step_impl(context, path, args):
26+
deploy_impl(context, path, json.loads(args), "mycc")
27+
28+
@when(u'a user deploys chaincode')
29+
def step_impl(context):
30+
deploy_impl(context,
31+
"github.com/hyperledger/fabric//chaincode_example02",
32+
["init", "a", "100" , "b", "200"],
33+
"mycc")
34+
35+
@when(u'a user queries on the chaincode named {name}')
36+
def query_impl(context, name):
37+
pass
38+
39+
@when(u'a user queries on the chaincode')
40+
def step_impl(context):
41+
query_impl(context, "mycc")
42+
43+
@when(u'a user invokes {count} times on the chaincode named {name} with args {args}')
44+
def invokes_impl(context, count, name, args):
45+
pass
46+
47+
@when(u'a user invokes on the chaincode named {name} with args {args}')
48+
def step_impl(context, name, args):
49+
invokes_impl(context, 1, name, json.loads(args))
50+
51+
@when(u'a user invokes {count} times on the chaincode')
52+
def step_impl(context, count):
53+
invokes_impl(context, count, "mycc", ["txId1", "invoke", "a", 5])
54+
55+
@when(u'a user invokes on the chaincode named {name}')
56+
def step_impl(context, name):
57+
invokes_impl(context, 1, name, ["txId1", "invoke", "a", 5])
58+
59+
@when(u'a user invokes on the chaincode')
60+
def step_impl(context):
61+
invokes_impl(context, 1, "mycc", ["txId1", "invoke", "a", 5])
62+
63+
@then(u'the chaincode is deployed')
64+
def step_impl(context):
65+
pass
66+
67+
@then(u'a user receives expected response')
68+
def step_impl(context):
69+
pass
70+

0 commit comments

Comments
 (0)