Skip to content

Commit

Permalink
fix group
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 29, 2023
1 parent 7957665 commit e8eef21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def broadcast_tx(self, tx_file, **kwargs):
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def event_query_tx_for(self, hash):
return json.loads(
self.raw(
Expand Down
35 changes: 24 additions & 11 deletions integration_tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@

import pytest

from .utils import parse_events

pytestmark = pytest.mark.normal


def event_query_tx_for(cli, rsp):
return json.loads(
cli.raw(
"query",
"event-query-tx-for",
rsp["txhash"],
"-y",
home=cli.data_dir,
)

Check failure on line 18 in integration_tests/test_group.py

View workflow job for this annotation

GitHub Actions / test

test_group AssertionError: Error: message validation failed: group policy: decoding bech32 failed: invalid character not part of charset: 34 [cosmos/cosmos-sdk/x/group/msgs.go:610] Usage: chain-maind tx group submit-proposal [proposal_json_file] [flags] Examples: chain-maind tx group submit-proposal path/to/proposal.json Where proposal.json contains: { "group_policy_address": "cosmos1...", // array of proto-JSON-encoded sdk.Msgs "messages": [ { "@type": "/cosmos.bank.v1beta1.MsgSend", "from_address": "cosmos1...", "to_address": "cosmos1...", "amount":[{"denom": "stake","amount": "10"}] } ], // metadata can be any of base64 encoded, raw text, stringified json, IPFS link to json // see below for example metadata "metadata": "4pIMOgIGx1vZGU=", // base64-encoded metadata "title": "My proposal", "summary": "This is a proposal to send 10 stake to cosmos1...", "proposers": ["cosmos1...", "cosmos1..."], } metadata example: { "title": "", "authors": [""], "summary": "", "details": "", "proposal_forum_url": "", "vote_option_context": "", } Flags: -a, --account-number uint The account number of the signing account (offline mode only) --aux Generate aux signer data instead of sending a tx -b, --broadcast-mode string Transaction broadcasting mode (sync|async) (default "sync") --chain-id string The network chain ID --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) --exec string Set to 1 to try to execute proposal immediately after creation (proposers signatures are considered as Yes votes) --fee-granter string Fee granter grants fees for the transaction --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer --fees string Fees to pay along with transaction; eg: 10uatom --from string Name or address of private key with which to sign --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) -h, --help help for submit-proposal --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) (default "os") --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used --ledger Use a connected Ledger device --node string <host>:<port> to tendermint rpc interface for this chain (default "tcp://localhost:26657") --note string Note to add a description to the transaction (previously --memo) --offline Offline mode (does not allow any online functionality) -o, --output string Output format (text|json) (default "json") -s, --sequence uint The sequence number of the signing account (offline mode only) --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enab
)


def test_group(cluster, tmp_path):
cli = cluster.cosmos_cli()

Expand Down Expand Up @@ -43,11 +57,11 @@ def test_group(cluster, tmp_path):
)

assert rsp["code"] == 0, rsp["raw_log"]
rsp = event_query_tx_for(cli, rsp)

# Get group id from events
group_id = json.loads(
json.loads(rsp["raw_log"])[0]["events"][0]["attributes"][0]["value"]
)
evt = parse_events(rsp["logs"])["cosmos.group.v1.EventCreateGroup"]
group_id = evt["group_id"]

# create group policy
policy_file = tmp_path / "policy.json"
Expand Down Expand Up @@ -79,10 +93,9 @@ def test_group(cluster, tmp_path):
)

assert rsp["code"] == 0, rsp["raw_log"]

group_policy_address = json.loads(
json.loads(rsp["raw_log"])[0]["events"][0]["attributes"][0]["value"]
)
rsp = event_query_tx_for(cli, rsp)
evt = parse_events(rsp["logs"])["cosmos.group.v1.EventCreateGroupPolicy"]
group_policy_address = evt["address"]

# submit a proposal
proposal_file = tmp_path / "proposal.json"
Expand Down Expand Up @@ -119,7 +132,7 @@ def test_group(cluster, tmp_path):
)

assert rsp["code"] == 0, rsp["raw_log"]

rsp = event_query_tx_for(cli, rsp)
proposal_id = json.loads(
json.loads(rsp["raw_log"])[0]["events"][0]["attributes"][0]["value"]
)
Expand All @@ -144,7 +157,7 @@ def test_group(cluster, tmp_path):
)

assert rsp["code"] == 0, rsp["raw_log"]

rsp = event_query_tx_for(cli, rsp)
rsp = json.loads(
cli.raw(
"tx",
Expand All @@ -164,7 +177,7 @@ def test_group(cluster, tmp_path):
)

assert rsp["code"] == 0, rsp["raw_log"]

rsp = event_query_tx_for(cli, rsp)
# query proposal votes
rsp = json.loads(
cli.raw(
Expand Down Expand Up @@ -203,7 +216,7 @@ def test_group(cluster, tmp_path):
)

assert rsp["code"] == 0, rsp["raw_log"]

rsp = event_query_tx_for(cli, rsp)
# check if the proposal executed successfully
assert (
json.loads(
Expand Down

0 comments on commit e8eef21

Please sign in to comment.