Skip to content

Commit 00e49d6

Browse files
committed
add staking cache integration tests
1 parent 2db13a1 commit 00e49d6

File tree

2 files changed

+819
-18
lines changed

2 files changed

+819
-18
lines changed

integration_tests/cosmoscli.py

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# the default initial base fee used by integration tests
2020
DEFAULT_GAS_PRICE = "100000000000basetcro"
2121
DEFAULT_GAS = "250000"
22+
STAKING_DEFAULT_GAS = "1000000"
2223

2324

2425
class ModuleAccount(enum.Enum):
@@ -409,24 +410,54 @@ def get_delegated_amount(self, which_addr):
409410
)
410411
)
411412

412-
def delegate_amount(self, to_addr, amount, from_addr, gas_price=None):
413-
if gas_price is None:
414-
return json.loads(
415-
self.raw(
416-
"tx",
417-
"staking",
418-
"delegate",
419-
to_addr,
420-
amount,
421-
"-y",
422-
home=self.data_dir,
423-
from_=from_addr,
424-
keyring_backend="test",
425-
chain_id=self.chain_id,
426-
node=self.node_rpc,
427-
)
413+
def get_delegations(self, which_addr):
414+
"""Query all delegations made from one delegator."""
415+
return json.loads(
416+
self.raw(
417+
"query",
418+
"staking",
419+
"delegations",
420+
which_addr,
421+
home=self.data_dir,
422+
chain_id=self.chain_id,
423+
node=self.node_rpc,
424+
output="json",
428425
)
429-
else:
426+
)
427+
428+
def get_unbonding_delegations(self, which_addr):
429+
"""Query all unbonding delegations from a delegator."""
430+
return json.loads(
431+
self.raw(
432+
"query",
433+
"staking",
434+
"unbonding-delegations",
435+
which_addr,
436+
home=self.data_dir,
437+
chain_id=self.chain_id,
438+
node=self.node_rpc,
439+
output="json",
440+
)
441+
).get("unbonding_responses", [])
442+
443+
def get_redelegations(self, delegator_addr, src_validator_addr, dst_validator_addr):
444+
"""Query all redelegations from a delegator."""
445+
return json.loads(
446+
self.raw(
447+
"query",
448+
"staking",
449+
"redelegation",
450+
delegator_addr,
451+
src_validator_addr,
452+
dst_validator_addr,
453+
home=self.data_dir,
454+
chain_id=self.chain_id,
455+
node=self.node_rpc,
456+
output="json",
457+
)
458+
).get("redelegation_responses", [])
459+
460+
def delegate_amount(self, to_addr, amount, from_addr):
430461
return json.loads(
431462
self.raw(
432463
"tx",
@@ -440,7 +471,8 @@ def delegate_amount(self, to_addr, amount, from_addr, gas_price=None):
440471
keyring_backend="test",
441472
chain_id=self.chain_id,
442473
node=self.node_rpc,
443-
gas_prices=gas_price,
474+
gas_prices=DEFAULT_GAS_PRICE,
475+
gas=STAKING_DEFAULT_GAS,
444476
)
445477
)
446478

@@ -459,6 +491,8 @@ def unbond_amount(self, to_addr, amount, from_addr):
459491
keyring_backend="test",
460492
chain_id=self.chain_id,
461493
node=self.node_rpc,
494+
gas=STAKING_DEFAULT_GAS,
495+
gas_prices=DEFAULT_GAS_PRICE,
462496
)
463497
)
464498

@@ -480,6 +514,8 @@ def redelegate_amount(
480514
keyring_backend="test",
481515
chain_id=self.chain_id,
482516
node=self.node_rpc,
517+
gas=STAKING_DEFAULT_GAS,
518+
gas_prices=DEFAULT_GAS_PRICE,
483519
)
484520
)
485521

0 commit comments

Comments
 (0)