From d7bffaffd22c26e5d8bcea94355c344d178fcd34 Mon Sep 17 00:00:00 2001 From: Latitia M Haskins Date: Fri, 28 Apr 2017 17:36:22 -0400 Subject: [PATCH] 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 --- test/feature/endorser.feature | 13 ++++++ test/feature/steps/__init__.py | 0 test/feature/steps/basic_impl.py | 31 +++++++++++++ test/feature/steps/endorser_impl.py | 70 +++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 test/feature/endorser.feature create mode 100644 test/feature/steps/__init__.py create mode 100644 test/feature/steps/basic_impl.py create mode 100644 test/feature/steps/endorser_impl.py diff --git a/test/feature/endorser.feature b/test/feature/endorser.feature new file mode 100644 index 00000000000..22ccc89a669 --- /dev/null +++ b/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 + 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 | diff --git a/test/feature/steps/__init__.py b/test/feature/steps/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/feature/steps/basic_impl.py b/test/feature/steps/basic_impl.py new file mode 100644 index 00000000000..d32f80d0125 --- /dev/null +++ b/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 diff --git a/test/feature/steps/endorser_impl.py b/test/feature/steps/endorser_impl.py new file mode 100644 index 00000000000..3120bbc4615 --- /dev/null +++ b/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 +