Skip to content

Commit

Permalink
test store list
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed May 2, 2024
1 parent 1925d5e commit fa6497f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (h *ProposalHandler) SetBlockList(blob []byte) error {
if err != nil {
return fmt.Errorf("invalid bech32 address: %s, err: %w", s, err)

Check warning on line 65 in app/proposal.go

View check run for this annotation

Codecov / codecov/patch

app/proposal.go#L61-L65

Added lines #L61 - L65 were not covered by tests
}
m[string(addr)] = struct{}{}
m[addr.String()] = struct{}{}

Check warning on line 67 in app/proposal.go

View check run for this annotation

Codecov / codecov/patch

app/proposal.go#L67

Added line #L67 was not covered by tests
}

h.Blocklist = m
Expand All @@ -84,7 +84,7 @@ func (h *ProposalHandler) ValidateTransactions(txs [][]byte) error {
}

for _, signer := range sigTx.GetSigners() {
if _, ok := h.Blocklist[string(signer)]; ok {
if _, ok := h.Blocklist[signer.String()]; ok {
return fmt.Errorf("signer is blocked: %s", signer.String())

Check warning on line 88 in app/proposal.go

View check run for this annotation

Codecov / codecov/patch

app/proposal.go#L86-L88

Added lines #L86 - L88 were not covered by tests
}
}
Expand Down
5 changes: 4 additions & 1 deletion integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def staking_pool(self, bonded=True):

def transfer(self, from_, to, coins, generate_only=False, fees=None, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
return json.loads(
rsp = json.loads(
self.raw(
"tx",
"bank",
Expand All @@ -349,6 +349,9 @@ def transfer(self, from_, to, coins, generate_only=False, fees=None, **kwargs):
**kwargs,
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def get_delegated_amount(self, which_addr):
return json.loads(
Expand Down
15 changes: 11 additions & 4 deletions integration_tests/test_e2ee.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from .utils import encrypt_file


def test_encrypt_decrypt(cronos):
cli = cronos.cosmos_cli()

Expand All @@ -19,6 +16,16 @@ def test_encrypt_decrypt(cronos):

# prepare data file to encrypt
content = "Hello World!"
cipherfile = encrypt_file(cli, content)
plainfile = cli.data_dir / "plaintext"
plainfile.write_text(content)

cipherfile = cli.data_dir / "ciphertext"
cli.encrypt(
plainfile,
cli.address("validator"),
cli.address("community"),
output=cipherfile,
)

assert cli.decrypt(cipherfile, identity="key0") == content
assert cli.decrypt(cipherfile, identity="key1") == content
35 changes: 34 additions & 1 deletion integration_tests/test_gov_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
import json

import pytest
from pystarport import ports

from .utils import CONTRACTS, approve_proposal, deploy_contract, eth_to_bech32
from .utils import (
CONTRACTS,
approve_proposal,
deploy_contract,
eth_to_bech32,
wait_for_new_blocks,
wait_for_port,
)

pytestmark = pytest.mark.gov

Expand Down Expand Up @@ -86,3 +94,28 @@ def test_gov_update_params(cronos, tmp_path):
rsp = cli.query_params()
print("params", rsp)
assert rsp == params

# gen two keys for two accounts
name = "e2ee-identity"
pubkey0 = cli.keygen(keyring_name=name)
cli.register_e2ee_key(pubkey0, _from="validator")
assert cli.query_e2ee_key(cli.address("validator")) == pubkey0
cronos.supervisorctl("stop", "cronos_777-1-node0")
cronos.supervisorctl("start", "cronos_777-1-node0")
wait_for_port(ports.evmrpc_port(cronos.base_port(0)))

addr = cli.address("user")
plainfile = cli.data_dir / "plaintext"
plainfile.write_text(json.dumps({"addresses": [addr]}))
cipherfile = cli.data_dir / "ciphertext"
cli.encrypt(
plainfile,
cli.address("validator"),
output=cipherfile,
)
rsp = cli.store_blocklist(cipherfile, from_="validator")
assert rsp["code"] == 0, rsp["raw_log"]
wait_for_new_blocks(cli, 4)
rsp = cli.transfer(addr, cli.address("validator"), "1basecro")

Check failure on line 119 in integration_tests/test_gov_update_params.py

View workflow job for this annotation

GitHub Actions / integration_tests (gov)

test_gov_update_params[True] AssertionError: (cronosd query event-query-tx-for 5347C57291AF22002CFBC217CA17E8BD100450AD93DA39BCB36090B6FC3C0232 --home /tmp/pytest-of-runner/pytest-0/indexer0/cronos_777-1/node0)
assert rsp["code"] != 0
assert "signer is blocked" in rsp["raw_log"]
14 changes: 0 additions & 14 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,17 +732,3 @@ def get_send_enable(port):
url = f"http://127.0.0.1:{port}/cosmos/bank/v1beta1/params"
raw = requests.get(url).json()
return raw["params"]["send_enabled"]


def encrypt_file(cli, content):
plainfile = cli.data_dir / "plaintext"
plainfile.write_text(content)

cipherfile = cli.data_dir / "ciphertext"
cli.encrypt(
plainfile,
cli.address("validator"),
cli.address("community"),
output=cipherfile,
)
return cipherfile

0 comments on commit fa6497f

Please sign in to comment.