Skip to content

Commit

Permalink
FAB-3506: Endorser Scaffolding
Browse files Browse the repository at this point in the history
This is the scaffolding for building behave tests
around endorsers and peers in general.

Change-Id: Ic033fcc9389508b69be20747dbe5be60003b65ba
Signed-off-by: Latitia M Haskins <latitia.haskins@gmail.com>
  • Loading branch information
lhaskins committed Apr 28, 2017
1 parent e24aedf commit d7bffaf
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/feature/endorser.feature
@@ -0,0 +1,13 @@
Feature: Endorser Peer
As a user I want to run and validate an endorsing peer

Scenario Outline: Test basic chaincode deploy
Given I have a bootstrapped fabric network of type <type>
When a user deploys chaincode
Then the chaincode is deployed
When a user queries on the chaincode
Then a user receives expected response
Examples:
| type |
| solo |
| kafka |
Empty file added test/feature/steps/__init__.py
Empty file.
31 changes: 31 additions & 0 deletions test/feature/steps/basic_impl.py
@@ -0,0 +1,31 @@
# 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.
#

from behave import *
import time

@given(u'I wait "{seconds}" seconds')
@when(u'I wait "{seconds}" seconds')
@then(u'I wait "{seconds}" seconds')
def step_impl(context, seconds):
time.sleep(float(seconds))

@given(u'I have a bootstrapped fabric network of')
def step_impl(context):
bootstrapped_impl(context, "solo")

@given(u'I have a bootstrapped fabric network of type {type}')
def bootstrapped_impl(context, type):
pass
70 changes: 70 additions & 0 deletions test/feature/steps/endorser_impl.py
@@ -0,0 +1,70 @@
# 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.
#

from behave import *
import json


@when(u'a user deploys chaincode at path {path} with {args} with name {name}')
def deploy_impl(context, path, args, name):
pass

@when(u'a user deploys chaincode at path {path} with {args}')
def step_impl(context, path, args):
deploy_impl(context, path, json.loads(args), "mycc")

@when(u'a user deploys chaincode')
def step_impl(context):
deploy_impl(context,
"github.com/hyperledger/fabric//chaincode_example02",
["init", "a", "100" , "b", "200"],
"mycc")

@when(u'a user queries on the chaincode named {name}')
def query_impl(context, name):
pass

@when(u'a user queries on the chaincode')
def step_impl(context):
query_impl(context, "mycc")

@when(u'a user invokes {count} times on the chaincode named {name} with args {args}')
def invokes_impl(context, count, name, args):
pass

@when(u'a user invokes on the chaincode named {name} with args {args}')
def step_impl(context, name, args):
invokes_impl(context, 1, name, json.loads(args))

@when(u'a user invokes {count} times on the chaincode')
def step_impl(context, count):
invokes_impl(context, count, "mycc", ["txId1", "invoke", "a", 5])

@when(u'a user invokes on the chaincode named {name}')
def step_impl(context, name):
invokes_impl(context, 1, name, ["txId1", "invoke", "a", 5])

@when(u'a user invokes on the chaincode')
def step_impl(context):
invokes_impl(context, 1, "mycc", ["txId1", "invoke", "a", 5])

@then(u'the chaincode is deployed')
def step_impl(context):
pass

@then(u'a user receives expected response')
def step_impl(context):
pass

0 comments on commit d7bffaf

Please sign in to comment.