# wait for confirmation assert tx.check() is constant.SUCCESS # deploy contract org_name = ''.join(random.choices(string.ascii_letters + string.digits, k=10)) deploy_tx, contract_address = t.deploy_contract(tx.id, [org_name]) assert deploy_tx.check() is constant.SUCCESS print(f"contract address: {contract_address}") contract = Contract(node, contract_address) # contract = Contract(node, c=compiled_contract, args=[org_name]) # mint asset assert contract.execute("mint", [10000 * constant.COIN]).check() is constant.SUCCESS # get asset type asset_type = Asset.asset2str(contract.read("assettype")) # check contract balance assert contract.read("checkBalance") == 10000 * constant.COIN # transfer asset from contract assert contract.execute("transfer", [node.address, 100 * constant.COIN]).check() is constant.SUCCESS assert node.balance(asset=asset_type) == 100 * constant.COIN # check contract balance assert contract.read("checkBalance") == 9900 * constant.COIN # transfer to other address assert node.send(AccountFactory.new().address, 1 * constant.COIN, asset_type).check() is constant.SUCCESS # check balance assert node.balance(asset=asset_type) == 99 * constant.COIN # burn assert contract.execute("burn", asset_value=98 * constant.COIN, asset_type=asset_type).check() is constant.SUCCESS # check balance assert node.balance(asset=asset_type) == 1 * constant.COIN
def test_read_contract(self, node: Node): with patch.object(Session, "post", side_effect=self.post): contract = Contract( node, "0x6361d0441973eb4457d2f8092bbbe303db5eb0f981") assert contract.read("dict", (0, )) == 1