Ejemplo n.º 1
0
    def test_intent_with_dependency(self):
        dependency_signed_intent = self.wallet.sign(
            Intent(
                intent_action=ERC20(
                    "0x6B0F919A5d450Fa5e6283Ff6178dC1FCd195FD2A").transfer(
                        "0x009ab4de1234c7066197d6ed75743add3576591f", 0),
                expiration=10**32,
                max_gas_limit=0,
                max_gas_price=9999999999,
            ))

        intent_action = self.ERC20(self.token_address).transfer({
            "_to":
            "0x009ab4de1234c7066197d6ed75743add3576591f",
            "_value":
            100 * 10**18
        })

        intent = Intent(
            intent_action=intent_action,
            expiration=10**36,
            max_gas_limit=0,
            max_gas_price=9999999999,
        )

        intent.add_dependency(dependency_signed_intent)

        self.assertEqual(
            intent.id(self.wallet),
            "0x4548f83726b36feaa3c5d284d3af30759a341aef4fb93ff85140cdcbfe49f7f8"
        )
Ejemplo n.º 2
0
def test_relay_with_dependency_and_read_status_success():
    wallet_receiver = Wallet(from_bytes(os.urandom(32)))

    intent_action = ERC20(TEST_ERC20).transfer(wallet_receiver.address, 0)
    intent = Intent(intent_action=intent_action)
    intent.add_dependency(success_intents[0])

    signed_intent = wallet.sign(intent)

    response = signed_intent.relay()

    assert response.status_code == 201 or response.status_code == 200
    assert wait_until(lambda: signed_intent.status()["code"] == "completed",
                      640)
    time.sleep(5)

    assert signed_intent.status()["receipt"]["success"]
    success_intents.append(signed_intent)
    assert signed_intent.status()["receipt"]["result"]["output"][0]