Esempio n. 1
0
    def test_invest(self):
        
        price_per_token = 1000
        token_value = 5

        eth = EthTools("http://localhost:5000")
        eth.init_fixtures("/var/lib/takewing/tests/fixtures.json")

        #Tokens
        base_token = eth.filter(name="BaseToken").contract
        tether = eth.filter(name="Tether").contract

        #Accounts
        deployer = eth.filter(role="Deployer").accounts[0].address
        tester = eth.filter(role="Tester").accounts[0].address
        eth.filter(role="Tester").unlock()

        base_token.instance.mint(deployer, 100, transact={'from': deployer})
        tether.instance.mint(tester, 100000, transact={'from': deployer})
       
        #Crowdsale
        crowdsale = eth.filter(name="MintedCrowdsale").contract
        base_token.instance.addMinter(crowdsale.address, transact={'from': deployer})

        self.assertEqual(base_token.instance.balanceOf(tester), 0)
        self.assertEqual(tether.instance.balanceOf(deployer), 0)

        tether.instance.approve(crowdsale.address,price_per_token*token_value, transact={'from': tester})
        crowdsale.instance.invest(price_per_token*token_value,tether.address, transact={'from': tester})
      
        self.assertEqual(base_token.instance.balanceOf(tester), token_value)
        self.assertEqual(tether.instance.balanceOf(deployer), token_value*price_per_token)
Esempio n. 2
0
    def test_on_pause(self):

        price_per_token = 1000
        token_value = 2

        eth = EthTools("http://localhost:5000")
        eth.init_fixtures("/var/lib/takewing/tests/fixtures.json")

        #Tokens
        base_token = eth.filter(name="BaseToken").contract
        tether = eth.filter(name="Tether").contract

        #Accounts
        deployer = eth.filter(role="Deployer").accounts[0].address
        tester = eth.filter(role="Tester").accounts[0].address
        eth.filter(role="Tester").unlock()

        base_token.instance.mint(deployer, 100, transact={'from': deployer})
        tether.instance.mint(tester, 100000, transact={'from': deployer})

        #Crowdsale
        pausable_crowdsale = eth.filter(name="PausableCrowdsale").contract
        base_token.instance.transfer(pausable_crowdsale.address,100, transact={'from': deployer})
        pausable_crowdsale.instance.pause(transact={'from':deployer})
        #Pause
        with self.assertRaises(ValueError):
            tether.instance.approve(pausable_crowdsale.address,token_value*price_per_token, transact={'from': tester})
            pausable_crowdsale.instance.invest(token_value*price_per_token,tether.address, transact={'from': tester})
Esempio n. 3
0
    def test_user_not_in_list(self):
        
        price_per_token = 1000
        token_value = 5

        eth = EthTools("http://localhost:5000")
        eth.init_fixtures("/var/lib/takewing/tests/fixtures.json")

        #Tokens
        base_token = eth.filter(name="BaseToken").contract
        tether = eth.filter(name="Tether").contract

        #Accounts
        deployer = eth.filter(role="Deployer").accounts[0].address
        tester = eth.filter(role="Tester").accounts[0].address
        eth.filter(role="Tester").unlock()

        #Whitelist
        whitelist_crowdsale = eth.filter(name="WhitelistedCrowdsale").contract 
        base_token.instance.transfer(whitelist_crowdsale.address,100, transact={'from': deployer})    
        
        with self.assertRaises(ValueError):       
            tether.instance.approve(whitelist_crowdsale.address,price_per_token*token_value, transact={'from': tester})
            whitelist_crowdsale.instance.invest(price_per_token*token_value,tether.address, transact={'from': tester})