Skip to content

Commit

Permalink
document how to run the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjmelements committed Aug 2, 2019
1 parent d2cfafa commit 999c6be
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 24 deletions.
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ Start by cloning the repository.
git clone [email protected]:trusttoken/bnb-tx-python.git
```

Install dependencies
### Install dependencies
```
pipenv install
pipenv install --dev
```

Run flake8
### Run flake8
```
pipenv run flake8
```

### Run tests
```
pipenv run ./runtests.py
```

# Pull Requests
Please try to adhere to the following guidelines.

Expand Down
5 changes: 5 additions & 0 deletions binance_transaction/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from .bech32 import bech32_encode, address_bytes
from .base import Amino, Repeated, String, Address, StringVarInt, StringToken, Token, VarInt, make_prefix
from .crypto import uncompress_key, compress_key, verify_sig


name = "binance_transaction"
2 changes: 1 addition & 1 deletion binance_transaction/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import base64

from .bech32 import bech32_encode, address_bytes
from binance_transaction.bech32 import bech32_encode, address_bytes


"""
Expand Down
8 changes: 4 additions & 4 deletions binance_transaction/bnb_transaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .base import Repeated, Amino, String, StringVarInt, VarInt
from .crypto import compress_key, int_to_bytes, int_from_bytes, secp256k1
from .signature import BnbSignature
from .msg import Msg
from binance_transaction.base import Repeated, Amino, String, StringVarInt, VarInt
from binance_transaction.crypto import compress_key, int_to_bytes, int_from_bytes, secp256k1
from binance_transaction.signature import BnbSignature
from binance_transaction.msg import Msg


import base64
Expand Down
2 changes: 1 addition & 1 deletion binance_transaction/dex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import Address, Amino, String, VarInt, make_prefix
from binance_transaction.base import Address, Amino, String, VarInt, make_prefix


"""
Expand Down
2 changes: 1 addition & 1 deletion binance_transaction/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class UnsupportedBNBMessage(Exception):
class UnsupportedBnbMessage(Exception):
pass
2 changes: 1 addition & 1 deletion binance_transaction/gov.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import Amino, Repeated, String, Address, StringVarInt, StringToken, Token, VarInt, make_prefix
from binance_transaction.base import Amino, Repeated, String, Address, StringVarInt, StringToken, Token, VarInt, make_prefix


"""
Expand Down
10 changes: 5 additions & 5 deletions binance_transaction/msg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .base import Amino, make_prefix
from .token import Send, Issue, Mint, Burn, Freeze, Unfreeze, TimeLock, TimeRelock, TimeUnlock
from .gov import Proposal, Vote
from .dex import DexList, NewOrder, CancelOrder
from binance_transaction.base import Amino, make_prefix
from binance_transaction.token import Send, Issue, Mint, Burn, Freeze, Unfreeze, TimeLock, TimeRelock, TimeUnlock
from binance_transaction.gov import Proposal, Vote
from binance_transaction.dex import DexList, NewOrder, CancelOrder


"""
Expand Down Expand Up @@ -58,5 +58,5 @@ def decode(data, field_id):

@staticmethod
def from_msg_obj(msg_obj):
msg_klass = msg_class_by_type(msg_obj['type'])
msg_klass = msg_class_by_type[msg_obj['type']]
return msg_klass.from_msg_obj(msg_obj)
2 changes: 1 addition & 1 deletion binance_transaction/signature.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import Amino, Bytes, StringVarInt, VarInt, make_prefix
from binance_transaction.base import Amino, Bytes, StringVarInt, VarInt, make_prefix


"""
Expand Down
4 changes: 2 additions & 2 deletions binance_transaction/tests/test_dex.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_new_order():
'64AC1240CF4D2BE853D8EBA348353A91ED3BCF2C0164004DAF898153444E91E4A2BAC02106E4D1B3686D70F2B756274D90BF'
'120BA87A3CCC412E1D20618CAB480CE69A5718C7A00420072002'
)
assert hashlib.sha256(valid_tx) == valid_tx_hash
assert hashlib.sha256(valid_tx).digest() == valid_tx_hash
from_address = 'bnb1pyt4vhpv0nq8d9jrt5fmgz6r303cltwxu27xn2'
tx = BnbTransaction.from_obj({
'account_number': 69703,
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_cancel_order():
'788A7054E48DCA0CB5AEC745467F19AAA46120236C3220D65E2C2801184773DC4E32EE8F33CE87DC13951E5818723CC60318'
'98910920022001'
)
assert hashlib.sha256(valid_tx) == valid_tx_hash
assert hashlib.sha256(valid_tx).digest() == valid_tx_hash
from_address = 'bnb1j9tnf0vq2rj65qle6ptwes0kjh5xejdle3fpuj'
tx = BnbTransaction.from_obj({
'account_number': 149656,
Expand Down
4 changes: 2 additions & 2 deletions binance_transaction/tests/test_signature.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import base64

from .signature import PubKeySecp256k1
from .base import Bytes
from binance_transaction.signature import PubKeySecp256k1
from binance_transaction.base import Bytes


def test_pubkey_encoding():
Expand Down
4 changes: 2 additions & 2 deletions binance_transaction/tests/test_token.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import base64
import hashlib

from .bnb_transaction import BnbTransaction, TestBnbTransaction
from .crypto import uncompress_key, verify_sig
from binance_transaction.bnb_transaction import BnbTransaction, TestBnbTransaction
from binance_transaction.crypto import uncompress_key, verify_sig


def test_send_signed_encoding():
Expand Down
2 changes: 1 addition & 1 deletion binance_transaction/token.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import Address, Amino, Bool, Input, Output, Repeated, String, Token, VarInt, make_prefix
from binance_transaction.base import Address, Amino, Bool, Input, Output, Repeated, String, Token, VarInt, make_prefix


"""
Expand Down
33 changes: 33 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
import argparse
import os
import sys

import pytest


def main():
os.environ['APP_ENV'] = 'testing'

parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--debug-level', default='info', choices=('debug', 'info', 'warning', 'error'))
parser.add_argument('--coverage', action='store_true', default=False)
parser.add_argument('--coverage-html', '--cov-html', action='store_true', default=False)

args, pytest_args = parser.parse_known_args()

use_coverage = args.coverage or args.coverage_html

if use_coverage:
pytest_args.extend(['--cov', 'bnbarb'])

if args.coverage_html:
pytest_args.extend(['--cov-report', 'html', '--cov-report', 'term'])

print('--> Calling pytest with args: {}'.format(' '.join(pytest_args)))
status = pytest.main(pytest_args)
sys.exit(status)


if __name__ == '__main__':
main()

0 comments on commit 999c6be

Please sign in to comment.