Commit Graph

61 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
e910b12d33
lnd: fix issues reported by golint+govet
github.com/lightningnetwork/lnd  master ✗

                                           0m ◒
▶ golint
htlcswitch.go:292:4: should replace numUpdates += 1 with numUpdates++
htlcswitch.go:554:6: var onionId should be onionID
htlcswitch.go:629:7: var onionId should be onionID
lnd_test.go:133:1: context.Context should be the first parameter of a
function
lnd_test.go:177:1: context.Context should be the first parameter of a
function
networktest.go:84:2: struct field nodeId should be nodeID
peer.go:1704:16: should omit 2nd value from range; this loop is
equivalent to `for invoice := range ...`
rpcserver.go:57:6: func newRpcServer should be newRPCServer

github.com/lightningnetwork/lnd  master ✗

                                        9m ⚑ ◒  ⍉
▶ go vet
features.go:12: github.com/lightningnetwork/lnd/lnwire.Feature
composite literal uses unkeyed fields
fundingmanager.go:380: no formatting directive in Errorf call
exit status 1
2017-02-22 14:58:37 -08:00
Olaoluwa Osuntokun
026753bce4
test: add assertion within integration tests for proper preimage after send
In this commit we modify the testSingleHopInvoice test to ensure that
we obtain the proper preimage from the SendPayment RPC upon successful
payment completion.
2017-02-21 01:43:57 -08:00
Olaoluwa Osuntokun
a34df2f7d8
test: modify force close integration test to assert bob gets his balance
This commit adds a new assertion in the channel force closure test in
order to exercise the fix for a bug related to channel force closure
implemented in a prior commit. With this new assertion, we ensure that
bob is aware of his on-chain balance after a force channel closure
initiated by alice.
2017-02-07 20:54:11 -08:00
Olaoluwa Osuntokun
28aa092ac2
test: eliminate sleep by tightly polling for existence of node
This commit elminates a sleep in the testHtlcErrorPropagation test by
instead polling for the existence of our target in a tight loop. This
is a small patch over until we get a “topology client” within the
ChannelRouter. This method is robust and can be applied in future tests
until we get the notification client into the ChannelRouter.
2017-01-29 17:16:58 -08:00
Olaoluwa Osuntokun
f18a21fc54
test: correct error message for htlc error propagation test 2017-01-29 17:08:02 -08:00
Olaoluwa Osuntokun
07f8dab560
cmd/lncli: rename --draw to --render for describegraph 2017-01-29 15:38:28 -08:00
Olaoluwa Osuntokun
1ee4c661bc
server: optimize message broadcast+targeted send
This commit slightly optimizes the process of broadcasting a message to
a list of peers, and also sending a set of messages to a target peer.

When broadcasting a message to a set of target peers, we now launch a
goroutine for each send as to not block the ChannelRouter on an
individual send. When sending a set of messages to a target peer, we
now give up the mutex as soon as we’ve access the map, rather than
holding onto it until the sending is complete.
2017-01-29 15:03:05 -08:00
Olaoluwa Osuntokun
a658fabf48
funding: disallow channel creation before lnd is synced to the chain
This commit adds a new restriction around funding channels at the
daemon level: lnd nodes will not allow either the initiation or the
acceptance of a channel before the node is fully synced to the best
known chain.

This fixes a class of bug that arises when a new node joins the network
and either attempts to open a channel or has a channel extended to them
before the node is fully synced to the network.
2017-01-24 17:12:57 -08:00
Trevin Hofmann
40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -08:00
Christopher Jämthagen
5c6d196ff8 test: reject non-standard transactions in integration tests 2017-01-17 16:23:50 -08:00
Olaoluwa Osuntokun
9662887d2f
rpcserver+cmd/lncli: implement DecodePayReq
This commit implements the newly added RPC to decode payment requests
passed over the command line or directly via gRPC.

With this tool, users can now examine payment requests they see in the
wild for diagnostic or debugging purposes.
2017-01-17 13:49:44 -08:00
Olaoluwa Osuntokun
dc280521dd
test: fix logging messages for funding push test 2017-01-16 17:08:56 -08:00
Olaoluwa Osuntokun
9ccf9947a2
test: add ability to push funds during funding to OpenChannel
This commit adds support for pushing funds during the funding process
to the helper method in the integration testing framework.

Additionally, we also modify the simple testBasicChannelFunding test to
also push over an amount in order to test the functionality within the
daemon.
2017-01-09 19:34:28 -08:00
Olaoluwa Osuntokun
d3612ac00a
test: let daemon create a new pre-image in the multi-hop test
If the RPreimage field is left off when adding a new invoice, the
daemon will create a new random pre-image itself for the requested
payment.
2017-01-07 21:22:29 -08:00
Olaoluwa Osuntokun
c61ea17df5
test: add an integration tests for multi-hop payment errors
With this commit we have gained a new interaction tests which excursus
all the possible multi-hop error cases aside from:
  * sphinx packet corruption

The case can’t be adequately tested with the current integration
testing framework as we can’t arbitrary modify packets en route to
peers within the proto test network. In a future commit, the p2p test
framework whcih has been started by andrew.shvv will be used to ensure
proper handling of this error.
2017-01-07 21:22:20 -08:00
Olaoluwa Osuntokun
387d41e5df
test: shutdown extra non "seed" nodes after tests they're created in
This commit ensures that any extra nodes that were created as part of
the integration tests are shutdown at the end of the test after it
completes successfully. This should speed up the tests as we’ll no
longer have lingering nodes in the background of the test consuming
resources.
2017-01-07 21:21:03 -08:00
Olaoluwa Osuntokun
573eb1dfc4
test: modify single hop invoice test to also test zpay32 payment requests
This commit adds an additional test case to the `testSingleHopInvoice`
test in order to exercise the proper parsing and dispatching of encoded
payment requests using the zpay32 encoding scheme.

With this test we ensure that the daemon properly encodes payreq’s upon
the creation of invoices, and also that the SendPayment RPC is able to
parse the payment request and properly complete a payment based off of
one.
2017-01-07 21:21:00 -08:00
bryanvu
24a99ade66 test: remove concurrent payment sends from testMultiHopPayments
testMultiHopPayments was failing intermittently due to a lack of
thread-safety in the gRPC stream. This commit takes payment sending out
of goroutines so that they execute serially.
2017-01-07 19:39:01 -08:00
Olaoluwa Osuntokun
5affed38fc
multi: update btcsuite API's to latest upstream changes
This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
2017-01-05 13:56:34 -08:00
Olaoluwa Osuntokun
fb3bc04d65
test: mine enough blocks to active CSV+segwit in integration tests
As we’re switching to a more up to date btcd branch that properly
guards the activation of the soft-forks we rely on, we’ll also need to
ensure the two soft-forks have activated.
2017-01-05 13:18:37 -08:00
bryanvu
aa04f82a15 utxonursery: added persistence to transaction output states
Moved transaction states from in-memory maps to persistent BoltDB
buckets. This allows channel force closes to operate reliably if the
daemon is shut down and restarted at any point during the forced
channel closure process.
2017-01-03 16:23:07 -08:00
Olaoluwa Osuntokun
b991cd3d78
multi: allow force channel closures while not connected to peer
This commit adds a much needed feature to the daemon, namely the
ability to force close a channel while the source daemon doesn’t have
an active connection to the counter party. Previously this wasn’t
possible as ALL channel closures were routed through the htlcSwitch
which is only able to trigger a channel closure if the peer is online.

To remedy this, if the closure type is “force” then, we now handle the
channel closure and related RPC streaming updates from the call handler
site of the RPC itself. As a result, there are now only two htlcSwitch
channel closure types: breach, and regular. The logic that’s now in the
rpcSever should likely be refactored into a distinct sub-system, but
getting the initial functionality in is important.

Finally, the channel breach integration test has been modified to skip
connection the peers before attempting the forceful channel closure of
a revoked state as the remote peer no longer needs to be online.
2017-01-03 16:04:47 -08:00
Olaoluwa Osuntokun
57c0f8f005
test: add short sleep before channel assert to account for gossip propagation
This commit adds a short sleep before a channel assertion in the
`testMaxPendingChannels` test. This sleep serves to give the nodes
enough time to propagate the new channel announcement over the
authenticated gossip system. Without this sleep, the call may be issued
in a state wherein only half of the channel announcement has fully
propagated.
2017-01-02 15:47:02 -08:00
Olaoluwa Osuntokun
82815b703e
rpcserver: refactor logic for ListPayments/DeleteAllPayments
This commit slightly refactors the logic for the new outgoing payment
related RPC’s to more closely match the style of the rest of the
codebase. Additionally the tests have been updated to reflect the
changes to the protos of the new RPC’s.
2016-12-30 16:42:10 -08:00
Olaoluwa Osuntokun
2651541139
test: update integration tests to use DescribeGraph 2016-12-27 16:44:58 -08:00
BitfuryLightning
1c7f87c3f1
channeldb: refactor payments code
Go-fmt files. Refactored code according to the guidelines.
Enhanced payment test: add error checking
and individual context for each API call.
Add Timestamp field to payment struct.
2016-12-27 16:42:56 -08:00
BitfuryLightning
eb4d0e035e channeldb: save outgoing payments
Add structure for outgoing payments. Saving payment in DB
after successful payment send. Add RPC call for listing
all payments.
2016-12-27 16:16:23 -08:00
Olaoluwa Osuntokun
a88b093843
test: due to persistent conn retry, don't consider already connected an error 2016-12-14 18:24:16 -08:00
Andrey Samokhvalov
5a82240c6a lnwire+lnwallet+fundingmanager: general improvements 2016-12-13 11:01:57 -08:00
Olaoluwa Osuntokun
a6f7f05323
test: update integration test helper funds to latest btcrpcclient API 2016-12-12 15:57:22 -08:00
Olaoluwa Osuntokun
e0c09a016b
lnwallet: use stored initiator bool to properly construct close tx
This commit modifies the channel closing logic to remove the hard coded
bools indicating which side is attempting the closure. With the recent
changes, the initiator must always pay the channel closure fees.

This information is recently stored on disk, therefore we can use the
boolean to ensure that the closure transaction is created properly no
matter who initiates the close.

This fixes a bug.
2016-12-07 22:39:33 -08:00
Olaoluwa Osuntokun
494fcec874
breacharbiter: introduce new sub-system to watch for breaches
This commit introduces a new sub-system into the daemon whose job it is
to vigilantly watch for any potential channel breaches throughout the
up-time of the daemon. The logic which was moved from the utxoNursery
in a prior commit now resides within the breachArbiter.

Upon start-up the breachArbiter will query the database for all active
channels, launching a goroutine for each channel in order to be able to
take action if a channel breach is detected. The breachArbiter is also
responsible for notifying the htlcSwitch about channel breaches in
order to black-list the breached linked during any multi-hop forwarding
decisions.
2016-11-28 19:44:09 -08:00
Andrey Samokhvalov
5b9e4ae61e general: fix typos, rename variables, add comments 2016-11-23 20:02:29 -06:00
bryanvu
2bf5794645 lnrpc: added rpc support for querying a channel's satoshis sent/received
Added total_satoshis_sent and total_satoshis_received fields to the
ListChannels RPC call.
2016-11-22 14:57:03 -06:00
Olaoluwa Osuntokun
1199786498
test: ensure all invoices are unique
This commit modifies the invoices generated during the
testRevokedCloseRetribution integration test to ensure that the
invoices are globally unique within the context of the integration
tests.
2016-11-21 21:52:08 -06:00
Olaoluwa Osuntokun
6ff357686f
test: add integration test to excerise uncooperative channel breaches
This commit adds a new rather extensive integration tests to excerise
uncooperative channel breaches triggered by a counter-party
broadcasting a previously revoked commitment state.

In order to programmatically script such logic using the integration
testing framework, the test manually manipulates the database files of
one of the nodes within the test network in order to force Bob to
travel back in time to a revoked commitment state. With this
manipulation, we then force Bob to broadcast the revoked state,
triggering Alice’s retribution logic which sweeps ALL the funds within
the channel.
2016-11-21 21:17:00 -06:00
Olaoluwa Osuntokun
5e5bc3884a
test: modify closeChannelAndAssert to allow force close, return txid 2016-11-21 21:13:12 -06:00
Olaoluwa Osuntokun
8608ffba15
test: cancel the daemon panic goroutine after interaction tests 2016-11-16 12:43:08 -08:00
Olaoluwa Osuntokun
f12b9b4bd7 Merge pull request #66 from AndrewSamokhvalov/temporary_fix_multihop
Temporary fix multihop
2016-11-08 14:58:01 -08:00
Andrey Samokhvalov
6d57fb08b3 tests: temporary fix multi hop test 2016-11-08 12:33:10 +03:00
Andrey Samokhvalov
75dd860ac9 tests: fix defer+goroutine by returning previous test structure (without goroutine) 2016-11-08 11:41:16 +03:00
Olaoluwa Osuntokun
d181aad8e2
test: use *testing.T directly outside of test execution 2016-10-23 20:04:05 -07:00
Olaoluwa Osuntokun
517255fdb1
test: rename CT to harnessTest, ensure all RPC's get distinct timeouts
This commit slightly modifies the existing CT struct in order to
maintain consistency with code-style. As a result of the name change,
all references have also been renamed from `ct` to `t`.

The Error and Errorf methods have been removed in favor of forcing
everything to be reported via `Fatalf`. Additionally a new method
(ProcessErrors) has been introduced to the networkHarness class in
order to encapsulate the underlying channel.
2016-10-23 19:27:24 -07:00
Andrey Samokhvalov
7196c4bb1c fundingmanager: add max pending channel check 2016-10-22 02:15:35 +03:00
Andrey Samokhvalov
e6f45a948e testing: add CT (Custom Testing) structure; create uniq point for 'lnd process errors' and 'test panic/failed errors' handling 2016-10-22 02:11:12 +03:00
andrew.shvv
56ab64ecab test: add basic test for multi-channel opening+closing 2016-10-16 21:36:43 -07:00
Olaoluwa Osuntokun
79e7862525
test: add integration tests for invoice settle/add notifications 2016-10-15 14:46:12 -07:00
Olaoluwa Osuntokun
80d38d6bbc
test: add network test case for repeated multi-hop invoice payments 2016-09-26 10:42:02 -07:00
Olaoluwa Osuntokun
bf0945a6bf
test: add test case for a simple one-hop invoice scenario 2016-09-26 10:41:05 -07:00
Olaoluwa Osuntokun
e6ced8ee7a
test: ensure tests nodes are started with the debughtlc flag 2016-09-21 19:49:21 -07:00