예제 #1
0
파일: test.py 프로젝트: todicus/hmt-escrow
    def test_create_start_contract_spend_to_oracle_fees(self):
        manifest = REQ_JSON
        escrow = api.get_job()
        address = ADDR
        address_balance = escrow.call().getAddressBalance(address)
        to_address = TO_ADDR
        to_address_balance = escrow.call().getAddressBalance(to_address)

        self.assertTrue(api._transfer_to_address(escrow.address, self.amount))

        address_balance_after_transfer = escrow.call().getAddressBalance(
            address)
        self.assertEqual(address_balance_after_transfer,
                         address_balance - 1000)

        self.assertTrue(
            api.setup_job(escrow, self.amount, self.oracle_stake, manifest,
                          Web3.toBytes(0)))
        self.assertEqual(api._balance(escrow), self.amount)
        api.partial_payout(escrow, self.amount, to_address, manifest,
                           Web3.toBytes(0))

        address_balance_after_payout = escrow.call().getAddressBalance(address)

        # Stake has been set to 5% which in these tests is 50.
        # 100 is the correct fee because our address is both the reputation and recording oracle.
        self.assertEqual(address_balance_after_payout,
                         address_balance_after_transfer + 100)

        to_address_balance_after_payout = escrow.call().getAddressBalance(
            to_address)
        self.assertEqual(to_address_balance_after_payout,
                         to_address_balance + 900)
예제 #2
0
파일: test.py 프로젝트: todicus/hmt-escrow
 def test_contract_needs_funding(self):
     # We shouldn't test this on our internal blockchain because it's slow
     manifest = REQ_JSON
     contract = api.get_job()
     self.assertFalse(
         api.setup_job(contract, self.amount, self.oracle_stake, manifest,
                       Web3.toBytes(0)))
예제 #3
0
파일: test.py 프로젝트: todicus/hmt-escrow
    def test_create_start_contract(self):
        # We shouldn't test this on our internal blockchain because it's slow
        manifest = REQ_JSON

        contract = api.get_job()
        self.assertTrue(api._transfer_to_address(contract.address,
                                                 self.amount))
        self.assertTrue(
            api.setup_job(contract, self.amount, self.oracle_stake, manifest,
                          Web3.toBytes(0)))
        self.assertEqual(api._balance(contract), self.amount)
예제 #4
0
파일: test.py 프로젝트: todicus/hmt-escrow
    def test_intermediate_results(self):
        # We shouldn't test this on our internal blockchain because it's slow
        manifest = REQ_JSON

        contract = api.get_job()
        self.assertTrue(api._transfer_to_address(contract.address,
                                                 self.amount))
        self.assertTrue(
            api.setup_job(contract, self.amount, self.oracle_stake, manifest,
                          Web3.toBytes(0)))
        api.store_results(contract, manifest, "0")
        self.assertEquals(manifest, api._getIURL(contract))
예제 #5
0
파일: test.py 프로젝트: todicus/hmt-escrow
 def test_create_start_contract_spend_to_complete(self):
     # We shouldn't test this on our internal blockchain because it's slow
     manifest = REQ_JSON
     contract = api.get_job()
     self.assertTrue(api._transfer_to_address(contract.address,
                                              self.amount))
     self.assertTrue(
         api.setup_job(contract, self.amount, self.oracle_stake, manifest,
                       Web3.toBytes(0)))
     self.assertEqual(api._balance(contract), self.amount)
     to_address = TO_ADDR
     api.partial_payout(contract, self.amount, to_address, manifest,
                        Web3.toBytes(0))
     self.assertEquals(manifest, api._getFURL(contract))