Exemplo n.º 1
0
def test_get_handle_transaction_cosmwasm():
    """Test the get deploy transaction method."""
    cc2 = CosmosCrypto()
    cosmos_api = CosmosApi(**COSMOS_TESTNET_CONFIG)
    handle_msg = "handle_msg"
    sender_address = cc2.address
    contract_address = "contract_address"
    tx_fee = 1
    amount = 10
    handle_transaction = cosmos_api.get_handle_transaction(
        sender_address, contract_address, handle_msg, amount, tx_fee)

    assert type(handle_transaction) == dict and len(handle_transaction) == 6
    assert "account_number" in handle_transaction
    assert "chain_id" in handle_transaction
    assert "fee" in handle_transaction and handle_transaction["fee"] == {
        "amount": [{
            "denom": "atestfet",
            "amount": "{}".format(tx_fee)
        }],
        "gas": "80000",
    }
    assert "memo" in handle_transaction
    assert "msgs" in handle_transaction and len(
        handle_transaction["msgs"]) == 1
    msg = handle_transaction["msgs"][0]
    assert "type" in msg and msg["type"] == "wasm/execute"
    assert ("value" in msg and msg["value"]["sender"] == sender_address
            and msg["value"]["contract"] == contract_address
            and msg["value"]["msg"] == handle_msg
            and msg["value"]["sent_funds"] == [{
                "denom": "atestfet",
                "amount": str(amount)
            }])
    assert "sequence" in handle_transaction
Exemplo n.º 2
0
def test_cosmos_api_get_handle_transaction(*args):
    """Test CosmosApi.get_handle_transaction."""
    cosmos_api = CosmosApi()
    assert cosmos_api.get_handle_transaction(*[Mock()] * 7) is None