From e289ad09caa4374e65b74775922c64857e258e83 Mon Sep 17 00:00:00 2001 From: nolash Date: Sun, 24 Oct 2021 15:58:01 +0200 Subject: [PATCH] Rehabilitate tests --- python/eth_token_index/index.py | 12 ++++++++++++ python/run_tests.sh | 14 ++++++++++++++ python/tests/test_tokenindex.py | 7 +++++++ 3 files changed, 33 insertions(+) create mode 100644 python/run_tests.sh diff --git a/python/eth_token_index/index.py b/python/eth_token_index/index.py index 78c57b5..0236793 100644 --- a/python/eth_token_index/index.py +++ b/python/eth_token_index/index.py @@ -85,6 +85,18 @@ class TokenUniqueSymbolIndex(TxFactory): return tx + def add_writer(self, contract_address, sender_address, address, tx_format=TxFormat.JSONRPC, id_generator=None): + enc = ABIContractEncoder() + enc.method('addWriter') + enc.typ(ABIContractType.ADDRESS) + enc.address(address) + data = enc.get() + tx = self.template(sender_address, contract_address, use_nonce=True) + tx = self.set_code(tx, data) + tx = self.finalize(tx, tx_format) + return tx + + def address_of(self, contract_address, token_symbol, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) o = j.template() diff --git a/python/run_tests.sh b/python/run_tests.sh new file mode 100644 index 0000000..fed6f11 --- /dev/null +++ b/python/run_tests.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +set -x +default_pythonpath=$PYTHONPATH:. +export PYTHONPATH=${default_pythonpath:-.} +for f in `ls tests/*.py`; do + python $f + if [ $? -gt 0 ]; then + exit 1 + fi +done +set +x +set +e diff --git a/python/tests/test_tokenindex.py b/python/tests/test_tokenindex.py index 570bb03..7693de5 100644 --- a/python/tests/test_tokenindex.py +++ b/python/tests/test_tokenindex.py @@ -45,6 +45,13 @@ class TestTokenUniqueSymbolIndex(TestAddressDeclaratorBase): self.token_index_address = r['contract_address'] + (tx_hash_hex, o) = c.add_writer(self.token_index_address, self.accounts[0], self.accounts[0]) + self.rpc.do(o) + + o = receipt(tx_hash_hex) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + def test_register(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)