Skip to content

Commit

Permalink
fix test_basic
Browse files Browse the repository at this point in the history
tidy up

tidy up

remove debugging

tidy up
  • Loading branch information
leejw51crypto committed Apr 27, 2021
1 parent 40a8fe1 commit dd88d0b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
27 changes: 18 additions & 9 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import time

import json
from .utils import wait_for_block


def test_simple(cluster):
"""
- check number of validators
Expand All @@ -26,18 +25,29 @@ def test_transfer(cluster):
"""
community_addr = cluster.address("community")
reserve_addr = cluster.address("reserve")

community_balance = cluster.balance(community_addr)
reserve_balance = cluster.balance(reserve_addr)

tx = cluster.transfer(community_addr, reserve_addr, "1cro")
print("transfer tx", tx["txhash"])
assert tx["logs"] == [
assert json.dumps(tx["logs"]) == json.dumps( [
{
"events": [
{
"attributes": [
{"key": "receiver", "value": reserve_addr},
{"key": "amount", "value": "100000000basecro"},
],
"type": "coin_received",
},
{
"attributes": [
{"key": "spender", "value": community_addr},
{"key": "amount", "value": "100000000basecro"},
],
"type": "coin_spent",
},
{
"attributes": [
{"key": "action", "value": "send"},
{"key": "action", "value": "/cosmos.bank.v1beta1.Msg/Send"},
{"key": "sender", "value": community_addr},
{"key": "module", "value": "bank"},
],
Expand All @@ -55,8 +65,7 @@ def test_transfer(cluster):
"log": "",
"msg_index": 0,
}
]

])
assert cluster.balance(community_addr) == community_balance - 100000000
assert cluster.balance(reserve_addr) == reserve_balance + 100000000
query_txs_1 = cluster.query_all_txs(community_addr)
Expand Down
16 changes: 10 additions & 6 deletions pystarport/pystarport/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import tempfile
import threading
import time
import yaml

import bech32
from dateutil.parser import isoparse
Expand Down Expand Up @@ -44,6 +45,7 @@ def __call__(self, cmd, *args, stdin=None, **kwargs):
"execute chain-maind"
args = " ".join(build_cli_args_safe(cmd, *args, **kwargs))
return interact(f"{self.cmd} {args}", input=stdin)



class CosmosCLI:
Expand Down Expand Up @@ -179,10 +181,11 @@ def collect_gentxs(self, gentx_dir):
return self.raw("collect-gentxs", gentx_dir, home=self.data_dir)

def status(self):
return json.loads(self.raw("status", node=self.node_rpc))
return yaml.load(self.raw("status", node=self.node_rpc))

def block_height(self):
return int(self.status()["SyncInfo"]["latest_block_height"])
current_status=self.status()
return int(current_status["SyncInfo"]["latest_block_height"])

def block_time(self):
return isoparse(self.status()["SyncInfo"]["latest_block_time"])
Expand All @@ -208,7 +211,7 @@ def query_all_txs(self, addr):
chain_id=self.chain_id,
node=self.node_rpc,
)
return json.loads(txs)
return yaml.load(txs)

def distribution_commission(self, addr):
coin = json.loads(
Expand Down Expand Up @@ -304,8 +307,7 @@ def staking_pool(self, bonded=True):
)

def transfer(self, from_, to, coins, generate_only=False, fees=None):
return json.loads(
self.raw(
yaml_text=self.raw(
"tx",
"bank",
"send",
Expand All @@ -319,8 +321,10 @@ def transfer(self, from_, to, coins, generate_only=False, fees=None):
chain_id=self.chain_id,
node=self.node_rpc,
fees=fees,
)
broadcast_mode="block"
)
json_text=yaml.load(yaml_text)
return json_text

def transfer_from_ledger(self, from_, to, coins, generate_only=False, fees=None):
def send_request():
Expand Down

0 comments on commit dd88d0b

Please sign in to comment.