poanetwork / poa-popa

DApp for proof of physical address (PoPA) attestation for validators of POA Network
https://popa.poa.network
GNU General Public License v3.0
24 stars 18 forks source link

(Improvement) Add auto tests for the Main.sol contract #15

Closed phahulin closed 6 years ago

phahulin commented 6 years ago

Prerequisites

Tests

  1. Address registration
    • [x] register_address must fail if at least one of parameters is an empty string ""
    • [x] register_address must fail if passed eth value is less than passed price_wei
    • [x] register_address must fail if signature is constructed from incorrect parameters. Signature must be calculated from the following parameters in this order:
    • msg.sender
    • name
    • country
    • state
    • city
    • location
    • zip
    • price_wei
    • confirmation_code_sha3

and signed with signer's private key

  1. Address confirmation
    • [x] confirm_address must fail if at least one of parameters is an empty string
    • [x] confirm_address must succeed without payment
    • [x] confirm_address must fail if signature is constructed from incorrect parameters. Signature must be calculated from the following parameters in this order:
    • msg.sender
    • confirmation_code_plain

and signed with signer's private key

  1. Withdrawals
    • [x] withdraw_some must fail if sender of the transaction is not owner
    • [x] withdraw_some must revert if passed amount_wei is less than contract's balance
    • [x] withdraw_some must succeed if amount_wei is correct and sender of the transaction is owner. Contract's balance should decrease by amount_wei, owner's balance should increase by amount_wei - gas_fee
  1. Changing signer

    • [x] set_signer must fail if sender of the transaction is not owner
    • [x] set_signer must succeed if sender of the transaction is owner. signer must be updated to the new signer's address. Also check
    • generate some random data, sign it twice: with an old signer's key and new signer's key, then check that signer_is_valid returns false on the first one and true on the second one
  2. Helpers

    • [x] user_exists must return true for an existing user, false for a non-existing user
pablofullana commented 6 years ago

Relates to #118