Skip to content

Commit

Permalink
Documented send transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
madnesspie committed Apr 28, 2020
1 parent adc35d0 commit 90b6294
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 26 deletions.
39 changes: 39 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,42 @@ Create address
'2N1Gbn5dqQxxD443Se9moXBaafGLvKCweop'
>>> eth.create_address()
'0x8a9c181caa4a1273e46a306309e806e2d61fc560'
Send transactions
`````````````````
.. code-block:: python
>>> btc.send_transaction(
... amount=0.00001,
... to_address='2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68',
... subtract_fee_from_amount=True,
... )
{
"txid": "cc8c9f7a86261fcb00d68b62073c740b8a0e14079d67e44fd726e0de2954c69a",
"from_address": "2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68",
"to_address": "2NAmne8BsSXWbV5iStkVzL4vW7Z4F6a5o68",
"amount": Decimal("0.00000866"),
"fee": Decimal("0.00000134"),
"block_number": None,
"category": "oneself",
"timestamp": 1588076404,
"info": {...},
}
>>> eth.send_transaction(
... amount=0.00005,
... from_address='0xe1082e71f1ced0efb0952edd23595e4f76840128',
... to_address='0xb610de1be67b10c746afec8fe74ad14d97e34146',
... subtract_fee_from_amount=True,
... password="abc",
... )
{
"txid": "0x4831820db0de1aad336c7a083b2504ad0b91eba293e5d7a6fa3bef49f660766c",
"from_address": "0xe1082e71f1ced0efb0952edd23595e4f76840128",
"to_address": "0xb610de1be67b10c746afec8fe74ad14d97e34146",
"amount": Decimal("0.000029"),
"fee": Decimal("0.000021"),
"block_number": None,
"category": "oneself",
"timestamp": None,
"info": {...},
}
2 changes: 1 addition & 1 deletion obm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# 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.
__version__ = "0.0.17"
__version__ = "0.0.18"
34 changes: 9 additions & 25 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,22 @@ class TestCurrency:
@pytest.mark.parametrize(
"kwargs, error, error_msg",
(
({"name": 111}, TypeError, "Name must be a string, not 'int'",),
(
{"name": 111},
TypeError,
"Name must be a string, not 'int'",
),
(
{"name": 'shitcoin'},
{"name": "shitcoin"},
exceptions.CurrencyUnsupportedError,
f"Unsupported currency. Available only: "
f"{connectors.SUPPORTED_CURRENCIES}",
),
),
ids=(
"wrong name type",
"unsupported currency",
),
ids=("wrong name type", "unsupported currency",),
)
def test_init_validation(kwargs, error, error_msg):
with pytest.raises(error) as exc_info:
models.Currency(**kwargs)
assert exc_info.value.args[0] == error_msg



class TestNode:
@staticmethod
@pytest.mark.parametrize(
Expand Down Expand Up @@ -101,21 +93,14 @@ def test_init_connector_validation(node_name, kwargs, error, error_msg):
@pytest.mark.parametrize(
"kwargs, error, error_msg",
(
({"name": 111}, TypeError, "Name must be a string, not 'int'",),
(
{"name": 111},
TypeError,
"Name must be a string, not 'int'",
),
(
{"name": 'fuckfinex'},
{"name": "fuckfinex"},
exceptions.NodeUnsupportedError,
"Unsupported node. Available only: ['bitcoin-core', 'geth']",
),
),
ids=(
"wrong name type",
"unsupported node",
),
ids=("wrong name type", "unsupported node",),
)
def test_init_validation(kwargs, error, error_msg):
with pytest.raises(error) as exc_info:
Expand All @@ -131,14 +116,14 @@ async def test_init_defaults(node_name):
"currency": "bitcoin",
"rpc_port": 18332,
"rpc_username": "testnet_user",
"rpc_password": 'testnet_pass',
"rpc_password": "testnet_pass",
},
"geth": {
"currency": "ethereum",
"rpc_port": 8545,
"rpc_username": None,
"rpc_password": None,
}
},
}
node = models.Node(
name=node_name,
Expand All @@ -154,7 +139,6 @@ async def test_init_defaults(node_name):
assert node.connector.timeout.total == expect["timeout"]



@pytest.mark.integration
class TestNodeIntegration:
@staticmethod
Expand Down Expand Up @@ -246,7 +230,7 @@ class TestTransactionIntegration:
async def test_sync(node):
tx = models.Transaction(
node=node,
to_address='fake-addr',
to_address="fake-addr",
amount=1,
txid=TXIDS_BY_CURRENCY[node.currency.name],
)
Expand Down

0 comments on commit 90b6294

Please sign in to comment.