Exemple #1
0
 def setUp(self):
     app.config["SKIP_AUTHENTICATION"] = False  # monkey patch
     self.app = app.test_client()
     
     self.btctxstore = BtcTxStore()
     
     db.create_all()
Exemple #2
0
    def setUp(self):
        app.config["SKIP_AUTHENTICATION"] = True  # monkey patch
        app.config["DISABLE_CACHING"] = True

        self.btctxstore = BtcTxStore()
        self.bad_addr = 'notvalidaddress'

        self.app = app.test_client()
        db.create_all()
Exemple #3
0
 def setUp(self):
     app.config["SKIP_AUTHENTICATION"] = False  # monkey patch
     self.app = app.test_client()
     db.create_all()
Exemple #4
0
    def setUp(self):
        app.config["SKIP_AUTHENTICATION"] = True  # monkey patch
        app.config["DISABLE_CACHING"] = True

        self.app = app.test_client()
        db.create_all()
Exemple #5
0
    def setUp(self):
        app.config["SKIP_AUTHENTICATION"] = True  # monkey patch
        app.config["DISABLE_CACHING"] = True

        self.app = app.test_client()
        db.create_all()
Exemple #6
0
    json_data = {'id': randint(0, 9999999), 'total_TB': round(result, 2)}

    return jsonify(json_data)


@app.route('/api/height/<btc_addr>/<int:height>', methods=["GET"])
def set_height(btc_addr, height):
    # create Farmer object to represent user
    user = Farmer(btc_addr)
    user.authenticate(request.headers.get('Authorization'),
                      request.headers.get('Date'))

    # attempt to set height
    try:
        user.set_height(height)
        return make_response("Height accepted.", 200)
    except ValueError:
        msg = "Invalid Bitcoin address."
        return make_response(msg, 400)
    except LookupError:
        msg = "Farmer not found."
        return make_response(msg, 404)


if __name__ == '__main__':  # pragma: no cover
    # Create Database
    db.create_all()

    # Run the Flask app
    app.run(host="0.0.0.0", port=int("5000"), debug=True)
Exemple #7
0
    result = total_shards * (app.config["BYTE_SIZE"] / (1024 * 1024 * 1024 * 1024))  # bytes / 1 TB
    json_data = {"id": randint(0, 9999999), "total_TB": round(result, 2)}

    return jsonify(json_data)


@app.route("/api/height/<btc_addr>/<int:height>", methods=["GET"])
def set_height(btc_addr, height):
    # create Farmer object to represent user
    user = Farmer(btc_addr)
    user.authenticate(request.headers.get("Authorization"), request.headers.get("Date"))

    # attempt to set height
    try:
        user.set_height(height)
        return make_response("Height accepted.", 200)
    except ValueError:
        msg = "Invalid Bitcoin address."
        return make_response(msg, 400)
    except LookupError:
        msg = "Farmer not found."
        return make_response(msg, 404)


if __name__ == "__main__":  # pragma: no cover
    # Create Database
    db.create_all()

    # Run the Flask app
    app.run(host="0.0.0.0", port=int("5000"), debug=True)
Exemple #8
0
 def setUp(self):
     self.app = app.test_client()
     db.create_all()
Exemple #9
0
 def setUp(self):
     self.app = app.test_client()
     db.create_all()