Skip to content

Commit c10dddf

Browse files
Merge pull request #10 from dragonchain/master
Release 4.0.1
2 parents 6bed3ff + e5b68ea commit c10dddf

File tree

13 files changed

+166
-35
lines changed

13 files changed

+166
-35
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ matrix:
2424
- name: CPython 3.7
2525
python: 3.7
2626
dist: xenial
27+
- name: CPython 3.8
28+
python: 3.8
29+
dist: bionic
2730
install:
28-
- if [ $TRAVIS_PYTHON_VERSION = 3.7 ]; then ./run.sh install-req; else ./run.sh install-req skip-extras; fi
31+
- if [ $TRAVIS_PYTHON_VERSION = 3.8 ]; then ./run.sh install-req; else ./run.sh install-req skip-extras; fi
2932
before_script:
3033
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
3134
- chmod +x ./cc-test-reporter
3235
- ./cc-test-reporter before-build
3336
script:
34-
- if [ $TRAVIS_PYTHON_VERSION = 3.7 ]; then ./run.sh full-build; elif [ $TRAVIS_PYTHON_VERSION = 3.4 ]; then ./run.sh full-build no-async; else ./run.sh full-build no-format; fi
37+
- if [ $TRAVIS_PYTHON_VERSION = 3.8 ]; then ./run.sh full-build; elif [ $TRAVIS_PYTHON_VERSION = 3.4 ]; then ./run.sh full-build no-async; else ./run.sh full-build no-format; fi
3538
after_script:
36-
- if [ $TRAVIS_PYTHON_VERSION = 3.7 ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
39+
- if [ $TRAVIS_PYTHON_VERSION = 3.8 ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi

build.Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM python:3.8
2+
3+
WORKDIR /usr/src/sdk
4+
COPY requirements.txt /
5+
COPY dev_requirements.txt /
6+
RUN python3 -m pip install -r /requirements.txt && \
7+
python3 -m pip install -r /dev_requirements.txt
8+
9+
CMD [ "sh", "run.sh", "full-build" ]

docs/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
4.0.1
5+
-----
6+
7+
Packaging:
8+
* Officially support python 3.8 in packaged release
9+
Development:
10+
* Fix unit tests for proper async context mocking with python 3.8+
11+
* Add integration tests for Dragonchain 4.1.0 features and changes
12+
413
4.0.0
514
-----
615

dragonchain_sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from dragonchain_sdk import dragonchain_client
1717

1818
__author__ = "Dragonchain, Inc."
19-
__version__ = "4.0.0"
19+
__version__ = "4.0.1"
2020

2121
ASYNC_SUPPORT = False
2222

dragonchain_sdk/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def _generate_request_data(
270270

271271
logger.debug("{} {}".format(http_verb, full_url))
272272
logger.debug("Headers: {}".format(header_dict))
273-
logger.debug("Data: {}".format(content))
273+
logger.debug("Data: {!r}".format(content))
274274
return full_url, content, additional_headers
275275

276276
def _make_request(

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ warn_unused_configs=True
99
# flake8-mypy expects the two following for sensible formatting
1010
show_column_numbers=True
1111
show_error_context=False
12+
no_error_summary=True
1213

1314
# Check all imports
1415
follow_imports=normal

run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ install : install the project from source (depends on running build first)
1919
install-req : install the python dependencies to dev on the project
2020
build-dist : build the distribution artifcats for the project from source
2121
clean : remove compiled python/docs/other build or distrubition artifacts from the local project
22+
docker-test : run all the checks in a docker container that a PR will test for
2223
full-build : run all of the tests that the pull request/build would check, locally
2324
dist-release : upload and distribute the artifacts from build-dist to pypi"
2425

@@ -73,6 +74,9 @@ elif [ "$1" = "build-dist" ]; then
7374
elif [ "$1" = "clean" ]; then
7475
find . -name __pycache__ -exec rm -rfv {} +
7576
rm -rfv .coverage coverage.xml build/ dist/ dragonchain_sdk.egg-info/ docs/.build/
77+
elif [ "$1" = "docker-test" ]; then
78+
docker build . -f ./build.Dockerfile -t dragonchain_sdk_testing_container
79+
docker run -v "$(pwd)":/usr/src/sdk dragonchain_sdk_testing_container
7680
elif [ "$1" = "full-build" ]; then
7781
set +e
7882
printf "\\nChecking for linting errors\\n\\n"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def get_version():
6767
"Programming Language :: Python :: 3.5",
6868
"Programming Language :: Python :: 3.6",
6969
"Programming Language :: Python :: 3.7",
70+
"Programming Language :: Python :: 3.8",
7071
"Programming Language :: Python :: 3 :: Only",
7172
"Programming Language :: Python :: Implementation :: CPython",
7273
"Programming Language :: Python :: Implementation :: PyPy",

tests/integration/test_interchain.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ def test_create_ethereum_interchain_with_defaults(self):
6060
self.assertEqual(response.get("status"), 201, response)
6161
jsonschema.validate(response.get("response"), schema.ethereum_interchain_at_rest_schema)
6262

63+
def test_create_ethereum_interchain_fails_with_existing_name(self):
64+
response = self.client.create_ethereum_interchain(ETHEREUM_INTERCHAIN_NAME_2, chain_id=1)
65+
expected_response = {
66+
"status": 409,
67+
"ok": False,
68+
"response": {"error": {"type": "INTERCHAIN_CONFLICT", "details": "An interchain network with the name you provided already exists"}},
69+
}
70+
self.assertEqual(response, expected_response)
71+
6372
def test_create_ethereum_interchain_fails_with_bad_rpc_address(self):
6473
response = self.client.create_ethereum_interchain("garbage", rpc_address="http://youcantGETthis.whatever")
6574
self.assertFalse(response.get("ok"), response)
@@ -126,6 +135,15 @@ def test_create_bitcoin_interchain_with_defaults(self):
126135
self.assertEqual(response.get("status"), 201, response)
127136
jsonschema.validate(response.get("response"), schema.bitcoin_interchain_at_rest_schema)
128137

138+
def test_create_bitcoin_interchain_fails_with_existing_name(self):
139+
response = self.client.create_bitcoin_interchain(BITCOIN_INTERCHAIN_NAME_2, testnet=False)
140+
expected_response = {
141+
"status": 409,
142+
"ok": False,
143+
"response": {"error": {"type": "INTERCHAIN_CONFLICT", "details": "An interchain network with the name you provided already exists"}},
144+
}
145+
self.assertEqual(response, expected_response)
146+
129147
def test_create_bitcoin_interchain_fails_with_bad_rpc_address(self):
130148
response = self.client.create_bitcoin_interchain("garbage", testnet=True, rpc_address="http://youcantGETthis.whatever")
131149
self.assertFalse(response.get("ok"), response)
@@ -406,12 +424,14 @@ def suite():
406424
suite = unittest.TestSuite()
407425
suite.addTest(TestInterchain("test_create_ethereum_interchain_with_values"))
408426
suite.addTest(TestInterchain("test_create_ethereum_interchain_with_defaults"))
427+
suite.addTest(TestInterchain("test_create_ethereum_interchain_fails_with_existing_name"))
409428
suite.addTest(TestInterchain("test_create_ethereum_interchain_fails_with_bad_rpc_address"))
410429
suite.addTest(TestInterchain("test_create_ethereum_interchain_fails_with_mismatching_chain_id"))
411430
suite.addTest(TestInterchain("test_create_ethereum_interchain_fails_with_bad_private_key"))
412431
suite.addTest(TestInterchain("test_create_ethereum_interchain_fails_without_chain_id_or_rpc_address"))
413432
suite.addTest(TestInterchain("test_create_bitcoin_interchain_with_values"))
414433
suite.addTest(TestInterchain("test_create_bitcoin_interchain_with_defaults"))
434+
suite.addTest(TestInterchain("test_create_bitcoin_interchain_fails_with_existing_name"))
415435
suite.addTest(TestInterchain("test_create_bitcoin_interchain_fails_with_bad_rpc_address"))
416436
suite.addTest(TestInterchain("test_create_bitcoin_interchain_fails_without_wif_private_key_or_testnet"))
417437
suite.addTest(TestInterchain("test_create_bitcoin_interchain_fails_with_bad_private_key"))

tests/integration/test_smart_contracts.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
SMART_CONTRACT_CRON_ID = None
3535
ARGS_CONTRACT_BODY = None
3636
CREATION_TIMESTAMP = None
37+
CRON_INVOCATION_COUNT = None
38+
SCHEDULER_INVOCATION_COUNT = None
3739

3840
SCHEDULER = 60
3941
CRON = "* * * * *"
@@ -202,19 +204,40 @@ def test_update_contract_execution_order(self):
202204

203205
# INVOCATION #
204206

205-
def wait_for_scheduler_invocation(self):
207+
def wait_for_scheduler_invocation_1(self):
206208
time.sleep(60)
207209

210+
def disable_schedule(self):
211+
self.assertTrue(self.client.update_smart_contract(SMART_CONTRACT_SCHEDULER_ID, disable_schedule=True).get("ok"))
212+
self.assertTrue(self.client.update_smart_contract(SMART_CONTRACT_CRON_ID, disable_schedule=True).get("ok"))
213+
208214
def test_successful_invocation_of_scheduler(self):
209215
transaction_invocation = self.client.query_transactions(SMART_CONTRACT_SCHEDULER_NAME, "*")
210-
self.assertGreater(transaction_invocation["response"]["total"], 0)
216+
global SCHEDULER_INVOCATION_COUNT
217+
SCHEDULER_INVOCATION_COUNT = transaction_invocation["response"]["total"]
218+
self.assertGreater(SCHEDULER_INVOCATION_COUNT, 0)
211219
self.assertGreater(transaction_invocation["response"]["results"][0]["header"]["timestamp"], CREATION_TIMESTAMP)
212220

213221
def test_successful_invocation_of_cron(self):
214222
transaction_invocation = self.client.query_transactions(SMART_CONTRACT_CRON_NAME, "*")
215-
self.assertGreater(transaction_invocation["response"]["total"], 0)
223+
global CRON_INVOCATION_COUNT
224+
CRON_INVOCATION_COUNT = transaction_invocation["response"]["total"]
225+
self.assertGreater(CRON_INVOCATION_COUNT, 0)
216226
self.assertGreater(transaction_invocation["response"]["results"][0]["header"]["timestamp"], CREATION_TIMESTAMP)
217227

228+
def wait_for_scheduler_invocation_2(self):
229+
time.sleep(65)
230+
231+
def test_disable_schedule_works_on_scheduler(self):
232+
transaction_invocation = self.client.query_transactions(SMART_CONTRACT_SCHEDULER_NAME, "*")
233+
# Assert that the transaction count after waiting 60 seconds is the same as after we immediately disabled the schedule
234+
self.assertEqual(SCHEDULER_INVOCATION_COUNT, transaction_invocation["response"]["total"])
235+
236+
def test_disable_schedule_works_on_cron(self):
237+
transaction_invocation = self.client.query_transactions(SMART_CONTRACT_CRON_NAME, "*")
238+
# Assert that the transaction count after waiting 60 seconds is the same as after we immediately disabled the schedule
239+
self.assertEqual(CRON_INVOCATION_COUNT, transaction_invocation["response"]["total"])
240+
218241
def test_successful_invocation_with_transactions(self):
219242
args_transaction = self.client.create_transaction(SMART_CONTRACT_ARGS_NAME, "banana", tag="banana")
220243
env_transaction = self.client.create_transaction(SMART_CONTRACT_ENV_NAME, "banana", tag="banana")
@@ -356,9 +379,13 @@ def suite():
356379
suite.addTest(TestSmartContracts("test_update_contract_with_env"))
357380
suite.addTest(TestSmartContracts("test_update_contract_with_secrets"))
358381
suite.addTest(TestSmartContracts("test_update_contract_execution_order"))
359-
suite.addTest(TestSmartContracts("wait_for_scheduler_invocation"))
382+
suite.addTest(TestSmartContracts("wait_for_scheduler_invocation_1"))
383+
suite.addTest(TestSmartContracts("disable_schedule"))
360384
suite.addTest(TestSmartContracts("test_successful_invocation_of_scheduler"))
361385
suite.addTest(TestSmartContracts("test_successful_invocation_of_cron"))
386+
suite.addTest(TestSmartContracts("wait_for_scheduler_invocation_2"))
387+
suite.addTest(TestSmartContracts("test_disable_schedule_works_on_scheduler"))
388+
suite.addTest(TestSmartContracts("test_disable_schedule_works_on_cron"))
362389
suite.addTest(TestSmartContracts("test_successful_invocation_with_transactions"))
363390
suite.addTest(TestSmartContracts("test_get_contract_logs_with_contract_id"))
364391
suite.addTest(TestSmartContracts("test_get_contract_logs_with_contract_id_tail_and_since"))

0 commit comments

Comments
 (0)