diff --git a/example.c b/example.c index 32fbe8a..1ae95cf 100644 --- a/example.c +++ b/example.c @@ -9,6 +9,8 @@ #include #include +#include "testinput.c" + static void send_json(json_t *req) { char *s = json_dumps(req, JSON_INDENT(2)); @@ -38,7 +40,13 @@ int main(int argc, char**argv) { // send req to server and parse response into req send_json(req); json_decref(req); - req = json_loadf(stdin, JSON_DISABLE_EOF_CHECK, &jsone); + if (argc == 2) + req = json_loadf(stdin, JSON_DISABLE_EOF_CHECK, &jsone); + else + { + req = json_loads(blkmaker_test_input, 0, &jsone); + send_json(req); + } assert(req); err = blktmpl_add_jansson(tmpl, req, time(NULL)); diff --git a/testinput.c b/testinput.c new file mode 100644 index 0000000..0b7f898 --- /dev/null +++ b/testinput.c @@ -0,0 +1,37 @@ +const char *blkmaker_test_input = +"{" + "\"result\": {" + "\"previousblockhash\": \"000000004d424dec1c660a68456b8271d09628a80cc62583e5904f5894a2483c\"," + "\"target\": \"00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff\"," + "\"noncerange\": \"00000000ffffffff\"," + "\"transactions\": []," + "\"sigoplimit\": 20000," + "\"expires\": 120," + "\"longpoll\": \"/LP\"," + "\"height\": 23957," + "\"coinbasetxn\": {" + "\"data\": \"" + "01000000" // txn version + "01" // txn in count + "0000000000000000000000000000000000000000000000000000000000000000" // input coin + "ffffffff" + "13" "02955d0f00456c6967697573005047dc66085f" // scriptSig + "ffffffff" // sequence + "02" // tx out count + "fff1052a01000000" // tx out #1 amount + "19" "76a9144ebeb1cd26d6227635828d60d3e0ed7d0da248fb88ac" // tx out #1 scriptPubKey + "0100000000000000" // tx out #2 amount + "19" "76a9147c866aee1fa2f3b3d5effad576df3dbf1f07475588ac" // tx out #2 scriptPubKey + "00000000" // lock time + "\"" + "}," + "\"version\": 2," + "\"curtime\": 1346886758," + "\"mutable\": [\"coinbase/append\"]," + "\"sizelimit\": 1000000," + "\"bits\": \"1d00ffff\"" + "}," + "\"id\": 2," + "\"error\": null" +"}" +; \ No newline at end of file