Exemplo n.º 1
0
    def setup(self):
        """Setup."""
        self.ledger_api = ledger_apis_registry.make(FETCHAI,
                                                    **FETCHAI_TESTNET_CONFIG)
        self.faucet_api = faucet_apis_registry.make(FETCHAI)
        self.deployer_crypto = crypto_registry.make(FETCHAI)
        self.item_owner_crypto = crypto_registry.make(FETCHAI)

        # Test tokens IDs
        self.token_ids_a = [
            340282366920938463463374607431768211456,
            340282366920938463463374607431768211457,
            340282366920938463463374607431768211458,
            340282366920938463463374607431768211459,
            340282366920938463463374607431768211460,
            340282366920938463463374607431768211461,
            340282366920938463463374607431768211462,
            340282366920938463463374607431768211463,
            340282366920938463463374607431768211464,
            340282366920938463463374607431768211465,
        ]

        self.token_id_b = 680564733841876926926749214863536422912

        # Refill deployer account from faucet
        self.refill_from_faucet(self.ledger_api, self.faucet_api,
                                self.deployer_crypto.address)

        # Refill item owner account from faucet
        self.refill_from_faucet(self.ledger_api, self.faucet_api,
                                self.item_owner_crypto.address)
        self.set_contract()
Exemplo n.º 2
0
def test_get_instance_no_address_cosmwasm(dummy_contract):
    """Tests get instance method with no address for cosmos."""
    ledger_api = ledger_apis_registry.make(
        COSMOS, address="https://rest-agent-land.prod.fetch-ai.com:443",
    )
    instance = dummy_contract.get_instance(ledger_api)
    assert instance is None
Exemplo n.º 3
0
def test_get_instance_no_address(dummy_contract):
    """Tests the from config method and contract registry registration."""
    ledger_api = ledger_apis_registry.make(
        "ethereum",
        address="https://ropsten.infura.io/v3/f00f7b3ba0e848ddbdc8941c527447fe",
    )
    instance = dummy_contract.get_instance(ledger_api)
    assert type(instance) == web3._utils.datatypes.PropertyCheckingFactory
Exemplo n.º 4
0
def test_get_instance_no_address_ethereum(dummy_contract):
    """Tests get instance method with no address for ethereum."""
    ledger_api = ledger_apis_registry.make(
        ETHEREUM,
        address="https://ropsten.infura.io/v3/f00f7b3ba0e848ddbdc8941c527447fe",
    )
    instance = dummy_contract.get_instance(ledger_api)
    assert type(instance) == web3._utils.datatypes.PropertyCheckingFactory
Exemplo n.º 5
0
def test_get_instance_no_address_cosmwasm(dummy_contract):
    """Tests get instance method with no address for fetchai."""
    ledger_api = ledger_apis_registry.make(
        FETCHAI,
        address=FETCHAI_DEFAULT_ADDRESS,
    )
    instance = dummy_contract.get_instance(ledger_api)
    assert instance is None
Exemplo n.º 6
0
def test_get_instance_no_address_ethereum(dummy_contract):
    """Tests get instance method with no address for ethereum."""
    ledger_api = ledger_apis_registry.make(
        ETHEREUM,
        address=ETHEREUM_DEFAULT_ADDRESS,
    )
    instance = dummy_contract.get_instance(ledger_api)
    assert type(instance) == web3._utils.datatypes.PropertyCheckingFactory
Exemplo n.º 7
0
def test_get_deploy_transaction_cosmwasm(dummy_contract):
    """Tests the deploy transaction classmethod for fetchai."""
    fetchai_crypto = crypto_registry.make(FETCHAI)
    ledger_api = ledger_apis_registry.make(FETCHAI, address=FETCHAI_DEFAULT_ADDRESS,)
    deploy_tx = dummy_contract.get_deploy_transaction(
        ledger_api, fetchai_crypto.address
    )
    assert deploy_tx is not None and len(deploy_tx) == 6
    assert all(
        key in ["account_number", "chain_id", "fee", "memo", "msgs", "sequence"]
        for key in deploy_tx.keys()
    )
Exemplo n.º 8
0
def test_get_deploy_transaction_cosmwasm(dummy_contract):
    """Tests the deploy transaction classmethod for cosmos."""
    cosmos_crypto = crypto_registry.make(COSMOS)
    ledger_api = ledger_apis_registry.make(
        COSMOS, address="https://rest-agent-land.prod.fetch-ai.com:443",
    )
    deploy_tx = dummy_contract.get_deploy_transaction(ledger_api, cosmos_crypto.address)
    assert deploy_tx is not None and len(deploy_tx) == 6
    assert all(
        key in ["account_number", "chain_id", "fee", "memo", "msgs", "sequence"]
        for key in deploy_tx.keys()
    )
Exemplo n.º 9
0
def test_get_deploy_transaction_ethereum(dummy_contract):
    """Tests the deploy transaction classmethod for ethereum."""
    ethereum_crypto = crypto_registry.make(ETHEREUM)
    ledger_api = ledger_apis_registry.make(
        ETHEREUM,
        address="https://ropsten.infura.io/v3/f00f7b3ba0e848ddbdc8941c527447fe",
    )
    deploy_tx = dummy_contract.get_deploy_transaction(
        ledger_api, ethereum_crypto.address
    )
    assert deploy_tx is not None and len(deploy_tx) == 6
    assert all(
        key in ["from", "value", "gas", "gasPrice", "nonce", "data"]
        for key in deploy_tx.keys()
    )
Exemplo n.º 10
0
def test_get_deploy_transaction_ethereum(dummy_contract):
    """Tests the deploy transaction classmethod for ethereum."""
    ethereum_crypto = crypto_registry.make(ETHEREUM)
    ledger_api = ledger_apis_registry.make(ETHEREUM, address=ETHEREUM_DEFAULT_ADDRESS,)
    with patch(
        "web3.contract.ContractConstructor.buildTransaction",
        return_value={"data": "0xstub"},
    ):
        deploy_tx = dummy_contract.get_deploy_transaction(
            ledger_api, ethereum_crypto.address
        )
    assert deploy_tx is not None and len(deploy_tx) == 6
    assert all(
        key in ["from", "value", "gas", "gasPrice", "nonce", "data"]
        for key in deploy_tx.keys()
    )
Exemplo n.º 11
0
def ledger_api(request):
    ledger_id, config = request.param
    api = ledger_apis_registry.make(ledger_id, **config)
    yield api
Exemplo n.º 12
0
def ledger_api(request):
    """Ledger api fixture."""
    ledger_id, config = request.param
    api = ledger_apis_registry.make(ledger_id, **config)
    yield api