1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 14:40:34 +01:00
eclair/TESTING.md

121 lines
2.9 KiB
Markdown
Raw Normal View History

2016-02-11 17:28:53 +01:00
# Testing eclair and lightningd
2016-02-08 17:00:41 +01:00
## Configure bitcoind to run in regtest mode
2016-06-02 17:15:11 +02:00
Important: you need a segwit version of bitcoin core for this test (see https://github.com/sipa/bitcoin/tree/segwit-master).
Make sure that bitcoin-cli is on the path and edit ~/.bitcoin/bitcoin.conf and add:
2016-02-08 17:00:41 +01:00
```shell
server=1
regtest=1
rpcuser=***
rpcpassword=***
```
2016-06-02 17:15:11 +02:00
To check that segwit is enabled run:
```shell
bitcoin-cli getblockchaininfo
```
and check bip9_softforks:
```
...
"bip9_softforks": {
"csv": {
"status": "active",
"startTime": 0,
"timeout": 999999999999
},
"witness": {
"status": "active",
"startTime": 0,
"timeout": 999999999999
}
}
```
2016-02-08 17:00:41 +01:00
## Start bitcoind
2016-06-02 17:15:11 +02:00
Mine enough blocks to activate segwit blocks:
2016-02-08 17:00:41 +01:00
```shell
2016-06-02 17:15:11 +02:00
bitcoin-cli generate 500
2016-02-08 17:00:41 +01:00
```
##
2016-06-02 17:15:11 +02:00
Start lightningd (here well use port 46000)
2016-02-08 17:00:41 +01:00
```shell
2016-06-02 17:15:11 +02:00
lightningd --port 46000
2016-02-08 17:00:41 +01:00
```
##
Start eclair:
```shell
mvn exec:java -Dexec.mainClass=fr.acinq.eclair.Boot
```
2016-02-11 17:44:40 +01:00
## Tell eclair to connect to lightningd
2016-02-08 17:00:41 +01:00
```shell
2016-02-11 17:27:21 +01:00
curl -X POST -H "Content-Type: application/json" -d '{
2016-02-11 17:43:59 +01:00
"method": "connect",
2016-06-02 17:15:11 +02:00
"params" : [ "localhost", 46000, 3000000 ]
2016-02-11 17:58:15 +01:00
}' http://localhost:8080
2016-02-08 17:00:41 +01:00
```
2016-12-09 17:08:16 +01:00
Since eclair is funder, it will create and publish the funding tx
2016-02-08 17:00:41 +01:00
2016-12-09 17:08:16 +01:00
Mine a few blocks to confirm the funding tx:
2016-02-08 17:00:41 +01:00
```shell
bitcoin-cli generate 10
```
2016-06-02 17:15:11 +02:00
eclair and lightningd are now both in NORMAL state.
You can check this by running:
```shell
lightning-cli getpeers
```
or
```shell
curl -X POST -H "Content-Type: application/json" -d '{
"method": "list",
"params" : [ ]
}' http://localhost:8080
```
2016-02-08 17:00:41 +01:00
## Tell eclair to send a htlc
Well use the following values for R and H:
2016-02-10 11:51:36 +01:00
```
2016-02-08 17:00:41 +01:00
R = 0102030405060708010203040506070801020304050607080102030405060708
H = 8cf3e5f40cf025a984d8e00b307bbab2b520c91b2bde6fa86958f8f4e7d8a609
2016-02-10 11:51:36 +01:00
```
2016-02-08 17:00:41 +01:00
Youll need a unix timestamp that is not too far into the future. Now + 100000 is fine:
```shell
2016-02-11 17:58:15 +01:00
curl -X POST -H "Content-Type: application/json" -d "{
\"method\": \"addhtlc\",
2016-06-02 17:15:11 +02:00
\"params\" : [ 70000000, \"8cf3e5f40cf025a984d8e00b307bbab2b520c91b2bde6fa86958f8f4e7d8a609\", $((`date +%s` + 100000)), \"021acf75c92318d3723098294d2a6a4b08d9abba2ebb5f2df2b4a8e9153e96a5f4\" ]
2016-02-11 17:58:15 +01:00
}" http://localhost:8080
2016-02-08 17:00:41 +01:00
```
2016-06-02 17:15:11 +02:00
## Tell eclair to commit its changes
```shell
curl -X POST -H "Content-Type: application/json" -d "{
\"method\": \"sign\",
\"params\" : [ \"d3f056a084e266ad06ea1ca28a1e080ca07c6b61fac7ce116e48a5c31d688eee\" ]
}" http://localhost:8080
```
2016-02-11 17:44:40 +01:00
## Tell lightningd to fulfill the HTLC:
2016-02-08 17:00:41 +01:00
```shell
2016-06-02 17:15:11 +02:00
./lightning-cli fulfillhtlc 03befb4f8ad1d87d4c41acbb316791fe157f305caf2123c848f448975aaf85c1bb 0102030405060708010203040506070801020304050607080102030405060708
2016-02-08 17:00:41 +01:00
```
Check balances on both eclair and lightningd
## Close the channel
```shell
2016-06-02 17:15:11 +02:00
./lightning-cli close 03befb4f8ad1d87d4c41acbb316791fe157f305caf2123c848f448975aaf85c1bb
2016-02-08 17:00:41 +01:00
```
2016-02-17 11:47:27 +01:00
Mine a few blocks to bury the closing tx
```shell
bitcoin-cli generate 10
```
The channel is now in CLOSED state
2016-02-08 17:00:41 +01:00