eth-token-index

Token symbol to address unique index
Log | Files | Refs

commit e289ad09caa4374e65b74775922c64857e258e83
parent 4d1da0c7c728f86e01b21ec039b12300a8b5a792
Author: nolash <dev@holbrook.no>
Date:   Sun, 24 Oct 2021 15:58:01 +0200

Rehabilitate tests

Diffstat:
Mpython/eth_token_index/index.py | 12++++++++++++
Apython/run_tests.sh | 14++++++++++++++
Mpython/tests/test_tokenindex.py | 7+++++++
3 files changed, 33 insertions(+), 0 deletions(-)

diff --git 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 @@ -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 @@ -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)