From 2c3c845d5b1bb23b1211877e04c2c4df0e593660 Mon Sep 17 00:00:00 2001 From: dflate Date: Sat, 22 Sep 2018 16:42:03 +0000 Subject: [PATCH 1/7] [WIP] code checks, run-bins and py's from test to work with Groestlcoin make check etc. for Groestlcoin Signed-off-by: dflate --- channeld/test/run-full_channel.c | 109 +++++++------- common/test/run-bolt11.c | 16 +- doc/lightning-listfunds.7 | 8 +- doc/lightning-listfunds.7.txt | 2 +- doc/lightningd-config.5 | 6 +- doc/lightningd-config.5.txt | 2 +- gossipd/routing.c | 6 +- lightningd/test/run-funding_tx.c | 11 +- onchaind/test/run-grind_feerate.c | 44 +++--- tests/benchmark.py | 61 ++++---- tests/btcproxy.py | 2 +- tests/conftest.py | 0 tests/fixtures.py | 21 ++- tests/requirements.txt | 0 tests/test_closing.py | 10 +- tests/test_connection.py | 60 +++++--- tests/test_gossip.py | 0 tests/test_invoices.py | 0 tests/test_misc.py | 26 ++-- tests/test_pay.py | 237 +++--------------------------- tests/utils.py | 12 +- 21 files changed, 242 insertions(+), 391 deletions(-) mode change 100644 => 100755 tests/benchmark.py mode change 100644 => 100755 tests/btcproxy.py mode change 100644 => 100755 tests/conftest.py mode change 100644 => 100755 tests/fixtures.py mode change 100644 => 100755 tests/requirements.txt mode change 100644 => 100755 tests/test_closing.py mode change 100644 => 100755 tests/test_connection.py mode change 100644 => 100755 tests/test_gossip.py mode change 100644 => 100755 tests/test_invoices.py mode change 100644 => 100755 tests/test_misc.py mode change 100644 => 100755 tests/test_pay.py mode change 100644 => 100755 tests/utils.py diff --git a/channeld/test/run-full_channel.c b/channeld/test/run-full_channel.c index f8098acf1e34..71f11623981c 100644 --- a/channeld/test/run-full_channel.c +++ b/channeld/test/run-full_channel.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -144,7 +145,7 @@ static const struct htlc **include_htlcs(struct channel *channel, enum side side memset(&preimage, i, sizeof(preimage)); sha256(&hash, &preimage, sizeof(preimage)); e = channel_add_htlc(channel, sender, i, msatoshi, 500+i, &hash, - dummy_routing, NULL); + dummy_routing, NULL); assert(e == CHANNEL_ERR_ADD_OK); htlcs[i] = channel_get_htlc(channel, sender, i); } @@ -190,24 +191,24 @@ static void tx_must_be_eq(const struct bitcoin_tx *a, for (i = 0; i < tal_count(lina); i++) { if (i >= tal_count(linb)) errx(1, "Second tx is truncated:\n" - "%s\n" - "%s", - tal_hex(tmpctx, lina), - tal_hex(tmpctx, linb)); + "%s\n" + "%s", + tal_hex(tmpctx, lina), + tal_hex(tmpctx, linb)); if (lina[i] != linb[i]) errx(1, "tx differ at offset %zu:\n" - "%s\n" - "%s", - i, - tal_hex(tmpctx, lina), - tal_hex(tmpctx, linb)); + "%s\n" + "%s", + i, + tal_hex(tmpctx, lina), + tal_hex(tmpctx, linb)); } if (i != tal_count(linb)) errx(1, "First tx is truncated:\n" - "%s\n" - "%s", - tal_hex(tmpctx, lina), - tal_hex(tmpctx, linb)); + "%s\n" + "%s", + tal_hex(tmpctx, lina), + tal_hex(tmpctx, linb)); } static void txs_must_be_eq(struct bitcoin_tx **a, struct bitcoin_tx **b) @@ -216,7 +217,7 @@ static void txs_must_be_eq(struct bitcoin_tx **a, struct bitcoin_tx **b) if (tal_count(a) != tal_count(b)) errx(1, "A has %zu txs, B has %zu", - tal_count(a), tal_count(b)); + tal_count(a), tal_count(b)); for (i = 0; i < tal_count(a); i++) tx_must_be_eq(a[i], b[i]); @@ -251,7 +252,7 @@ static void send_and_fulfill_htlc(struct channel *channel, ret = channel_sending_revoke_and_ack(channel); assert(!ret); assert(channel_fulfill_htlc(channel, LOCAL, 1337, &r, NULL) - == CHANNEL_ERR_REMOVE_OK); + == CHANNEL_ERR_REMOVE_OK); ret = channel_rcvd_commit(channel, &changed_htlcs); assert(ret); ret = channel_sending_revoke_and_ack(channel); @@ -261,7 +262,7 @@ static void send_and_fulfill_htlc(struct channel *channel, ret = channel_rcvd_revoke_and_ack(channel, &changed_htlcs); assert(!ret); assert(channel_get_htlc(channel, sender, 1337)->state - == RCVD_REMOVE_ACK_REVOCATION); + == RCVD_REMOVE_ACK_REVOCATION); } else { ret = channel_rcvd_commit(channel, &changed_htlcs); assert(ret); @@ -272,7 +273,7 @@ static void send_and_fulfill_htlc(struct channel *channel, ret = channel_rcvd_revoke_and_ack(channel, &changed_htlcs); assert(!ret); assert(channel_fulfill_htlc(channel, REMOTE, 1337, &r, NULL) - == CHANNEL_ERR_REMOVE_OK); + == CHANNEL_ERR_REMOVE_OK); ret = channel_sending_commit(channel, &changed_htlcs); assert(ret); ret = channel_rcvd_revoke_and_ack(channel, &changed_htlcs); @@ -282,7 +283,7 @@ static void send_and_fulfill_htlc(struct channel *channel, ret = channel_sending_revoke_and_ack(channel); assert(!ret); assert(channel_get_htlc(channel, sender, 1337)->state - == SENT_REMOVE_ACK_REVOCATION); + == SENT_REMOVE_ACK_REVOCATION); } } @@ -336,7 +337,7 @@ int main(void) const struct htlc **htlc_map, **htlcs; const u8 *funding_wscript, **wscripts; size_t i; - const struct chainparams *chainparams = chainparams_for_network("bitcoin"); + const struct chainparams *chainparams = chainparams_for_network("groestlcoin"); secp256k1_ctx = wally_get_secp_context(); setup_tmpctx(); @@ -445,27 +446,27 @@ int main(void) to_remote_msat = 3000000000; feerate_per_kw[LOCAL] = feerate_per_kw[REMOTE] = 15000; lchannel = new_full_channel(tmpctx, - &chainparams->genesis_blockhash, - &funding_txid, funding_output_index, - funding_amount_satoshi, to_local_msat, - feerate_per_kw, - local_config, - remote_config, - &localbase, &remotebase, - &local_funding_pubkey, - &remote_funding_pubkey, - LOCAL); + &chainparams->genesis_blockhash, + &funding_txid, funding_output_index, + funding_amount_satoshi, to_local_msat, + feerate_per_kw, + local_config, + remote_config, + &localbase, &remotebase, + &local_funding_pubkey, + &remote_funding_pubkey, + LOCAL); rchannel = new_full_channel(tmpctx, - &chainparams->genesis_blockhash, - &funding_txid, funding_output_index, - funding_amount_satoshi, to_remote_msat, - feerate_per_kw, - remote_config, - local_config, - &remotebase, &localbase, - &remote_funding_pubkey, - &local_funding_pubkey, - REMOTE); + &chainparams->genesis_blockhash, + &funding_txid, funding_output_index, + funding_amount_satoshi, to_remote_msat, + feerate_per_kw, + remote_config, + local_config, + &remotebase, &localbase, + &remote_funding_pubkey, + &local_funding_pubkey, + REMOTE); /* BOLT #3: * @@ -496,7 +497,6 @@ int main(void) to_local_msat, to_remote_msat, NULL, &htlc_map, 0x2bb038521914 ^ 42, LOCAL); - txs = channel_txs(tmpctx, &htlc_map, &wscripts, lchannel, &local_per_commitment_point, 42, LOCAL); assert(tal_count(txs) == 1); @@ -528,9 +528,9 @@ int main(void) send_and_fulfill_htlc(rchannel, REMOTE, 7000000); assert(lchannel->view[LOCAL].owed_msat[LOCAL] - == rchannel->view[REMOTE].owed_msat[REMOTE]); + == rchannel->view[REMOTE].owed_msat[REMOTE]); assert(lchannel->view[REMOTE].owed_msat[REMOTE] - == rchannel->view[LOCAL].owed_msat[LOCAL]); + == rchannel->view[LOCAL].owed_msat[LOCAL]); txs = channel_txs(tmpctx, &htlc_map, &wscripts, lchannel, &local_per_commitment_point, 42, LOCAL); @@ -546,9 +546,9 @@ int main(void) include_htlcs(rchannel, REMOTE); assert(lchannel->view[LOCAL].owed_msat[LOCAL] - == rchannel->view[REMOTE].owed_msat[REMOTE]); + == rchannel->view[REMOTE].owed_msat[REMOTE]); assert(lchannel->view[REMOTE].owed_msat[REMOTE] - == rchannel->view[LOCAL].owed_msat[LOCAL]); + == rchannel->view[LOCAL].owed_msat[LOCAL]); txs = channel_txs(tmpctx, &htlc_map, &wscripts, lchannel, &local_per_commitment_point, 42, LOCAL); @@ -557,12 +557,13 @@ int main(void) rchannel, &local_per_commitment_point, 42, REMOTE); txs_must_be_eq(txs, txs2); - /* FIXME: Compare signatures! */ + /* FIXME: Compare signatures! GROESTLCOIN FIND OTHER HTLC TESTCASES */ /* BOLT #3: * * output htlc_success_tx 0: 020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219700000000000000000001e8030000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402206a6e59f18764a5bf8d4fa45eebc591566689441229c918b480fb2af8cc6a4aeb02205248f273be447684b33e3c8d1d85a8e0ca9fa0bae9ae33f0527ada9c162919a60147304402207cb324fa0de88f452ffa9389678127ebcf4cabe1dd848b8e076c1a1962bf34720220116ed922b12311bd602d67e60d2529917f21c5b82f25ff6506c0f87886b4dfd5012000000000000000000000000000000000000000000000000000000000000000008a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f401b175ac686800000000 */ - raw_tx = tx_from_hex(tmpctx, "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219700000000000000000001e8030000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402206a6e59f18764a5bf8d4fa45eebc591566689441229c918b480fb2af8cc6a4aeb02205248f273be447684b33e3c8d1d85a8e0ca9fa0bae9ae33f0527ada9c162919a60147304402207cb324fa0de88f452ffa9389678127ebcf4cabe1dd848b8e076c1a1962bf34720220116ed922b12311bd602d67e60d2529917f21c5b82f25ff6506c0f87886b4dfd5012000000000000000000000000000000000000000000000000000000000000000008a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f401b175ac686800000000"); + + raw_tx = tx_from_hex(tmpctx, "02000000017f6162d60bf6e3da6a03cf62e6b705b9234a9497aeae77075f0db54fc990a8aa00000000000000000001e8030000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e00000000"); raw_tx->input[0].witness = NULL; tx_must_be_eq(raw_tx, txs[1]); @@ -570,31 +571,37 @@ int main(void) * * output htlc_timeout_tx 2: 020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219701000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100d5275b3619953cb0c3b5aa577f04bc512380e60fa551762ce3d7a1bb7401cff9022037237ab0dac3fe100cde094e82e2bed9ba0ed1bb40154b48e56aa70f259e608b01483045022100c89172099507ff50f4c925e6c5150e871fb6e83dd73ff9fbb72f6ce829a9633f02203a63821d9162e99f9be712a68f9e589483994feae2661e4546cd5b6cec007be501008576a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a914b43e1b38138a41b37f7cd9a1d274bc63e3a9b5d188ac6868f6010000 */ - raw_tx = tx_from_hex(tmpctx, "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219701000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100d5275b3619953cb0c3b5aa577f04bc512380e60fa551762ce3d7a1bb7401cff9022037237ab0dac3fe100cde094e82e2bed9ba0ed1bb40154b48e56aa70f259e608b01483045022100c89172099507ff50f4c925e6c5150e871fb6e83dd73ff9fbb72f6ce829a9633f02203a63821d9162e99f9be712a68f9e589483994feae2661e4546cd5b6cec007be501008576a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a914b43e1b38138a41b37f7cd9a1d274bc63e3a9b5d188ac6868f6010000"); + + + raw_tx = tx_from_hex(tmpctx, "02000000017f6162d60bf6e3da6a03cf62e6b705b9234a9497aeae77075f0db54fc990a8aa01000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80ef6010000"); raw_tx->input[0].witness = NULL; tx_must_be_eq(raw_tx, txs[2]); + /* BOLT #3: * * output htlc_success_tx 1: 020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219702000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402201b63ec807771baf4fdff523c644080de17f1da478989308ad13a58b51db91d360220568939d38c9ce295adba15665fa68f51d967e8ed14a007b751540a80b325f20201483045022100def389deab09cee69eaa1ec14d9428770e45bcbe9feb46468ecf481371165c2f022015d2e3c46600b2ebba8dcc899768874cc6851fd1ecb3fffd15db1cc3de7e10da012001010101010101010101010101010101010101010101010101010101010101018a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a9144b6b2e5444c2639cc0fb7bcea5afba3f3cdce23988527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f501b175ac686800000000 */ - raw_tx = tx_from_hex(tmpctx, "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219702000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402201b63ec807771baf4fdff523c644080de17f1da478989308ad13a58b51db91d360220568939d38c9ce295adba15665fa68f51d967e8ed14a007b751540a80b325f20201483045022100def389deab09cee69eaa1ec14d9428770e45bcbe9feb46468ecf481371165c2f022015d2e3c46600b2ebba8dcc899768874cc6851fd1ecb3fffd15db1cc3de7e10da012001010101010101010101010101010101010101010101010101010101010101018a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a9144b6b2e5444c2639cc0fb7bcea5afba3f3cdce23988527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f501b175ac686800000000"); + raw_tx = tx_from_hex(tmpctx, "02000000017f6162d60bf6e3da6a03cf62e6b705b9234a9497aeae77075f0db54fc990a8aa02000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e00000000"); raw_tx->input[0].witness = NULL; tx_must_be_eq(raw_tx, txs[3]); + + /* BOLT #3: * * output htlc_timeout_tx 3: 020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219703000000000000000001b80b0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100daee1808f9861b6c3ecd14f7b707eca02dd6bdfc714ba2f33bc8cdba507bb182022026654bf8863af77d74f51f4e0b62d461a019561bb12acb120d3f7195d148a554014730440220643aacb19bbb72bd2b635bc3f7375481f5981bace78cdd8319b2988ffcc6704202203d27784ec8ad51ed3bd517a05525a5139bb0b755dd719e0054332d186ac0872701008576a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a9148a486ff2e31d6158bf39e2608864d63fefd09d5b88ac6868f7010000 */ - raw_tx = tx_from_hex(tmpctx, "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219703000000000000000001b80b0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100daee1808f9861b6c3ecd14f7b707eca02dd6bdfc714ba2f33bc8cdba507bb182022026654bf8863af77d74f51f4e0b62d461a019561bb12acb120d3f7195d148a554014730440220643aacb19bbb72bd2b635bc3f7375481f5981bace78cdd8319b2988ffcc6704202203d27784ec8ad51ed3bd517a05525a5139bb0b755dd719e0054332d186ac0872701008576a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a9148a486ff2e31d6158bf39e2608864d63fefd09d5b88ac6868f7010000"); + raw_tx = tx_from_hex(tmpctx, "02000000017f6162d60bf6e3da6a03cf62e6b705b9234a9497aeae77075f0db54fc990a8aa03000000000000000001b80b0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80ef7010000"); raw_tx->input[0].witness = NULL; tx_must_be_eq(raw_tx, txs[4]); + /* BOLT #3: * * output htlc_success_tx 4: 020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219704000000000000000001a00f0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402207e0410e45454b0978a623f36a10626ef17b27d9ad44e2760f98cfa3efb37924f0220220bd8acd43ecaa916a80bd4f919c495a2c58982ce7c8625153f8596692a801d014730440220549e80b4496803cbc4a1d09d46df50109f546d43fbbf86cd90b174b1484acd5402205f12a4f995cb9bded597eabfee195a285986aa6d93ae5bb72507ebc6a4e2349e012004040404040404040404040404040404040404040404040404040404040404048a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a91418bc1a114ccf9c052d3d23e28d3b0a9d1227434288527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f801b175ac686800000000 */ - raw_tx = tx_from_hex(tmpctx, "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219704000000000000000001a00f0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402207e0410e45454b0978a623f36a10626ef17b27d9ad44e2760f98cfa3efb37924f0220220bd8acd43ecaa916a80bd4f919c495a2c58982ce7c8625153f8596692a801d014730440220549e80b4496803cbc4a1d09d46df50109f546d43fbbf86cd90b174b1484acd5402205f12a4f995cb9bded597eabfee195a285986aa6d93ae5bb72507ebc6a4e2349e012004040404040404040404040404040404040404040404040404040404040404048a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a91418bc1a114ccf9c052d3d23e28d3b0a9d1227434288527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f801b175ac686800000000"); + raw_tx = tx_from_hex(tmpctx, "02000000017f6162d60bf6e3da6a03cf62e6b705b9234a9497aeae77075f0db54fc990a8aa04000000000000000001a00f0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e00000000"); raw_tx->input[0].witness = NULL; tx_must_be_eq(raw_tx, txs[5]); diff --git a/common/test/run-bolt11.c b/common/test/run-bolt11.c index 2b89032d4f84..8fb3c8ce4273 100644 --- a/common/test/run-bolt11.c +++ b/common/test/run-bolt11.c @@ -72,7 +72,6 @@ static void test_b11(const char *b11str, struct bolt11 *b11; char *fail; char *reproduce; - b11 = bolt11_decode(tmpctx, b11str, hashed_desc, &fail); if (!b11) errx(1, "%s:%u:%s", __FILE__, __LINE__, fail); @@ -160,7 +159,7 @@ int main(void) * * `ca784w`: Bech32 checksum */ b11 = new_bolt11(tmpctx, NULL); - b11->chain = chainparams_for_network("bitcoin"); + b11->chain = chainparams_for_network("groestlcoin"); b11->timestamp = 1496314658; if (!hex_decode("0001020304050607080900010203040506070809000102030405060708090102", strlen("0001020304050607080900010203040506070809000102030405060708090102"), @@ -169,7 +168,7 @@ int main(void) b11->receiver_id = node; b11->description = "Please consider supporting this project"; - test_b11("lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w", b11, NULL); + test_b11("lngrs1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaqry7cu947rc3snaedmjtmauuslg0glcq6w7t9njkwxpql8zataj6jkcj02tcrskffaahc7570mjv50gt0nku23r8e30gazgndd50cucgplz6udt", b11, NULL); /* BOLT #11: * @@ -194,7 +193,7 @@ int main(void) */ msatoshi = 2500 * (1000ULL * 100000000) / 1000000; b11 = new_bolt11(tmpctx, &msatoshi); - b11->chain = chainparams_for_network("bitcoin"); + b11->chain = chainparams_for_network("groestlcoin"); b11->timestamp = 1496314658; if (!hex_decode("0001020304050607080900010203040506070809000102030405060708090102", strlen("0001020304050607080900010203040506070809000102030405060708090102"), @@ -204,7 +203,7 @@ int main(void) b11->description = "1 cup coffee"; b11->expiry = 60; - test_b11("lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpuaztrnwngzn3kdzw5hydlzf03qdgm2hdq27cqv3agm2awhz5se903vruatfhq77w3ls4evs3ch9zw97j25emudupq63nyw24cg27h2rspfj9srp", b11, NULL); + test_b11("lngrs2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qesh2z5s6s0vjmq05mva9wp7l2pynjm2x3wf8zcj4kfa040wqzprsmyrdeuc8l7eemqt56r3srwvjetej72xdhnr4r74nellv7hlkgqqscvgy", b11, NULL); /* BOLT #11: * @@ -226,7 +225,7 @@ int main(void) */ msatoshi = 20 * (1000ULL * 100000000) / 1000; b11 = new_bolt11(tmpctx, &msatoshi); - b11->chain = chainparams_for_network("bitcoin"); + b11->chain = chainparams_for_network("groestlcoin"); b11->timestamp = 1496314658; if (!hex_decode("0001020304050607080900010203040506070809000102030405060708090102", strlen("0001020304050607080900010203040506070809000102030405060708090102"), @@ -234,7 +233,10 @@ int main(void) abort(); b11->receiver_id = node; b11->description_hash = tal(b11, struct sha256); - test_b11("lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqscc6gd6ql3jrc5yzme8v4ntcewwz5cnw92tz0pc8qcuufvq7khhr8wpald05e92xw006sq94mg8v2ndf4sefvf9sygkshp5zfem29trqq2yxxz7", b11, "One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon"); + + //sha256(b11->description_hash, "One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon", strlen("One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon")); + + test_b11("lngrs20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsey8q96sq3fth032rsqpl8vedajcpxapcfgpv2m3sj8xgpdpv8vy38dv68hsj2dhfwpyh2g5a9ppmyv05df4sv8p4dtftpegp94dr4gqp6ek8hs", b11, "One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon"); /* FIXME: Test the others! */ wally_cleanup(0); diff --git a/doc/lightning-listfunds.7 b/doc/lightning-listfunds.7 index 31a31dcfc951..39cc525c1e43 100644 --- a/doc/lightning-listfunds.7 +++ b/doc/lightning-listfunds.7 @@ -2,12 +2,12 @@ .\" Title: lightning-listfunds .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 09/18/2018 +.\" Date: 09/25/2018 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "LIGHTNING\-LISTFUNDS" "7" "09/18/2018" "\ \&" "\ \&" +.TH "LIGHTNING\-LISTFUNDS" "7" "09/25/2018" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -142,8 +142,8 @@ Each entry in \fIchannels\fR will include: .sp -1 .IP \(bu 2.3 .\} -\fIchannel_total_sat\fR -\- total channel value in satoshi (values rounded to the nearest satoshi as internal storage is in millisatoshi)\&. +\fIchannel_total_gro\fR +\-channel value in gro (values rounded to the nearest satoshi as internal storage is in millisatoshi)\&. .RE .sp .RS 4 diff --git a/doc/lightning-listfunds.7.txt b/doc/lightning-listfunds.7.txt index fa9477b8baa3..2be1990fc8fa 100644 --- a/doc/lightning-listfunds.7.txt +++ b/doc/lightning-listfunds.7.txt @@ -45,7 +45,7 @@ number and output index of the channel funding transaction). - 'channel_sat' - available satoshis on our node's end of the channel (values rounded to the nearest satoshi as internal storage is in millisatoshi). -- 'channel_total_sat' - total channel value in satoshi +- 'channel_total_gro' -channel value in gro (values rounded to the nearest satoshi as internal storage is in millisatoshi). - 'funding_txid' - funding transaction id. diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5 index 38f3f6d3c579..67918be21dab 100644 --- a/doc/lightningd-config.5 +++ b/doc/lightningd-config.5 @@ -2,12 +2,12 @@ .\" Title: lightningd-config .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 09/07/2018 +.\" Date: 09/22/2018 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "LIGHTNINGD\-CONFIG" "5" "09/07/2018" "\ \&" "\ \&" +.TH "LIGHTNINGD\-CONFIG" "5" "09/22/2018" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -186,7 +186,7 @@ Up to 32 UTF\-8 characters to tag your node\&. Completely silly, since anyone ca The base fee to charge for every payment which passes through\&. Note that millisatoshis are a very, very small unit! .RE .PP -\fBfee\-per\-satoshi\fR=\fIMILLIONTHS\fR +\fBfee\-per\-gro\fR=\fIMILLIONTHS\fR .RS 4 This is the proportional fee to charge for every payment which passes through\&. As percentages are too coarse, it\(cqs in millionths, so 10000 is 1%, 1000 is 0\&.1%\&. .RE diff --git a/doc/lightningd-config.5.txt b/doc/lightningd-config.5.txt index 00f9709f6358..36b690bea129 100644 --- a/doc/lightningd-config.5.txt +++ b/doc/lightningd-config.5.txt @@ -133,7 +133,7 @@ Lightning node customization options: The base fee to charge for every payment which passes through. Note that millisatoshis are a very, very small unit! -*fee-per-satoshi*='MILLIONTHS':: +*fee-per-gro*='MILLIONTHS':: This is the proportional fee to charge for every payment which passes through. As percentages are too coarse, it's in millionths, so 10000 is 1%, 1000 is 0.1%. diff --git a/gossipd/routing.c b/gossipd/routing.c index a0ab36a8054a..9a96ceb93975 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -20,8 +20,8 @@ #define SUPERVERBOSE(...) #endif -/* 365.25 * 24 * 60 / 10 */ -#define BLOCKS_PER_YEAR 52596 +/* 365.25 * 24 * 60 Groestlcoin */ +#define BLOCKS_PER_YEAR 525960 /* For overflow avoidance, we never deal with msatoshi > 40 bits. */ #define MAX_MSATOSHI (1ULL << 40) @@ -526,7 +526,7 @@ find_route(const tal_t *ctx, struct routing_state *rstate, } /* No route? */ - if (dst->bfg[best].total >= INFINITE) { + if ((dst->bfg[best].total) >= INFINITE) { status_trace("find_route: No route to %s", type_to_string(tmpctx, struct pubkey, to)); return NULL; diff --git a/lightningd/test/run-funding_tx.c b/lightningd/test/run-funding_tx.c index 64637ab48386..9eae41d9300d 100644 --- a/lightningd/test/run-funding_tx.c +++ b/lightningd/test/run-funding_tx.c @@ -66,18 +66,19 @@ int main(void) * Block 1 coinbase transaction: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100f2052a010000001976a9143ca33c2e4446f4a305f23c80df8ad1afdcf652f988ac00000000 */ input = bitcoin_tx_from_hex(tmpctx, - "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100f2052a010000001976a9143ca33c2e4446f4a305f23c80df8ad1afdcf652f988ac00000000", - strlen("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100f2052a010000001976a9143ca33c2e4446f4a305f23c80df8ad1afdcf652f988ac00000000")); + "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510108ffffffff0200002cd6e21500002321034da56300c4211accc61b0546168a691fddec00cb0473f8e5b08a7b5ceea699eeac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000", + strlen("02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510108ffffffff0200002cd6e21500002321034da56300c4211accc61b0546168a691fddec00cb0473f8e5b08a7b5ceea699eeac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000")); assert(input); /* BOLT #3: * Block 1 coinbase privkey: 6bd078650fcee8444e4e09825227b801a1ca928debb750eb36e6d56124bb20e801 * # privkey in base58: cRCH7YNcarfvaiY1GWUKQrRGmoezvfAiqHtdRvxe16shzbd7LDMz */ - if (!key_from_base58("cRCH7YNcarfvaiY1GWUKQrRGmoezvfAiqHtdRvxe16shzbd7LDMz", strlen("cRCH7YNcarfvaiY1GWUKQrRGmoezvfAiqHtdRvxe16shzbd7LDMz"), + if (!key_from_base58("L5ByerGLTFw6AR7BpxCFFgejDRZ71XkMZipQGfSSnSMVbtCqM7ue", strlen("L5ByerGLTFw6AR7BpxCFFgejDRZ71XkMZipQGfSSnSMVbtCqM7ue"), &testnet, &input_privkey, &inputkey)) abort(); - assert(testnet); + /* regtest coinbase */ + assert(!testnet); printf("* Block 1 coinbase privkey: %s\n", type_to_string(tmpctx, struct privkey, &input_privkey)); @@ -99,7 +100,7 @@ int main(void) bitcoin_txid(input, &utxo.txid); utxo.outnum = 0; - utxo.amount = 5000000000; + utxo.amount = 24064000000000; utxo.is_p2sh = false; utxo.close_info = NULL; funding_satoshis = 10000000; diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index 988d9801e16b..85e8886c1180 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/onchaind/test/run-grind_feerate.c @@ -102,8 +102,8 @@ void subdaemon_setup(int argc UNNEEDED, char *argv[]) { fprintf(stderr, "subdaemon_setup called!\n"); abort(); } /* Generated stub for to_self_wscript */ u8 *to_self_wscript(const tal_t *ctx UNNEEDED, - u16 to_self_delay UNNEEDED, - const struct keyset *keyset UNNEEDED) + u16 to_self_delay UNNEEDED, + const struct keyset *keyset UNNEEDED) { fprintf(stderr, "to_self_wscript called!\n"); abort(); } /* Generated stub for towire_hsm_get_per_commitment_point */ u8 *towire_hsm_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED) @@ -168,39 +168,47 @@ int main(int argc, char *argv[]) secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN); setup_tmpctx(); - tx = bitcoin_tx_from_hex(tmpctx, "0200000001e1ebca08cf1c301ac563580a1126d5c8fcb0e5e2043230b852c726553caf1e1d0000000000000000000160ae0a000000000022002082e03c5a9cb79c82cd5a0572dc175290bc044609aabe9cc852d61927436041796d000000", - strlen("0200000001e1ebca08cf1c301ac563580a1126d5c8fcb0e5e2043230b852c726553caf1e1d0000000000000000000160ae0a000000000022002082e03c5a9cb79c82cd5a0572dc175290bc044609aabe9cc852d61927436041796d000000")); - tx->input[0].amount = tal(tx, u64); - *tx->input[0].amount = 700000; - der = tal_hexdata(tmpctx, "30450221009b2e0eef267b94c3899fb0dc7375012e2cee4c10348a068fe78d1b82b4b14036022077c3fad3adac2ddf33f415e45f0daf6658b7a0b09647de4443938ae2dbafe2b9", - strlen("30450221009b2e0eef267b94c3899fb0dc7375012e2cee4c10348a068fe78d1b82b4b14036022077c3fad3adac2ddf33f415e45f0daf6658b7a0b09647de4443938ae2dbafe2b9")); + tx = tal(tmpctx, struct bitcoin_tx); + tx = bitcoin_tx_from_hex(tmpctx, "0200000001ce636f4eb66fe1bbbe43a11681d0b81a487675ff75f14e715722862594191d7200000000000000000001470f01000000000022002093f19f3548788064102caddb3c496e94635cf35e0d43edc1eea5c7739462d04600000000", + strlen("0200000001ce636f4eb66fe1bbbe43a11681d0b81a487675ff75f14e715722862594191d7200000000000000000001470f01000000000022002093f19f3548788064102caddb3c496e94635cf35e0d43edc1eea5c7739462d04600000000")); + + + tx->input[0].amount = tal(tmpctx, u64); + *tx->input[0].amount = 70150; + + der = tal_hexdata(tmpctx, "304402206758f025f30bfd6f11fa44dbb8ae132ad9c7c89ca172b743d99bcbbcc703a75302200cadb8f7c52522d23344ce1bf4c285a983c717b52bc89b58a94130184058d434", + strlen("304402206758f025f30bfd6f11fa44dbb8ae132ad9c7c89ca172b743d99bcbbcc703a75302200cadb8f7c52522d23344ce1bf4c285a983c717b52bc89b58a94130184058d434")); + if (!signature_from_der(der, tal_count(der), &sig)) abort(); - wscript = tal_hexdata(tmpctx, "76a914a8c40c334351dbe8e5908544f1c98fbcfb8719fc8763ac6721038ffd2621647812011960152bfb79c5a2787dfe6c4f37e2222547de054432eb7f7c820120876475527c2103cf8e2f193a6aed60db80af75f3c8d59c2de735b299b7c7083527be9bd23b77a852ae67a914b8bcd51efa35be1e50ae2d5f72f4500acb005c9c88ac6868", strlen("76a914a8c40c334351dbe8e5908544f1c98fbcfb8719fc8763ac6721038ffd2621647812011960152bfb79c5a2787dfe6c4f37e2222547de054432eb7f7c820120876475527c2103cf8e2f193a6aed60db80af75f3c8d59c2de735b299b7c7083527be9bd23b77a852ae67a914b8bcd51efa35be1e50ae2d5f72f4500acb005c9c88ac6868")); - if (!pubkey_from_hexstr("038ffd2621647812011960152bfb79c5a2787dfe6c4f37e2222547de054432eb7f", - strlen("038ffd2621647812011960152bfb79c5a2787dfe6c4f37e2222547de054432eb7f"), - &htlc_key)) - abort(); + wscript = tal_hexdata(tmpctx, "76a9142a85f084bb57555fd20c30dbfb96106fa9b972838763ac67210232974d5858c34a8a69c7b708857a72717daca1bcc312904b5a3ef5304ea5ca8f7c8201208763a9148ddc0fc0ec8c58afab6bb7475f84be60e8e754d488527c21036879c3877d39229bf960b60a11c73560aa8dbd2439b8560c08964385bac79a1352ae6775020a01b175ac6868",strlen("76a9142a85f084bb57555fd20c30dbfb96106fa9b972838763ac67210232974d5858c34a8a69c7b708857a72717daca1bcc312904b5a3ef5304ea5ca8f7c8201208763a9148ddc0fc0ec8c58afab6bb7475f84be60e8e754d488527c21036879c3877d39229bf960b60a11c73560aa8dbd2439b8560c08964385bac79a1352ae6775020a01b175ac6868")); + if (!pubkey_from_hexstr("0232974d5858c34a8a69c7b708857a72717daca1bcc312904b5a3ef5304ea5ca8f", + strlen("0232974d5858c34a8a69c7b708857a72717daca1bcc312904b5a3ef5304ea5ca8f"), + &htlc_key)) + abort(); /* Dance around a little because keyset is const */ keys = tal(tmpctx, struct keyset); keys->other_htlc_key = htlc_key; keyset = keys; + if (argc > 1) iterations = atoi(argv[1]); - max_possible_feerate = 250000; + max_possible_feerate = 2000; min_possible_feerate = max_possible_feerate + 1 - iterations; start = time_now(); + fee = grind_htlc_tx_fee(tx, &sig, wscript, 663); end = time_now(); - assert(fee == 165750); + + assert(fee == 703); printf("%u iterations in %"PRIu64" msec = %"PRIu64" nsec each\n", - iterations, - time_to_msec(time_between(end, start)), - time_to_nsec(time_divide(time_between(end, start), iterations))); + iterations, + time_to_msec(time_between(end, start)), + time_to_nsec(time_divide(time_between(end, start), iterations))); tal_free(tmpctx); secp256k1_context_destroy(secp256k1_ctx); diff --git a/tests/benchmark.py b/tests/benchmark.py old mode 100644 new mode 100755 index 5767dceca419..ee8fe1a8571b --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -8,10 +8,11 @@ import pytest import random import utils +import time -num_workers = 480 -num_payments = 10000 +num_workers = 10 +num_payments = 100 @pytest.fixture @@ -26,10 +27,20 @@ def bitcoind(): bitcoind = utils.BitcoinD(rpcport=21441) bitcoind.start() info = bitcoind.rpc.getblockchaininfo() - # Make sure we have segwit and some funds - if info['blocks'] < 432: - logging.debug("SegWit not active, generating some more blocks") - bitcoind.generate_block(432 - info['blocks']) + # Make sure we have segwit + # Make sure we have some spendable funds + bitcoind.generate_block(123) + start_time = time.time() + # 120 sec timeout + local_timeout = 120 + while (bitcoind.rpc.getblockchaininfo()['blocks'] < 122) and time.time() < start_time + local_timeout: + bitcoind.generate_block(1) + + assert not (bitcoind.rpc.getblockchaininfo()['blocks'] < 122) + + if bitcoind.rpc.getwalletinfo()['balance'] < 1: + logging.debug("Insufficient balance") + raise ValueError("groestlcoind error no funds from generate blocks") yield bitcoind @@ -41,24 +52,30 @@ def bitcoind(): def test_single_hop(node_factory, executor): + #FIXME if VALGRIND=1 l1 = node_factory.get_node() l2 = node_factory.get_node() - l1.rpc.connect(l2.rpc.getinfo()['id'], 'localhost:%d' % l2.port) - l1.openchannel(l2, 4000000) + l1.rpc.connect(l2.info['id'], 'localhost', port = l2.port) + l1.daemon.wait_for_log('openingd-.*: Handed peer, entering loop') + l1.openchannel(l2, 10000000) + l1.bitcoin.generate_block(1) + route = l1.rpc.getroute(l2.info['id'], 123000, 1 , 9 , l1.info['id'], 10)['route'] + print("Collecting invoices") fs = [] invoices = [] for i in tqdm(range(num_payments)): - invoices.append(l2.rpc.invoice(1000, 'invoice-%d' % (i), 'desc')['payment_hash']) + invoices.append(l2.rpc.invoice(123000, 'invoice-%d' % (i), 'desc')['payment_hash']) + - route = l1.rpc.getroute(l2.rpc.getinfo()['id'], 1000, 1)['route'] print("Sending payments") - start_time = time() + start_time = time.time() def do_pay(i): p = l1.rpc.sendpay(route, i) + filler_time = time.time() r = l1.rpc.waitsendpay(p['payment_hash']) return r @@ -68,14 +85,14 @@ def do_pay(i): for f in tqdm(futures.as_completed(fs), total=len(fs)): f.result() - diff = time() - start_time + diff = time.time() - start_time print("Done. %d payments performed in %f seconds (%f payments per second)" % (num_payments, diff, num_payments / diff)) def test_single_payment(node_factory, benchmark): l1 = node_factory.get_node() l2 = node_factory.get_node() - l1.rpc.connect(l2.rpc.getinfo()['id'], 'localhost:%d' % l2.port) + l1.rpc.connect(l2.info['id'], 'localhost' , port=l2.port) l1.openchannel(l2, 4000000) def do_pay(l1, l2): @@ -89,27 +106,11 @@ def test_invoice(node_factory, benchmark): l1 = node_factory.get_node() def bench_invoice(): - l1.rpc.invoice(1000, 'invoice-{}'.format(time()), 'desc') + l1.rpc.invoice(1000, 'invoice-{}'.format(time.time()), 'desc')['bolt11'] benchmark(bench_invoice) -def test_pay(node_factory, benchmark): - l1 = node_factory.get_node() - l2 = node_factory.get_node() - l1.rpc.connect(l2.rpc.getinfo()['id'], 'localhost:%d' % l2.port) - l1.openchannel(l2, 4000000) - - invoices = [] - for _ in range(1, 100): - invoice = l2.rpc.invoice(1000, 'invoice-{}'.format(random.random()), 'desc')['bolt11'] - invoices.append(invoice) - - def do_pay(l1, l2): - l1.rpc.pay(invoices.pop()) - - benchmark(do_pay, l1, l2) - def test_start(node_factory, benchmark): benchmark(node_factory.get_node) diff --git a/tests/btcproxy.py b/tests/btcproxy.py old mode 100644 new mode 100755 index 8b0f64018692..a27a8091653b --- a/tests/btcproxy.py +++ b/tests/btcproxy.py @@ -34,7 +34,7 @@ def __init__(self, bitcoind, rpcport=0): self.request_count = 0 def _handle_request(self, r): - conf_file = os.path.join(self.bitcoind.bitcoin_dir, 'bitcoin.conf') + conf_file = os.path.join(self.bitcoind.bitcoin_dir, 'groestlcoin.conf') brpc = BitcoinProxy(btc_conf_file=conf_file) method = r['method'] diff --git a/tests/conftest.py b/tests/conftest.py old mode 100644 new mode 100755 diff --git a/tests/fixtures.py b/tests/fixtures.py old mode 100644 new mode 100755 index b9a2e07a4ee1..697ffdbd2338 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -8,7 +8,7 @@ import shutil import sys import tempfile - +import time with open('config.vars') as configfile: config = dict([(line.rstrip().split('=', 1)) for line in configfile]) @@ -77,19 +77,24 @@ def bitcoind(directory): info = bitcoind.rpc.getnetworkinfo() - if info['version'] < 160000: + if info['version'] < 2160000: bitcoind.rpc.stop() - raise ValueError("bitcoind is too old. At least version 16000 (v0.16.0)" + raise ValueError("bitcoind is too old. At least version (v21.6.0)" " is needed, current version is {}".format(info['version'])) - info = bitcoind.rpc.getblockchaininfo() # Make sure we have some spendable funds - if info['blocks'] < 101: - bitcoind.generate_block(101 - info['blocks']) - elif bitcoind.rpc.getwalletinfo()['balance'] < 1: - logging.debug("Insufficient balance, generating 1 block") + bitcoind.generate_block(122) + start_time = time.time() + # 120 sec timeout + local_timeout = 120 + while (bitcoind.rpc.getblockchaininfo()['blocks'] < 121) and time.time() < start_time + local_timeout: bitcoind.generate_block(1) + if bitcoind.rpc.getwalletinfo()['balance'] < 1: + logging.debug("Insufficient balance") + raise ValueError("groestlcoind error no funds from generate blocks") + + yield bitcoind try: diff --git a/tests/requirements.txt b/tests/requirements.txt old mode 100644 new mode 100755 diff --git a/tests/test_closing.py b/tests/test_closing.py old mode 100644 new mode 100755 index 271b998f68da..f0f22f29bf65 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -110,7 +110,7 @@ def test_closing_while_disconnected(node_factory, bitcoind): l1.daemon.wait_for_log('sendrawtx exit 0') l2.daemon.wait_for_log('sendrawtx exit 0') - bitcoind.rpc.generate(101) + bitcoind.rpc.generate(121) wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 0) wait_for(lambda: len(l2.rpc.listchannels()['channels']) == 0) @@ -549,7 +549,7 @@ def test_onchaind_replay(node_factory, bitcoind): # Generate some blocks so we restart the onchaind from DB (we rescan # last_height - 100) - bitcoind.rpc.generate(100) + bitcoind.rpc.generate(121) sync_blockheight(bitcoind, [l1, l2]) # l1 should still have a running onchaind @@ -979,7 +979,7 @@ def test_onchain_different_fees(node_factory, bitcoind, executor): l1.daemon.wait_for_logs(['sendrawtx exit 0'] * 3) # Now, 100 blocks it should be done. - bitcoind.generate_block(100) + bitcoind.generate_block(121) wait_for(lambda: l1.rpc.listpeers()['peers'] == []) wait_for(lambda: l2.rpc.listpeers()['peers'] == []) @@ -1017,7 +1017,7 @@ def test_permfail_new_commit(node_factory, bitcoind, executor): t.cancel() # Now, 100 blocks it should be done. - bitcoind.generate_block(100) + bitcoind.generate_block(121) wait_for(lambda: l1.rpc.listpeers()['peers'] == []) wait_for(lambda: l2.rpc.listpeers()['peers'] == []) @@ -1197,7 +1197,7 @@ def check_billboard(): ]) # Now, 100 blocks l2 should be done. - bitcoind.generate_block(5) + bitcoind.generate_block(100) wait_for(lambda: l2.rpc.listpeers()['peers'] == []) # Only l1 has a direct output since all of l2's outputs are respent (it diff --git a/tests/test_connection.py b/tests/test_connection.py old mode 100644 new mode 100755 index 5c30f8b56c1b..102e4cff9890 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -9,6 +9,7 @@ import random import shutil import unittest +import time def test_connect(node_factory): @@ -103,10 +104,10 @@ def test_balance(node_factory): l1, l2 = node_factory.line_graph(2, fundchannel=True) p1 = only_one(l1.rpc.getpeer(peer_id=l2.info['id'], level='info')['channels']) p2 = only_one(l2.rpc.getpeer(l1.info['id'], 'info')['channels']) - assert p1['msatoshi_to_us'] == 10**6 * 1000 - assert p1['msatoshi_total'] == 10**6 * 1000 - assert p2['msatoshi_to_us'] == 0 - assert p2['msatoshi_total'] == 10**6 * 1000 + assert p1['mgro_to_us'] == 10**6 * 1000 + assert p1['mgro_total'] == 10**6 * 1000 + assert p2['mgro_to_us'] == 0 + assert p2['mgro_total'] == 10**6 * 1000 def test_bad_opening(node_factory): @@ -533,7 +534,7 @@ def test_shutdown_awaiting_lockin(node_factory, bitcoind): # Technically, this is async to fundchannel. l1.daemon.wait_for_log('sendrawtx exit 0') - bitcoind.generate_block(1) + bitcoind.generate_block(10) # This should return with an error, then close. with pytest.raises(RpcError, match=r'Channel close negotiation not finished'): @@ -555,7 +556,16 @@ def test_shutdown_awaiting_lockin(node_factory, bitcoind): l1.daemon.wait_for_log(' to ONCHAIN') l2.daemon.wait_for_log(' to ONCHAIN') - bitcoind.generate_block(100) + count = bitcoind.rpc.getblockchaininfo()['blocks'] + bitcoind.generate_block(101) + start_time = time.time() + # 120 sec timeout + local_timeout = 120 + while (bitcoind.rpc.getblockchaininfo()['blocks'] < (100 + count)) and time.time() < start_time + local_timeout: + bitcoind.generate_block(1) + + assert not (bitcoind.rpc.getblockchaininfo()['blocks'] < (100 + count)) + wait_for(lambda: l1.rpc.listpeers()['peers'] == []) wait_for(lambda: l2.rpc.listpeers()['peers'] == []) @@ -565,7 +575,7 @@ def test_funding_change(node_factory, bitcoind): """ l1, l2 = node_factory.line_graph(2, fundchannel=False) l1.fundwallet(10000000) - bitcoind.generate_block(1) + bitcoind.generate_block(10) sync_blockheight(bitcoind, [l1]) outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;') @@ -586,7 +596,7 @@ def test_funding_all(node_factory, bitcoind): l1, l2 = node_factory.line_graph(2, fundchannel=False) l1.fundwallet(0.1 * 10**8) - bitcoind.generate_block(1) + bitcoind.generate_block(10) sync_blockheight(bitcoind, [l1]) outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;') @@ -605,15 +615,15 @@ def test_funding_all_too_much(node_factory): l1.fundwallet(2**24 + 10000) l1.rpc.fundchannel(l2.info['id'], "all") - + l1.bitcoin.rpc.generate(10) assert only_one(l1.rpc.listfunds()['outputs'])['status'] == 'unconfirmed' - assert only_one(l1.rpc.listfunds()['channels'])['channel_total_sat'] == 2**24 - 1 + assert only_one(l1.rpc.listfunds()['channels'])['channel_total_gro'] == 2**24 - 1 def test_funding_fail(node_factory, bitcoind): """Add some funds, fund a channel without enough funds""" # Previous runs with same bitcoind can leave funds! - max_locktime = 5 * 6 * 24 + max_locktime = 5 * 60 * 24 l1 = node_factory.get_node(random_hsm=True, options={'max-locktime-blocks': max_locktime}) l2 = node_factory.get_node(options={'watchtime-blocks': max_locktime + 1}) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) @@ -622,7 +632,7 @@ def test_funding_fail(node_factory, bitcoind): addr = l1.rpc.newaddr()['address'] l1.bitcoin.rpc.sendtoaddress(addr, funds / 10**8) - bitcoind.generate_block(1) + l1.bitcoin.rpc.generate(10) # Wait for it to arrive. wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0) @@ -661,7 +671,7 @@ def test_funding_toolarge(node_factory, bitcoind): # Send funds. amount = 2**24 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['address'], amount / 10**8 + 0.01) - bitcoind.generate_block(1) + bitcoind.generate_block(10) # Wait for it to arrive. wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0) @@ -763,7 +773,7 @@ def test_channel_persistence(node_factory, bitcoind, executor): wait_for(lambda: len(l2.rpc.listpeers()['peers']) == 1) # Wait for the restored HTLC to finish - wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99990000, interval=1) + wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['mgro_to_us'] == 99990000, interval=1) wait_for(lambda: len([p for p in l1.rpc.listpeers()['peers'] if p['connected']]), interval=1) wait_for(lambda: len([p for p in l2.rpc.listpeers()['peers'] if p['connected']]), interval=1) @@ -773,12 +783,12 @@ def test_channel_persistence(node_factory, bitcoind, executor): # L1 doesn't actually update msatoshi_to_us until it receives # revoke_and_ack from L2, which can take a little bit. - wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99980000) - assert only_one(l2.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 20000 + wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['mgro_to_us'] == 99980000) + assert only_one(l2.rpc.listpeers()['peers'][0]['channels'])['mgro_to_us'] == 20000 # Finally restart l1, and make sure it remembers l1.restart() - assert only_one(l1.rpc.listpeers()['peers'][0]['channels'])['msatoshi_to_us'] == 99980000 + assert only_one(l1.rpc.listpeers()['peers'][0]['channels'])['mgro_to_us'] == 99980000 # Now make sure l1 is watching for unilateral closes l2.rpc.dev_fail(l1.info['id']) @@ -997,7 +1007,7 @@ def test_peerinfo(node_factory, bitcoind): # Fund a channel to force a node announcement chan = l1.fund_channel(l2, 10**6) # Now proceed to funding-depth and do a full gossip round - bitcoind.generate_block(5) + bitcoind.generate_block(6) l1.daemon.wait_for_logs(['Received node_announcement for node ' + l2.info['id']]) l2.daemon.wait_for_logs(['Received node_announcement for node ' + l1.info['id']]) @@ -1014,6 +1024,7 @@ def test_peerinfo(node_factory, bitcoind): # If it reconnects after db load, it should know features. l1.restart() + bitcoind.generate_block(1) wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected']) wait_for(lambda: l2.rpc.getpeer(l1.info['id'])['connected']) assert l1.rpc.getpeer(l2.info['id'])['local_features'] == '8a' @@ -1024,7 +1035,18 @@ def test_peerinfo(node_factory, bitcoind): l1.rpc.close(chan, False, 0) l1.daemon.wait_for_log('Forgetting peer') - bitcoind.generate_block(100) + + count = bitcoind.rpc.getblockchaininfo()['blocks'] + #BOLT5 after 100 blocks in longest chain irrevocably resolved + bitcoind.generate_block(101) + start_time = time.time() + # 120 sec timeout + local_timeout = 120 + while (bitcoind.rpc.getblockchaininfo()['blocks'] < 100 + count) and time.time() < start_time + local_timeout: + bitcoind.generate_block(1) + + assert not (bitcoind.rpc.getblockchaininfo()['blocks'] < (100 + count)) + l1.daemon.wait_for_log('WIRE_ONCHAIN_ALL_IRREVOCABLY_RESOLVED') l2.daemon.wait_for_log('WIRE_ONCHAIN_ALL_IRREVOCABLY_RESOLVED') diff --git a/tests/test_gossip.py b/tests/test_gossip.py old mode 100644 new mode 100755 diff --git a/tests/test_invoices.py b/tests/test_invoices.py old mode 100644 new mode 100755 diff --git a/tests/test_misc.py b/tests/test_misc.py old mode 100644 new mode 100755 index 0e7f1ac6ce55..e2a6c9794597 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -397,8 +397,8 @@ def test_withdraw(node_factory, bitcoind): assert l1.db_query('SELECT COUNT(*) as c FROM outputs WHERE status=2')[0]['c'] == 4 # Simple test for withdrawal to P2WPKH - # Address from: https://bc-2.jp/tools/bech32demo/index.html - waddr = 'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080' + + waddr = 'grsrt1qccn808860ygrqq98e6ltplxu8hvjk08ngwkdpr' with pytest.raises(RpcError): l1.rpc.withdraw('xx1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx', 2 * amount) with pytest.raises(RpcError): @@ -411,8 +411,8 @@ def test_withdraw(node_factory, bitcoind): assert l1.db_query('SELECT COUNT(*) as c FROM outputs WHERE status=2')[0]['c'] == 6 # Simple test for withdrawal to P2WSH - # Address from: https://bc-2.jp/tools/bech32demo/index.html - waddr = 'bcrt1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qzf4jry' + # FIXME GENERATE REAL P2WSH ADDR + waddr = 'grsrt1qpc4mnd3zfzjnyyyxj97yxcastjh7cx7m3ex6pn33quse9qleqsjsnakslv' with pytest.raises(RpcError): l1.rpc.withdraw('xx1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7', 2 * amount) with pytest.raises(RpcError): @@ -732,22 +732,22 @@ def test_rescan(node_factory, bitcoind): """ l1 = node_factory.get_node() - # The first start should start at current_height - 30 = 71, make sure + # The first start should start at current_height - 60 = 61, make sure # it's not earlier - l1.daemon.wait_for_log(r'Adding block 101') - assert not l1.daemon.is_in_log(r'Adding block 70') + l1.daemon.wait_for_log(r'Adding block 121') + assert not l1.daemon.is_in_log(r'Adding block 60') # Restarting with a higher rescan should go back further l1.daemon.opts['rescan'] = 50 l1.restart() - l1.daemon.wait_for_log(r'Adding block 101') - assert l1.daemon.is_in_log(r'Adding block 51') - assert not l1.daemon.is_in_log(r'Adding block 50') + l1.daemon.wait_for_log(r'Adding block 121') + assert l1.daemon.is_in_log(r'Adding block 71') + assert not l1.daemon.is_in_log(r'Adding block 70') # Restarting with an absolute rescan should start from there l1.daemon.opts['rescan'] = -31 l1.restart() - l1.daemon.wait_for_log(r'Adding block 101') + l1.daemon.wait_for_log(r'Adding block 121') assert l1.daemon.is_in_log(r'Adding block 31') assert not l1.daemon.is_in_log(r'Adding block 30') @@ -757,8 +757,8 @@ def test_rescan(node_factory, bitcoind): l1.stop() bitcoind.rpc.generate(4) l1.start() - l1.daemon.wait_for_log(r'Adding block 105') - assert not l1.daemon.is_in_log(r'Adding block 102') + l1.daemon.wait_for_log(r'Adding block 125') + assert not l1.daemon.is_in_log(r'Adding block 122') def test_reserve_enforcement(node_factory, executor): diff --git a/tests/test_pay.py b/tests/test_pay.py old mode 100644 new mode 100755 index d5ea5022363c..0450ee807332 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -33,6 +33,7 @@ def test_pay(node_factory): # Repeat payments are NOPs (if valid): we can hand null. l1.rpc.pay(inv) # This won't work: can't provide an amount (even if correct!) + with pytest.raises(RpcError): l1.rpc.pay(inv, 123000) with pytest.raises(RpcError): @@ -41,7 +42,6 @@ def test_pay(node_factory): # Check pay_index is not null outputs = l2.db_query('SELECT pay_index IS NOT NULL AS q FROM invoices WHERE label="label";') assert len(outputs) == 1 and outputs[0]['q'] != 0 - # Check payment of any-amount invoice. for i in range(5): label = "any{}".format(i) @@ -368,10 +368,10 @@ def only_one(arr): # FIXME: test paying via another node, should fail to pay twice. p1 = l1.rpc.getpeer(l2.info['id'], 'info') p2 = l2.rpc.getpeer(l1.info['id'], 'info') - assert only_one(p1['channels'])['msatoshi_to_us'] == 10**6 * 1000 - assert only_one(p1['channels'])['msatoshi_total'] == 10**6 * 1000 - assert only_one(p2['channels'])['msatoshi_to_us'] == 0 - assert only_one(p2['channels'])['msatoshi_total'] == 10**6 * 1000 + assert only_one(p1['channels'])['mgro_to_us'] == 10**6 * 1000 + assert only_one(p1['channels'])['mgro_total'] == 10**6 * 1000 + assert only_one(p2['channels'])['mgro_to_us'] == 0 + assert only_one(p2['channels'])['mgro_total'] == 10**6 * 1000 # This works. before = int(time.time()) @@ -394,10 +394,10 @@ def check_balances(): p1 = l1.rpc.getpeer(l2.info['id'], 'info') p2 = l2.rpc.getpeer(l1.info['id'], 'info') return ( - only_one(p1['channels'])['msatoshi_to_us'] == 10**6 * 1000 - amt and - only_one(p1['channels'])['msatoshi_total'] == 10**6 * 1000 and - only_one(p2['channels'])['msatoshi_to_us'] == amt and - only_one(p2['channels'])['msatoshi_total'] == 10**6 * 1000 + only_one(p1['channels'])['mgro_to_us'] == 10**6 * 1000 - amt and + only_one(p1['channels'])['mgro_total'] == 10**6 * 1000 and + only_one(p2['channels'])['mgro_to_us'] == amt and + only_one(p2['channels'])['mgro_total'] == 10**6 * 1000 ) wait_for(check_balances) @@ -496,19 +496,15 @@ def test_decodepay(node_factory): # * `2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq`: 'Please consider supporting this project' # * `32vjcgqxyuj7nqphl3xmmhls2rkl3t97uan4j0xa87gj5779czc8p0z58zf5wpt9ggem6adl64cvawcxlef9djqwp2jzzfvs272504sp`: signature # * `0lkg3c`: Bech32 checksum - b11 = l1.rpc.decodepay( - 'lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqd' - 'pl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rk' - 'x3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatg' - 'ddc6k63n7erqz25le42c4u4ecky03ylcqca784w' - ) - assert b11['currency'] == 'bc' + b11 = l1.rpc.decodepay('lngrs1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaqry7cu947rc3snaedmjtmauuslg0glcq6w7t9njkwxpql8zataj6jkcj02tcrskffaahc7570mjv50gt0nku23r8e30gazgndd50cucgplz6udt') + + assert b11['currency'] == 'grs' assert b11['created_at'] == 1496314658 assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' assert b11['description'] == 'Please consider supporting this project' assert b11['expiry'] == 3600 assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - + # BOLT #11: # > ### Please send $3 for a cup of coffee to the same peer, within 1 minute # > lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpuaztrnwngzn3kdzw5hydlzf03qdgm2hdq27cqv3agm2awhz5se903vruatfhq77w3ls4evs3ch9zw97j25emudupq63nyw24cg27h2rspfj9srp @@ -528,211 +524,18 @@ def test_decodepay(node_factory): # * `pu`: 60 seconds (`p` = 1, `u` = 28. 1 * 32 + 28 == 60) # * `azh8qt5w7qeewkmxtv55khqxvdfs9zzradsvj7rcej9knpzdwjykcq8gv4v2dl705pjadhpsc967zhzdpuwn5qzjm0s4hqm2u0vuhhqq`: signature # * `7vc09u`: Bech32 checksum - b11 = l1.rpc.decodepay( - 'lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqf' - 'qypqdq5xysxxatsyp3k7enxv4jsxqzpuaztrnwngzn3kdzw5hydlzf03qdgm2hdq27cq' - 'v3agm2awhz5se903vruatfhq77w3ls4evs3ch9zw97j25emudupq63nyw24cg27h2rsp' - 'fj9srp' - ) - assert b11['currency'] == 'bc' - assert b11['msatoshi'] == 2500 * 10**11 // 1000000 - assert b11['created_at'] == 1496314658 - assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['description'] == '1 cup coffee' - assert b11['expiry'] == 60 - assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - - # BOLT #11: - # > ### Now send $24 for an entire list of things (hashed) - # > lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqscc6gd6ql3jrc5yzme8v4ntcewwz5cnw92tz0pc8qcuufvq7khhr8wpald05e92xw006sq94mg8v2ndf4sefvf9sygkshp5zfem29trqq2yxxz7 - # - # Breakdown: - # - # * `lnbc`: prefix, lightning on bitcoin mainnet - # * `20m`: amount (20 milli-bitcoin) - # * `1`: Bech32 separator - # * `pvjluez`: timestamp (1496314658) - # * `p`: payment hash... - # * `h`: tagged field: hash of description - # * `p5`: `data_length` (`p` = 1, `5` = 20. 1 * 32 + 20 == 52) - # * `8yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqs`: SHA256 of 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon' - # * `vjfls3ljx9e93jkw0kw40yxn4pevgzflf83qh2852esjddv4xk4z70nehrdcxa4fk0t6hlcc6vrxywke6njenk7yzkzw0quqcwxphkcp`: signature - # * `vam37w`: Bech32 checksum - b11 = l1.rpc.decodepay( - 'lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqy' - 'pqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqscc6gd6ql3jr' - 'c5yzme8v4ntcewwz5cnw92tz0pc8qcuufvq7khhr8wpald05e92xw006sq94mg8v2ndf' - '4sefvf9sygkshp5zfem29trqq2yxxz7', - 'One piece of chocolate cake, one icecream cone, one pickle, one slic' - 'e of swiss cheese, one slice of salami, one lollypop, one piece of c' - 'herry pie, one sausage, one cupcake, and one slice of watermelon' - ) - assert b11['currency'] == 'bc' - assert b11['msatoshi'] == 20 * 10**11 // 1000 - assert b11['created_at'] == 1496314658 - assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['expiry'] == 3600 - assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - - # > ### The same, on testnet, with a fallback address mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP - # > lntb20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfpp3x9et2e20v6pu37c5d9vax37wxq72un98kmzzhznpurw9sgl2v0nklu2g4d0keph5t7tj9tcqd8rexnd07ux4uv2cjvcqwaxgj7v4uwn5wmypjd5n69z2xm3xgksg28nwht7f6zspwp3f9t - # - # Breakdown: - # - # * `lntb`: prefix, lightning on bitcoin testnet - # * `20m`: amount (20 milli-bitcoin) - # * `1`: Bech32 separator - # * `pvjluez`: timestamp (1496314658) - # * `p`: payment hash... - # * `f`: tagged field: fallback address - # * `pp`: `data_length` (`p` = 1. 1 * 32 + 1 == 33) - # * `3x9et2e20v6pu37c5d9vax37wxq72un98`: `3` = 17, so P2PKH address - # * `h`: tagged field: hash of description... - # * `qh84fmvn2klvglsjxfy0vq2mz6t9kjfzlxfwgljj35w2kwa60qv49k7jlsgx43yhs9nuutllkhhnt090mmenuhp8ue33pv4klmrzlcqp`: signature - # * `us2s2r`: Bech32 checksum - b11 = l1.rpc.decodepay( - 'lntb20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahr' - 'qspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfpp3x9et2e2' - '0v6pu37c5d9vax37wxq72un98kmzzhznpurw9sgl2v0nklu2g4d0keph5t7tj9tcqd8r' - 'exnd07ux4uv2cjvcqwaxgj7v4uwn5wmypjd5n69z2xm3xgksg28nwht7f6zspwp3f9t', - 'One piece of chocolate cake, one icecream cone, one pickle, one slic' - 'e of swiss cheese, one slice of salami, one lollypop, one piece of c' - 'herry pie, one sausage, one cupcake, and one slice of watermelon' - ) - assert b11['currency'] == 'tb' - assert b11['msatoshi'] == 20 * 10**11 // 1000 - assert b11['created_at'] == 1496314658 - assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['expiry'] == 3600 - assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - assert len(b11['fallbacks']) == 1 - assert b11['fallbacks'][0]['type'] == 'P2PKH' - assert b11['fallbacks'][0]['addr'] == 'mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP' - # > ### On mainnet, with fallback address 1RustyRX2oai4EYYDpQGWvEL62BBGqN9T with extra routing info to go via nodes 029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255 then 039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255 - # > lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsfpp3qjmp7lwpagxun9pygexvgpjdc4jdj85fr9yq20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzqj9n4evl6mr5aj9f58zp6fyjzup6ywn3x6sk8akg5v4tgn2q8g4fhx05wf6juaxu9760yp46454gpg5mtzgerlzezqcqvjnhjh8z3g2qqdhhwkj - # - # Breakdown: - # - # * `lnbc`: prefix, lightning on bitcoin mainnet - # * `20m`: amount (20 milli-bitcoin) - # * `1`: Bech32 separator - # * `pvjluez`: timestamp (1496314658) - # * `p`: payment hash... - # * `h`: tagged field: hash of description... - # * `f`: tagged field: fallback address - # * `pp`: `data_length` (`p` = 1. 1 * 32 + 1 == 33) - # * `3` = 17, so P2PKH address - # * `qjmp7lwpagxun9pygexvgpjdc4jdj85f`: 160 bit P2PKH address - # * `r`: tagged field: route information - # * `9y`: `data_length` (`9` = 5, `y` = 4. 5 * 32 + 4 = 164) - # `q20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqqqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqqqqqqq7qqzq`: pubkey `029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255`, `short_channel_id` 0102030405060708, `fee_base_msat` 1 millisatoshi, `fee_proportional_millionths` 20, `cltv_expiry_delta` 3. pubkey `039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255`, `short_channel_id` 030405060708090a, `fee_base_msat` 2 millisatoshi, `fee_proportional_millionths` 30, `cltv_expiry_delta` 4. - # * `j9n4evl6mr5aj9f58zp6fyjzup6ywn3x6sk8akg5v4tgn2q8g4fhx05wf6juaxu9760yp46454gpg5mtzgerlzezqcqvjnhjh8z3g2qq`: signature - # * `dhhwkj`: Bech32 checksum - b11 = l1.rpc.decodepay('lnbc20m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqsfpp3qjmp7lwpagxun9pygexvgpjdc4jdj85fr9yq20q82gphp2nflc7jtzrcazrra7wwgzxqc8u7754cdlpfrmccae92qgzqvzq2ps8pqqqqqqpqqqqq9qqqvpeuqafqxu92d8lr6fvg0r5gv0heeeqgcrqlnm6jhphu9y00rrhy4grqszsvpcgpy9qqqqqqgqqqqq7qqzqj9n4evl6mr5aj9f58zp6fyjzup6ywn3x6sk8akg5v4tgn2q8g4fhx05wf6juaxu9760yp46454gpg5mtzgerlzezqcqvjnhjh8z3g2qqdhhwkj', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon') - assert b11['currency'] == 'bc' - assert b11['msatoshi'] == 20 * 10**11 // 1000 - assert b11['created_at'] == 1496314658 - assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['expiry'] == 3600 - assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - assert len(b11['fallbacks']) == 1 - assert b11['fallbacks'][0]['type'] == 'P2PKH' - assert b11['fallbacks'][0]['addr'] == '1RustyRX2oai4EYYDpQGWvEL62BBGqN9T' - assert len(b11['routes']) == 1 - assert len(b11['routes'][0]) == 2 - assert b11['routes'][0][0]['pubkey'] == '029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255' - # 0x010203:0x040506:0x0708 - assert b11['routes'][0][0]['short_channel_id'] == '66051:263430:1800' - assert b11['routes'][0][0]['fee_base_msat'] == 1 - assert b11['routes'][0][0]['fee_proportional_millionths'] == 20 - assert b11['routes'][0][0]['cltv_expiry_delta'] == 3 - - assert b11['routes'][0][1]['pubkey'] == '039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255' - # 0x030405:0x060708:0x090a - assert b11['routes'][0][1]['short_channel_id'] == '197637:395016:2314' - assert b11['routes'][0][1]['fee_base_msat'] == 2 - assert b11['routes'][0][1]['fee_proportional_millionths'] == 30 - assert b11['routes'][0][1]['cltv_expiry_delta'] == 4 - - # > ### On mainnet, with fallback (P2SH) address 3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX - # > lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppj3a24vwu6r8ejrss3axul8rxldph2q7z9kmrgvr7xlaqm47apw3d48zm203kzcq357a4ls9al2ea73r8jcceyjtya6fu5wzzpe50zrge6ulk4nvjcpxlekvmxl6qcs9j3tz0469gq5g658y - # - # Breakdown: - # - # * `lnbc`: prefix, lightning on bitcoin mainnet - # * `20m`: amount (20 milli-bitcoin) - # * `1`: Bech32 separator - # * `pvjluez`: timestamp (1496314658) - # * `p`: payment hash... - # * `f`: tagged field: fallback address. - # * `pp`: `data_length` (`p` = 1. 1 * 32 + 1 == 33) - # * `j3a24vwu6r8ejrss3axul8rxldph2q7z9`: `j` = 18, so P2SH address - # * `h`: tagged field: hash of description... - # * `2jhz8j78lv2jynuzmz6g8ve53he7pheeype33zlja5azae957585uu7x59w0f2l3rugyva6zpu394y4rh093j6wxze0ldsvk757a9msq`: signature - # * `mf9swh`: Bech32 checksum - b11 = l1.rpc.decodepay('lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppj3a24vwu6r8ejrss3axul8rxldph2q7z9kmrgvr7xlaqm47apw3d48zm203kzcq357a4ls9al2ea73r8jcceyjtya6fu5wzzpe50zrge6ulk4nvjcpxlekvmxl6qcs9j3tz0469gq5g658y', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon') - assert b11['currency'] == 'bc' - assert b11['msatoshi'] == 20 * 10**11 // 1000 - assert b11['created_at'] == 1496314658 - assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['expiry'] == 3600 - assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - assert len(b11['fallbacks']) == 1 - assert b11['fallbacks'][0]['type'] == 'P2SH' - assert b11['fallbacks'][0]['addr'] == '3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX' + b11 = l1.rpc.decodepay('lngrs2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qesh2z5s6s0vjmq05mva9wp7l2pynjm2x3wf8zcj4kfa040wqzprsmyrdeuc8l7eemqt56r3srwvjetej72xdhnr4r74nellv7hlkgqqscvgy') - # > ### On mainnet, with fallback (P2WPKH) address bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 - # > lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kepvrhrm9s57hejg0p662ur5j5cr03890fa7k2pypgttmh4897d3raaq85a293e9jpuqwl0rnfuwzam7yr8e690nd2ypcq9hlkdwdvycqa0qza8 - # - # * `lnbc`: prefix, lightning on bitcoin mainnet - # * `20m`: amount (20 milli-bitcoin) - # * `1`: Bech32 separator - # * `pvjluez`: timestamp (1496314658) - # * `p`: payment hash... - # * `f`: tagged field: fallback address. - # * `pp`: `data_length` (`p` = 1. 1 * 32 + 1 == 33) - # * `q`: 0, so witness version 0. - # * `qw508d6qejxtdg4y5r3zarvary0c5xw7k`: 160 bits = P2WPKH. - # * `h`: tagged field: hash of description... - # * `gw6tk8z0p0qdy9ulggx65lvfsg3nxxhqjxuf2fvmkhl9f4jc74gy44d5ua9us509prqz3e7vjxrftn3jnk7nrglvahxf7arye5llphgq`: signature - # * `qdtpa4`: Bech32 checksum - b11 = l1.rpc.decodepay('lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfppqw508d6qejxtdg4y5r3zarvary0c5xw7kepvrhrm9s57hejg0p662ur5j5cr03890fa7k2pypgttmh4897d3raaq85a293e9jpuqwl0rnfuwzam7yr8e690nd2ypcq9hlkdwdvycqa0qza8', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon') - assert b11['currency'] == 'bc' - assert b11['msatoshi'] == 20 * 10**11 // 1000 + assert b11['currency'] == 'grs' + assert b11['msatoshi'] == 250000000 assert b11['created_at'] == 1496314658 assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['expiry'] == 3600 + assert b11['description'] == '1 cup coffee' + assert b11['expiry'] == 60 assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - assert len(b11['fallbacks']) == 1 - assert b11['fallbacks'][0]['type'] == 'P2WPKH' - assert b11['fallbacks'][0]['addr'] == 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4' - # > ### On mainnet, with fallback (P2WSH) address bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3 - # > lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfp4qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q28j0v3rwgy9pvjnd48ee2pl8xrpxysd5g44td63g6xcjcu003j3qe8878hluqlvl3km8rm92f5stamd3jw763n3hck0ct7p8wwj463cql26ava - # - # * `lnbc`: prefix, lightning on bitcoin mainnet - # * `20m`: amount (20 milli-bitcoin) - # * `1`: Bech32 separator - # * `pvjluez`: timestamp (1496314658) - # * `p`: payment hash... - # * `f`: tagged field: fallback address. - # * `p4`: `data_length` (`p` = 1, `4` = 21. 1 * 32 + 21 == 53) - # * `q`: 0, so witness version 0. - # * `rp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q`: 260 bits = P2WSH. - # * `h`: tagged field: hash of description... - # * `5yps56lmsvgcrf476flet6js02m93kgasews8q3jhtp7d6cqckmh70650maq4u65tk53ypszy77v9ng9h2z3q3eqhtc3ewgmmv2grasp`: signature - # * `akvd7y`: Bech32 checksum - b11 = l1.rpc.decodepay('lnbc20m1pvjluezhp58yjmdan79s6qqdhdzgynm4zwqd5d7xmw5fk98klysy043l2ahrqspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqfp4qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q28j0v3rwgy9pvjnd48ee2pl8xrpxysd5g44td63g6xcjcu003j3qe8878hluqlvl3km8rm92f5stamd3jw763n3hck0ct7p8wwj463cql26ava', 'One piece of chocolate cake, one icecream cone, one pickle, one slice of swiss cheese, one slice of salami, one lollypop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon') - assert b11['currency'] == 'bc' - assert b11['msatoshi'] == 20 * 10**11 // 1000 - assert b11['created_at'] == 1496314658 - assert b11['payment_hash'] == '0001020304050607080900010203040506070809000102030405060708090102' - assert b11['expiry'] == 3600 - assert b11['payee'] == '03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad' - assert len(b11['fallbacks']) == 1 - assert b11['fallbacks'][0]['type'] == 'P2WSH' - assert b11['fallbacks'][0]['addr'] == 'bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3' + # FIXME ADD MORE TESTS with pytest.raises(RpcError): l1.rpc.decodepay('1111111') @@ -918,7 +721,7 @@ def test_forward_different_fees_and_cltv(node_factory, bitcoind): .format(bitcoind.rpc.getblockcount() + 20 + 9 + shadow_route)) l2.daemon.wait_for_log("Adding HTLC 0 msat=4999999 cltv={} gave CHANNEL_ERR_ADD_OK" .format(bitcoind.rpc.getblockcount() + 9 + shadow_route)) - l3.daemon.wait_for_log("test_forward_different_fees_and_cltv: Actual amount 4999999msat, HTLC expiry {}" + l3.daemon.wait_for_log("test_forward_different_fees_and_cltv: Actual amount 4999999mgro, HTLC expiry {}" .format(bitcoind.rpc.getblockcount() + 9 + shadow_route)) assert only_one(l3.rpc.listinvoices('test_forward_different_fees_and_cltv')['invoices'])['status'] == 'paid' diff --git a/tests/utils.py b/tests/utils.py old mode 100644 new mode 100755 index 7ec68a812f17..b67c8a2e9c41 --- a/tests/utils.py +++ b/tests/utils.py @@ -35,7 +35,7 @@ config = dict([(line.rstrip().split('=', 1)) for line in configfile]) DEVELOPER = os.getenv("DEVELOPER", config['DEVELOPER']) == "1" -TIMEOUT = int(os.getenv("TIMEOUT", "60")) +TIMEOUT = int(os.getenv("TIMEOUT", "120")) VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1" @@ -258,7 +258,7 @@ def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=None): os.makedirs(regtestdir) self.cmd_line = [ - 'bitcoind', + 'groestlcoind', '-datadir={}'.format(bitcoin_dir), '-printtoconsole', '-server', @@ -270,7 +270,7 @@ def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=None): # For after 0.16.1 (eg. 3f398d7a17f136cd4a67998406ca41a124ae2966), this # needs its own [regtest] section. BITCOIND_REGTEST = {'rpcport': rpcport} - btc_conf_file = os.path.join(bitcoin_dir, 'bitcoin.conf') + btc_conf_file = os.path.join(bitcoin_dir, 'groestlcoin.conf') write_config(btc_conf_file, BITCOIND_CONFIG, BITCOIND_REGTEST) self.rpc = SimpleBitcoinProxy(btc_conf_file=btc_conf_file) @@ -382,7 +382,7 @@ def openchannel(self, remote_node, capacity, addrtype="p2sh-segwit", confirm=Tru self.bitcoin.generate_block(1) if announce: - self.bitcoin.generate_block(5) + self.bitcoin.generate_block(6) if confirm or announce: self.daemon.wait_for_log( @@ -741,7 +741,7 @@ def get_node(self, disconnect=None, options=None, may_fail=False, 'valgrind', '-q', '--trace-children=yes', - '--trace-children-skip=*bitcoin-cli*', + '--trace-children-skip=*groestlcoin-cli*', '--error-exitcode=7', '--log-file={}/valgrind-errors.%p'.format(node.daemon.lightning_dir) ] @@ -789,6 +789,8 @@ def line_graph(self, num_nodes, fundchannel=True, fundamount=10**6, announce=Fal scid = src.get_channel_scid(dst) src.daemon.wait_for_log(r'Received channel_update for channel {scid}\(.\) now ACTIVE'.format(scid=scid)) + bitcoin.generate_block(1) + if not announce: return nodes From a254a9e862a8786e55cf65e67a978e73ddd72179 Mon Sep 17 00:00:00 2001 From: dflate Date: Thu, 27 Sep 2018 08:25:18 +0000 Subject: [PATCH 2/7] fixup benchmark Signed-off-by: dflate --- tests/benchmark.py | 73 ++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 55 deletions(-) diff --git a/tests/benchmark.py b/tests/benchmark.py index ee8fe1a8571b..c54ef5361944 100755 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -11,64 +11,17 @@ import time -num_workers = 10 -num_payments = 100 - - -@pytest.fixture -def executor(): - ex = futures.ThreadPoolExecutor(max_workers=num_workers) - yield ex - ex.shutdown(wait=False) - - -@pytest.fixture(scope="module") -def bitcoind(): - bitcoind = utils.BitcoinD(rpcport=21441) - bitcoind.start() - info = bitcoind.rpc.getblockchaininfo() - # Make sure we have segwit - # Make sure we have some spendable funds - bitcoind.generate_block(123) - start_time = time.time() - # 120 sec timeout - local_timeout = 120 - while (bitcoind.rpc.getblockchaininfo()['blocks'] < 122) and time.time() < start_time + local_timeout: - bitcoind.generate_block(1) - - assert not (bitcoind.rpc.getblockchaininfo()['blocks'] < 122) - - if bitcoind.rpc.getwalletinfo()['balance'] < 1: - logging.debug("Insufficient balance") - raise ValueError("groestlcoind error no funds from generate blocks") - - yield bitcoind - - try: - bitcoind.rpc.stop() - except Exception: - bitcoind.proc.kill() - bitcoind.proc.wait() - +num_payments = 1000 def test_single_hop(node_factory, executor): - #FIXME if VALGRIND=1 - l1 = node_factory.get_node() - l2 = node_factory.get_node() - - l1.rpc.connect(l2.info['id'], 'localhost', port = l2.port) - l1.daemon.wait_for_log('openingd-.*: Handed peer, entering loop') - l1.openchannel(l2, 10000000) - l1.bitcoin.generate_block(1) - route = l1.rpc.getroute(l2.info['id'], 123000, 1 , 9 , l1.info['id'], 10)['route'] - + l1, l2 = node_factory.line_graph(2, fundchannel=True) + route = l1.rpc.getroute(l2.info['id'], 1000, 1 , 9 , l1.info['id'], 10)['route'] print("Collecting invoices") fs = [] invoices = [] for i in tqdm(range(num_payments)): - invoices.append(l2.rpc.invoice(123000, 'invoice-%d' % (i), 'desc')['payment_hash']) - + invoices.append(l2.rpc.invoice(1000, 'invoice-%d' % (i), 'desc')['payment_hash']) print("Sending payments") start_time = time.time() @@ -90,10 +43,7 @@ def do_pay(i): def test_single_payment(node_factory, benchmark): - l1 = node_factory.get_node() - l2 = node_factory.get_node() - l1.rpc.connect(l2.info['id'], 'localhost' , port=l2.port) - l1.openchannel(l2, 4000000) + l1, l2 = node_factory.line_graph(2, fundchannel=True) def do_pay(l1, l2): invoice = l2.rpc.invoice(1000, 'invoice-{}'.format(random.random()), 'desc')['bolt11'] @@ -111,6 +61,19 @@ def bench_invoice(): benchmark(bench_invoice) +def test_pay(node_factory, benchmark): + l1, l2 = node_factory.line_graph(2, fundchannel=True) + invoices = [] + for _ in range(1, num_payments): + invoice = l2.rpc.invoice(1000, 'invoice-{}'.format(random.random()), 'desc')['bolt11'] + invoices.append(invoice) + + def do_pay(l1, l2): + l1.rpc.pay(invoices.pop()) + + benchmark(do_pay, l1, l2) + + def test_start(node_factory, benchmark): benchmark(node_factory.get_node) From 98ce716ff4d8149ff639617c3397ca4fac97ebc1 Mon Sep 17 00:00:00 2001 From: dflate Date: Thu, 27 Sep 2018 09:09:23 +0000 Subject: [PATCH 3/7] fixup run_funding_tx Signed-off-by: dflate --- lightningd/test/run-funding_tx.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lightningd/test/run-funding_tx.c b/lightningd/test/run-funding_tx.c index 9eae41d9300d..83f876cf4723 100644 --- a/lightningd/test/run-funding_tx.c +++ b/lightningd/test/run-funding_tx.c @@ -63,22 +63,23 @@ int main(void) /* BOLT #3: * - * Block 1 coinbase transaction: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100f2052a010000001976a9143ca33c2e4446f4a305f23c80df8ad1afdcf652f988ac00000000 + * Block 1 coinbase transaction: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100002cd6e2150000232102a74321b69723e7574510f2a96d3becea672dd465c747bc6b23b9771a4d02e48aac00000000 */ + input = bitcoin_tx_from_hex(tmpctx, - "02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510108ffffffff0200002cd6e21500002321034da56300c4211accc61b0546168a691fddec00cb0473f8e5b08a7b5ceea699eeac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000", - strlen("02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510108ffffffff0200002cd6e21500002321034da56300c4211accc61b0546168a691fddec00cb0473f8e5b08a7b5ceea699eeac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf900000000")); + "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100002cd6e2150000232102a74321b69723e7574510f2a96d3becea672dd465c747bc6b23b9771a4d02e48aac00000000", + strlen("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0100002cd6e2150000232102a74321b69723e7574510f2a96d3becea672dd465c747bc6b23b9771a4d02e48aac00000000")); assert(input); /* BOLT #3: - * Block 1 coinbase privkey: 6bd078650fcee8444e4e09825227b801a1ca928debb750eb36e6d56124bb20e801 - * # privkey in base58: cRCH7YNcarfvaiY1GWUKQrRGmoezvfAiqHtdRvxe16shzbd7LDMz + * Block 1 coinbase privkey: 8344ce325246cce131a4785b3878daef212643c2d62aa23e170f05f38258807901 + * # privkey in base58: cRysUDzUoa5BqfvaQnLwQ5aXGXsKD4Hh8Ai3sK6UYSx1CNyLBA2q */ - if (!key_from_base58("L5ByerGLTFw6AR7BpxCFFgejDRZ71XkMZipQGfSSnSMVbtCqM7ue", strlen("L5ByerGLTFw6AR7BpxCFFgejDRZ71XkMZipQGfSSnSMVbtCqM7ue"), + if (!key_from_base58("cRysUDzUoa5BqfvaQnLwQ5aXGXsKD4Hh8Ai3sK6UYSx1CNyLBA2q",strlen("cRysUDzUoa5BqfvaQnLwQ5aXGXsKD4Hh8Ai3sK6UYSx1CNyLBA2q"), &testnet, &input_privkey, &inputkey)) abort(); - /* regtest coinbase */ - assert(!testnet); + /* testnet coinbase */ + assert(testnet); printf("* Block 1 coinbase privkey: %s\n", type_to_string(tmpctx, struct privkey, &input_privkey)); @@ -89,11 +90,11 @@ int main(void) * local_funding_pubkey: 023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb * remote_funding_pubkey: 030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c1 */ - if (!pubkey_from_hexstr("023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb", - strlen("023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb"), + if (!pubkey_from_hexstr("0282600e6ffb205676f45b19bd4ff3bd7b0980dcb8d7979fe988516d7e7e95db27", + strlen("0282600e6ffb205676f45b19bd4ff3bd7b0980dcb8d7979fe988516d7e7e95db27"), &local_funding_pubkey)) abort(); - if (!pubkey_from_hexstr("030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c1", + if (!pubkey_from_hexstr("0282600e6ffb205676f45b19bd4ff3bd7b0980dcb8d7979fe988516d7e7e95db27", strlen("030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c1"), &remote_funding_pubkey)) abort(); From 7358acf6de862fc56699be3493b0ceacaac9b1f1 Mon Sep 17 00:00:00 2001 From: dflate Date: Thu, 27 Sep 2018 09:13:42 +0000 Subject: [PATCH 4/7] fixup doc Signed-off-by: dflate --- doc/lightning-listfunds.7.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lightning-listfunds.7.txt b/doc/lightning-listfunds.7.txt index 2be1990fc8fa..300a1451ac4d 100644 --- a/doc/lightning-listfunds.7.txt +++ b/doc/lightning-listfunds.7.txt @@ -46,7 +46,7 @@ number and output index of the channel funding transaction). (values rounded to the nearest satoshi as internal storage is in millisatoshi). - 'channel_total_gro' -channel value in gro -(values rounded to the nearest satoshi as internal storage is in millisatoshi). +(values rounded to the nearest gro's as internal storage is in milligro). - 'funding_txid' - funding transaction id. From 89cda14324adff217a3d78b966fc4f70c83fb2fc Mon Sep 17 00:00:00 2001 From: dflate Date: Thu, 27 Sep 2018 09:26:57 +0000 Subject: [PATCH 5/7] fixups Signed-off-by: dflate --- doc/lightning-listfunds.7 | 8 ++++---- doc/lightning-listfunds.7.txt | 2 +- doc/lightningd-config.5 | 2 +- doc/lightningd-config.5.txt | 2 +- tests/fixtures.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/lightning-listfunds.7 b/doc/lightning-listfunds.7 index 39cc525c1e43..2223fd2bb1dd 100644 --- a/doc/lightning-listfunds.7 +++ b/doc/lightning-listfunds.7 @@ -2,12 +2,12 @@ .\" Title: lightning-listfunds .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 -.\" Date: 09/25/2018 +.\" Date: 09/27/2018 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "LIGHTNING\-LISTFUNDS" "7" "09/25/2018" "\ \&" "\ \&" +.TH "LIGHTNING\-LISTFUNDS" "7" "09/27/2018" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -131,7 +131,7 @@ Each entry in \fIchannels\fR will include: .IP \(bu 2.3 .\} \fIchannel_sat\fR -\- available satoshis on our node\(cqs end of the channel (values rounded to the nearest satoshi as internal storage is in millisatoshi)\&. +\- available satoshis on our node\(cqs end of the channel (values rounded to the nearest gro as internal storage is in milligro)\&. .RE .sp .RS 4 @@ -143,7 +143,7 @@ Each entry in \fIchannels\fR will include: .IP \(bu 2.3 .\} \fIchannel_total_gro\fR -\-channel value in gro (values rounded to the nearest satoshi as internal storage is in millisatoshi)\&. +\-channel value in gro (values rounded to the nearest gro\(cqs as internal storage is in milligro)\&. .RE .sp .RS 4 diff --git a/doc/lightning-listfunds.7.txt b/doc/lightning-listfunds.7.txt index 300a1451ac4d..f088c5644dbc 100644 --- a/doc/lightning-listfunds.7.txt +++ b/doc/lightning-listfunds.7.txt @@ -43,7 +43,7 @@ Each entry in 'channels' will include: number and output index of the channel funding transaction). - 'channel_sat' - available satoshis on our node's end of the channel -(values rounded to the nearest satoshi as internal storage is in millisatoshi). +(values rounded to the nearest gro as internal storage is in milligro). - 'channel_total_gro' -channel value in gro (values rounded to the nearest gro's as internal storage is in milligro). diff --git a/doc/lightningd-config.5 b/doc/lightningd-config.5 index 67918be21dab..c5e973e2e5c9 100644 --- a/doc/lightningd-config.5 +++ b/doc/lightningd-config.5 @@ -183,7 +183,7 @@ Up to 32 UTF\-8 characters to tag your node\&. Completely silly, since anyone ca .PP \fBfee\-base\fR=\fIMILLISATOSHI\fR .RS 4 -The base fee to charge for every payment which passes through\&. Note that millisatoshis are a very, very small unit! +The base fee to charge for every payment which passes through\&. Note that milligro's are a very, very small unit! .RE .PP \fBfee\-per\-gro\fR=\fIMILLIONTHS\fR diff --git a/doc/lightningd-config.5.txt b/doc/lightningd-config.5.txt index 36b690bea129..762ca209bc19 100644 --- a/doc/lightningd-config.5.txt +++ b/doc/lightningd-config.5.txt @@ -131,7 +131,7 @@ Lightning node customization options: *fee-base*='MILLISATOSHI':: The base fee to charge for every payment which passes through. Note that - millisatoshis are a very, very small unit! + milligro are a very, very small unit! *fee-per-gro*='MILLIONTHS':: This is the proportional fee to charge for every payment which passes diff --git a/tests/fixtures.py b/tests/fixtures.py index 697ffdbd2338..f3eec0c52759 100755 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -79,7 +79,7 @@ def bitcoind(directory): if info['version'] < 2160000: bitcoind.rpc.stop() - raise ValueError("bitcoind is too old. At least version (v21.6.0)" + raise ValueError("bitcoind is too old. At least version (v2.16.0)" " is needed, current version is {}".format(info['version'])) # Make sure we have some spendable funds From 9be99b2a8b86145a472eb16d341bd8817203efe3 Mon Sep 17 00:00:00 2001 From: dflate Date: Thu, 27 Sep 2018 09:31:31 +0000 Subject: [PATCH 6/7] fixups doc Signed-off-by: dflate --- doc/lightning-listfunds.7 | 2 +- doc/lightning-listfunds.7.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lightning-listfunds.7 b/doc/lightning-listfunds.7 index 2223fd2bb1dd..a85f2f97487d 100644 --- a/doc/lightning-listfunds.7 +++ b/doc/lightning-listfunds.7 @@ -131,7 +131,7 @@ Each entry in \fIchannels\fR will include: .IP \(bu 2.3 .\} \fIchannel_sat\fR -\- available satoshis on our node\(cqs end of the channel (values rounded to the nearest gro as internal storage is in milligro)\&. +\- available gro's on our node\(cqs end of the channel (values rounded to the nearest gro as internal storage is in milligro)\&. .RE .sp .RS 4 diff --git a/doc/lightning-listfunds.7.txt b/doc/lightning-listfunds.7.txt index f088c5644dbc..510f941f8628 100644 --- a/doc/lightning-listfunds.7.txt +++ b/doc/lightning-listfunds.7.txt @@ -42,7 +42,7 @@ Each entry in 'channels' will include: - 'short_channel_id' - as per BOLT 7 (representing the block, transaction number and output index of the channel funding transaction). -- 'channel_sat' - available satoshis on our node's end of the channel +- 'channel_sat' - available gro's on our node's end of the channel (values rounded to the nearest gro as internal storage is in milligro). - 'channel_total_gro' -channel value in gro From cb948f8c10df951208940c72dfe53f766d310ab4 Mon Sep 17 00:00:00 2001 From: dflate Date: Thu, 27 Sep 2018 09:45:31 +0000 Subject: [PATCH 7/7] fixups Signed-off-by: dflate --- doc/lightning-listfunds.7 | 2 +- tests/fixtures.py | 2 +- tests/utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/lightning-listfunds.7 b/doc/lightning-listfunds.7 index a85f2f97487d..ffb1a69e0fb7 100644 --- a/doc/lightning-listfunds.7 +++ b/doc/lightning-listfunds.7 @@ -143,7 +143,7 @@ Each entry in \fIchannels\fR will include: .IP \(bu 2.3 .\} \fIchannel_total_gro\fR -\-channel value in gro (values rounded to the nearest gro\(cqs as internal storage is in milligro)\&. +\-channel value in gro (values rounded to the nearest gro as internal storage is in milligro)\&. .RE .sp .RS 4 diff --git a/tests/fixtures.py b/tests/fixtures.py index f3eec0c52759..5fd40bf5c441 100755 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -79,7 +79,7 @@ def bitcoind(directory): if info['version'] < 2160000: bitcoind.rpc.stop() - raise ValueError("bitcoind is too old. At least version (v2.16.0)" + raise ValueError("groestlcoind is too old. At least version 2160000 (v2.16.0)" " is needed, current version is {}".format(info['version'])) # Make sure we have some spendable funds diff --git a/tests/utils.py b/tests/utils.py index b67c8a2e9c41..d34d1e5dd90f 100755 --- a/tests/utils.py +++ b/tests/utils.py @@ -278,7 +278,7 @@ def start(self): TailableProc.start(self) self.wait_for_log("Done loading", timeout=TIMEOUT) - logging.info("BitcoinD started") + logging.info("GroestlcoinD started") def generate_block(self, numblocks=1): # As of 0.16, generate() is removed; use generatetoaddress.