This means we don't have to manually choose what to link against, which is much of the complexity of our Makefiles: the compiler will automatically use any object files it needs to link. We already do this for ccan as libccan.a, now we have libcommon.a. We don't link against it for *everything*, as some tests require their own versions. Notes: 1. I get rid of the weird plugins/test/Makefile2 (accidental commit?) 2. Many tests change due to update-mocks. 3. In some places I added the missing dependency on the Makefile itself, though most are in the next patch. Before: Total program size: 221366528 Total tests size: 364243856 After: Total program size: 190733656 Total tests size: 337880888 Build time from make clean (RUST=0) (includes building external libs): Before: real 0m38.227000-44.245000(41.8222+/-1.6)s user 3m2.105000-33.696000(23.1442+/-8.4)s sys 0m35.054000-42.269000(39.7231+/-2)s After: real 0m38.944000-40.416000(40.1131+/-0.4)s user 3m6.790000-17.159000(15.0571+/-2.8)s sys 0m35.304000-37.336000(36.8942+/-0.57)s Build time after touch config.vars (RUST=0): Before: real 0m18.928000-22.776000(21.5084+/-1.1)s user 2m8.613000-36.567000(27.7281+/-7.7)s sys 0m20.458000-23.436000(22.3963+/-0.77)s After: real 0m19.831000-21.862000(21.5528+/-0.58)s user 2m15.361000-30.731000(28.4798+/-4.4)s sys 0m21.056000-22.339000(22.0346+/-0.35)s Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> rusty@rusty-Framework:~/devel/cvs/lightni
81 lines
2.6 KiB
C
81 lines
2.6 KiB
C
#include "config.h"
|
|
#include <assert.h>
|
|
#include <bitcoin/psbt.c>
|
|
#include <bitcoin/shadouble.c>
|
|
#include <bitcoin/signature.c>
|
|
#include <bitcoin/tx.c>
|
|
#include <bitcoin/varint.c>
|
|
#include <ccan/str/hex/hex.h>
|
|
#include <common/setup.h>
|
|
#include <common/utils.h>
|
|
#include <stdio.h>
|
|
|
|
/* AUTOGENERATED MOCKS START */
|
|
/* AUTOGENERATED MOCKS END */
|
|
|
|
const char extended_tx[] =
|
|
"02000000000101b5bef485c41d0d1f58d1e8a561924ece5c476d86cff063ea10c8df06136e"
|
|
"b31d00000000171600144aa38e396e1394fb45cbf83f48d1464fbc9f498fffffffff014033"
|
|
"0f000000000017a9140580ba016669d3efaf09a0b2ec3954469ea2bf038702483045022100"
|
|
"f2abf9e9cf238c66533af93f23937eae8ac01fb6f105a00ab71dbefb9637dc9502205c1ac7"
|
|
"45829b3f6889607961f5d817dfa0c8f52bdda12e837c4f7b162f6db8a701210204096eb817"
|
|
"f7efb414ef4d3d8be39dd04374256d3b054a322d4a6ee22736d03b00000000";
|
|
|
|
static void hexeq(const void *p, size_t len, const char *hex)
|
|
{
|
|
char *tmphex = tal_hexstr(NULL, p, len);
|
|
|
|
if (!streq(hex, tmphex)) {
|
|
fprintf(stderr, "Expected '%s' got '%s'", hex, tmphex);
|
|
abort();
|
|
}
|
|
tal_free(tmphex);
|
|
}
|
|
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
common_setup(argv[0]);
|
|
chainparams = chainparams_for_network("bitcoin");
|
|
|
|
struct bitcoin_tx *tx;
|
|
|
|
tx = bitcoin_tx_from_hex(NULL, extended_tx, strlen(extended_tx));
|
|
assert(tx);
|
|
|
|
/* Canonical results from Nichola Dorier's
|
|
* http://n.bitcoin.ninja/checktx
|
|
* With much thanks!
|
|
*/
|
|
assert(tx->wtx->num_inputs == 1);
|
|
assert(tx->wtx->num_outputs == 1);
|
|
|
|
reverse_bytes(tx->wtx->inputs[0].txhash,
|
|
sizeof(tx->wtx->inputs[0].txhash));
|
|
hexeq(tx->wtx->inputs[0].txhash, sizeof(tx->wtx->inputs[0].txhash),
|
|
"1db36e1306dfc810ea63f0cf866d475cce4e9261a5e8d1581f0d1dc485f4beb5");
|
|
assert(tx->wtx->inputs[0].index == 0);
|
|
|
|
/* This is a p2sh-p2wpkh: */
|
|
/* ScriptSig is push of "version 0 + hash of pubkey" */
|
|
hexeq(tx->wtx->inputs[0].script, tx->wtx->inputs[0].script_len,
|
|
"16" "00" "144aa38e396e1394fb45cbf83f48d1464fbc9f498f");
|
|
|
|
/* Witness with 2 items */
|
|
assert(tx->wtx->inputs[0].witness);
|
|
assert(tx->wtx->inputs[0].witness->num_items == 2);
|
|
|
|
hexeq(tx->wtx->inputs[0].witness->items[0].witness,
|
|
tx->wtx->inputs[0].witness->items[0].witness_len,
|
|
"3045022100f2abf9e9cf238c66533af93f23937eae8ac01fb6f105a00ab71dbe"
|
|
"fb9637dc9502205c1ac745829b3f6889607961f5d817dfa0c8f52bdda12e837c"
|
|
"4f7b162f6db8a701");
|
|
hexeq(tx->wtx->inputs[0].witness->items[1].witness,
|
|
tx->wtx->inputs[0].witness->items[1].witness_len,
|
|
"0204096eb817f7efb414ef4d3d8be39dd04374256d3b054a322d4a6ee22736d0"
|
|
"3b");
|
|
|
|
tal_free(tx);
|
|
common_shutdown();
|
|
return 0;
|
|
}
|