Skip to content

Token Wizard Smart Contracts Tests

Victor Baranov edited this page Sep 21, 2018 · 1 revision

Token wizard smart contracts tests are written in javascript with Truffle framework. Contracts are deploying in testrpc with the script. Test scripts are added to Travis CI and executed at every pull request.

If you want to start it by yourself, simply run the command npm test from the root directory. It will start testrpc at port 8545, Truffle will compile, deploy contracts to it and Truffle will execute tests.

Note: Kill testrpc after tests will be executed:

sudo kill `sudo lsof -t -i:8545`.

Currently, available tests cover the following scenario:

The updatable, whitelisted one tier crowdsale contract with one address in whitelist and reserved tokens for the same address (both: in absolute values and in percentage)

Checklist of contracts' testing:

  Contract: CrowdsaleTokenExt
    ✓ should reject setReservedTokensListMultiple another call (38ms)
    ✓ should get number of reserved tokens for investor (44ms)
    ✓ should get reserved tokens in percentage unit for investor
    ✓ should get percentage decimals for reserved tokens (39ms)
    ✓ should get mint agent: crowdsale contract
    ✓ should get mint agent: NullFinalizeAgentExt contract
    ✓ should get mint agent: ReservedTokensFinalizeAgent contract
    ✓ should get release agent
    ✓ should get owner
    ✓ should allow claiming tokens (1181ms)
  Contract: FlatPricingExt
    ✓ should return rate of pricing strategy contract
    ✓ should reject update rate transaction (it can be done only from crowdsale contract)
    ✓ should reject set tier transaction (because we already set it)
  Contract: MintedTokenCappedCrowdsaleExt
    ✓ shouldn't set finalize agent once more
    ✓ shouldn't set pricing strategy once more
    ✓ shouldn't update rate
    ✓ shouldn't update max cap
    ✓ shouldn't set startsAt
    ✓ should get last tier tier for crowdsale contract (48ms)
    ✓ should get name of crowdsale (46ms)
    ✓ should get finalize agent
    ✓ should get pricing strategy
    ✓ should get isTierJoined
    ✓ should get tier position (53ms)
    ✓ should get early participant white list (40ms)
    ✓ should get early participant white list minCap (41ms)
    ✓ should get early participant white list maxCap (40ms)
    ✓ shouldn't accept investment from not whitelisted user (107ms)
    ✓ shouldn't accept investment from whitelisted user less than minCap (157ms)
    ✓ shouldn't accept investment from whitelisted user more than maxCap (109ms)
    ✓ should accept buy from whitelisted user 1 within cap range (221ms)
    ✓ should return updated balance of multisig (134ms)
    ✓ should accept buy from whitelisted user 2 within cap range (219ms)
    ✓ should return updated balance of multisig (111ms)
    ✓ should return token's balance we have bought in previous step
    ✓ should accept buy less than minCap at second buy (220ms)
    ✓ should return updated balance of multisig (131ms)
    ✓ should accept buy of fractionated amount of tokens from whitelisted user within cap range (296ms)
    ✓ should return token balance we have bought in previous step
    ✓ should return updated balance of multisig (113ms)
    ✓ shouldn't accept investment from whitelisted user that exceeds maxCap (111ms)
    ✓ should get the count of whitelisted participants
    ✓ should get the whitelist participant from the array
    ✓ should not allow adding the 0 address to the whitelist
    ✓ should not allow adding an address to the whitelist with a minCap greater than the maxCap (60ms)
    ✓ should not allow adding an address to the whitelist with a maxCap of 0 (40ms)
    ✓ should not add an address to the whitelist that was already added (103ms)
    ✓ should can not distribute reserved tokens (145ms)
    ✓ should set endsAt (60ms)
    ✓ should get state of crowdsale (91ms)
    ✓ should get state of crowdsale (86ms)
    ✓ should get state of crowdsale (93ms)
    ✓ should get state of crowdsale (87ms)
    ✓ should get state of crowdsale (98ms)
    ✓ should get state of crowdsale (83ms)
    ✓ should get state of crowdsale (134ms)
    ✓ should get state of crowdsale (93ms)
    ✓ should get state of crowdsale (97ms)
    ✓ should get state of crowdsale (98ms)
    ✓ should not set endsAt, if crowdsale is already ended
    ✓ should can distribute reserved tokens (168ms)
    ✓ should fail finalize (59ms)
    ✓ should fail distribution of reserved tokens with 0 batch (83ms)
    ✓ should distribute 1st batch of reserved tokens (224ms)
    ✓ should return that reserved tokens are distributed for one address
    ✓ should return that not all reserved tokens are distributed
    ✓ should fail finalize (62ms)
    ✓ should distribute reserved tokens (242ms)
    ✓ should return that all reserved tokens are distributed
    ✓ should return that all reserved tokens are distributed
    ✓ should fail distribution of reserved tokens (62ms)
    ✓ should can not distribute reserved tokens (161ms)
    ✓ should finalize crowdsale (96ms)
    ✓ should return updated token balance of user 1 including reserved tokens
    ✓ should return updated token balance of user 2 including reserved tokens
  Contract: Registry
    ✓ should start with an empty mapping
    ✓ should get 0 as number of deployed contracts
    ✓ should add a deployed contract (67ms)
    ✓ should add just one deployed contract
    ✓ should get 1 as number of deployed contracts
    ✓ should emit an Added event when adding an address (163ms)
  Contract: ReservedTokensFinalizeAgent
    ✓ 
  Contract: SafeMathLibExt
    ✓ should accurately multiply numbers
    ✓ should accurately divide numbers
    ✓ should accurately subtract numbers
    ✓ should accurately add numbers
  86 passing (8s)
Clone this wiki locally