def test_new(self):
        buyer_balance = self.s.block.get_balance(tester.a0)

        expiry = self.s.block.timestamp + 86400
        o1 = self.s.send(tester.k0,
                         self.trade_contract,
                         self.ETH_AMOUNT,
                         funid=self.TRADE_FUN_NEW,
                         abi=[
                             self.SELLER,
                             int(self.watch_contract, 16), self.BTC_ADDRESS,
                             self.BTC_AMOUNT, expiry
                         ])
        assert o1 == [2]  # pending

        assert self._storage('0x') == '0x' + tester.a0  # buyer
        assert self._storage('0x01') == '0x' + tester.a1  # seller
        assert self._storage('0x02') == '0x' + self.watch_contract
        assert self._storage('0x03') == xhex(self.BTC_ADDRESS)
        assert self._storage('0x04') == xhex(self.BTC_AMOUNT)
        assert self._storage('0x05') == xhex(expiry)
        assert self._storage('0x06') == '0x02'  # state = pending

        # amount escrowed
        assert self.s.block.get_balance(self.trade_contract) == self.ETH_AMOUNT
        assert self.s.block.get_balance(
            tester.a0) == buyer_balance - self.ETH_AMOUNT
    def test_watch(self):
        o1 = self.s.send(tester.k0, self.c, 0, funid=self.FUN_WATCH, abi=[self.ADDRESS])
        assert o1 == [1]

        assert self._storage('0x04') == '0x01'  # nr_contracts
        assert self._storage('0x05') == xhex(self.ADDRESS)

        o2 = self.s.send(tester.k0, self.c, 0, funid=4, abi=[self.ADDRESS])
        assert o2 == [0, 0, 1, self.s.block.timestamp]
    def test_new(self):
        buyer_balance = self.s.block.get_balance(tester.a0)

        expiry = self.s.block.timestamp + 86400
        o1 = self.s.send(tester.k0, self.trade_contract, self.ETH_AMOUNT, funid=self.TRADE_FUN_NEW,
                         abi=[self.SELLER, int(self.watch_contract, 16), self.BTC_ADDRESS, self.BTC_AMOUNT, expiry])
        assert o1 == [2]  # pending

        assert self._storage('0x') == '0x' + tester.a0  # buyer
        assert self._storage('0x01') == '0x' + tester.a1  # seller
        assert self._storage('0x02') == '0x' + self.watch_contract
        assert self._storage('0x03') == xhex(self.BTC_ADDRESS)
        assert self._storage('0x04') == xhex(self.BTC_AMOUNT)
        assert self._storage('0x05') == xhex(expiry)
        assert self._storage('0x06') == '0x02'  # state = pending

        # amount escrowed
        assert self.s.block.get_balance(self.trade_contract) == self.ETH_AMOUNT
        assert self.s.block.get_balance(tester.a0) == buyer_balance - self.ETH_AMOUNT
示例#4
0
    def test_watch(self):
        o1 = self.s.send(tester.k0,
                         self.c,
                         0,
                         funid=self.FUN_WATCH,
                         abi=[self.ADDRESS])
        assert o1 == [1]

        assert self._storage('0x04') == '0x01'  # nr_contracts
        assert self._storage('0x05') == xhex(self.ADDRESS)

        o2 = self.s.send(tester.k0, self.c, 0, funid=4, abi=[self.ADDRESS])
        assert o2 == [0, 0, 1, self.s.block.timestamp]