loomnetwork / plasma-cash

Plasma Cash Contract & Client. ERC721, ERC20, and ETH compatible
https://loomx.io/developers
Other
271 stars 62 forks source link

improve tests to automatically accommodate simple code changes #35

Closed aupiff closed 6 years ago

aupiff commented 6 years ago

Currently, many values in both the Python and JS test suites are hard-coded. For example, in demo.py we see lines like:

 38 utxo_id = 2
 39 blk_num = 3
 40 alice_to_bob = alice.send_transaction(utxo_id, blk_num, 1,
 41                                       bob.token_contract.account.address)
 42 random_tx = alice.send_transaction(utxo_id-1, blk_num-1, 1,
 43                                    charlie.token_contract.account.address)
 44 authority.submit_block()

This makes the tests very fragile and it requires larges changes to the tests when block-numbering or utxo-assignment changes. Making all the changes necessary to test a new non-sequential UTXO scheme would take many hours and would be error prone.

The tests should be able to fill in the necessary values for block numbers and utxo ids automatically.