rgb-cln/contrib/pyln-testing
Rusty Russell 2482fd4427 pytest: detect RBF more reliably
```
2023-10-30T20:52:48.0652403Z [gw2] [ 63%] FAILED tests/test_closing.py::test_onchain_timeout[True]
...
...
bitcoind.generate_block(4)
        bitcoind.generate_block(1, wait_for_mempool=txid1)
>       l1.mine_txid_or_rbf(txid2)

tests/test_closing.py:1987: 
```

Turns out that the DEBUG-level "no feechange" RBF can happen, as we can actually
call the RBF routine before we even broadcast the first one:


```
2023-10-30T21:07:42.2201798Z lightningd-1 2023-10-30T20:49:44.184Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: RBF onchain txid 14aa9c78fbcbff01faf96d3e734eba52355437078a67f46b8fbca9e72d1494e5 (fee 121sat) with txid 14aa9c78fbcbff01faf96d3e734eba52355437078a67f46b8fbca9e72d1494e5 (fee 121sat)
2023-10-30T21:07:42.2214788Z lightningd-1 2023-10-30T20:49:44.185Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: RBF 02000000000101e37ffb981f28875509cd0069de2b457763cb252c9372725c1d8ba813c493b09e030000000005000000019b920d0000000000160014071c49cad2f420f3c805f9f6b98a57269cb1415003473044022007fff5174a0ea980ad158a4893cf9dcbc87dba1edf28adf8379bd7cdca6d8d1e02201b55b50e79446e580b4c53c6894f6c0384a36fd228a553f975c38cb128e454fd01004b632102f1d7d753e58aa4a0b3f245775f5588ac0f02f072d1854c5d846c3d1bac0738bb6755b27521033dbabb9463042008146aa9e5be6bc3fb48cfb3ead4bb1876f1c1a73159cc56a068ac00000000->02000000000101e37ffb981f28875509cd0069de2b457763cb252c9372725c1d8ba813c493b09e030000000005000000019b920d0000000000160014071c49cad2f420f3c805f9f6b98a57269cb1415003473044022007fff5174a0ea980ad158a4893cf9dcbc87dba1edf28adf8379bd7cdca6d8d1e02201b55b50e79446e580b4c53c6894f6c0384a36fd228a553f975c38cb128e454fd01004b632102f1d7d753e58aa4a0b3f245775f5588ac0f02f072d1854c5d846c3d1bac0738bb6755b27521033dbabb9463042008146aa9e5be6bc3fb48cfb3ead4bb1876f1c1a73159cc56a068ac00000000
2023-10-30T21:07:42.2230434Z lightningd-1 2023-10-30T20:49:44.196Z DEBUG   lightningd: sendrawtransaction: 02000000000101e37ffb981f28875509cd0069de2b457763cb252c9372725c1d8ba813c493b09e030000000005000000019b920d0000000000160014071c49cad2f420f3c805f9f6b98a57269cb1415003473044022007fff5174a0ea980ad158a4893cf9dcbc87dba1edf28adf8379bd7cdca6d8d1e02201b55b50e79446e580b4c53c6894f6c0384a36fd228a553f975c38cb128e454fd01004b632102f1d7d753e58aa4a0b3f245775f5588ac0f02f072d1854c5d846c3d1bac0738bb6755b27521033dbabb9463042008146aa9e5be6bc3fb48cfb3ead4bb1876f1c1a73159cc56a068ac00000000
...
2023-10-30T21:07:42.2258455Z lightningd-1 2023-10-30T20:49:44.250Z DEBUG   plugin-bcli: sendrawtx exit 0 (bitcoin-cli -regtest -datadir=/tmp/ltests-b6i5i0cl/test_onchain_timeout_1/lightning-1/ -rpcport=43613 -rpcuser=... -stdinrpcpass sendrawtransaction 02000000000101e37ffb981f28875509cd0069de2b457763cb252c9372725c1d8ba813c493b09e030000000005000000019b920d0000000000160014071c49cad2f420f3c805f9f6b98a57269cb1415003473044022007fff5174a0ea980ad158a4893cf9dcbc87dba1edf28adf8379bd7cdca6d8d1e02201b55b50e79446e580b4c53c6894f6c0384a36fd228a553f975c38cb128e454fd01004b632102f1d7d753e58aa4a0b3f245775f5588ac0f02f072d1854c5d846c3d1bac0738bb6755b27521033dbabb9463042008146aa9e5be6bc3fb48cfb3ead4bb1876f1c1a73159cc56a068ac00000000 0) 
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-11-01 14:11:28 +10:30
..
pyln/testing pytest: detect RBF more reliably 2023-11-01 14:11:28 +10:30
tests pyln-testing: Add a dummy test to check functionality 2020-08-30 20:03:42 +02:00
.gitignore pyln: Update the makefile to use poetry for publishing 2022-05-01 14:22:49 +09:30
Makefile pyln: use poetry version, add target to check version, use poetry publish. 2022-09-22 11:41:11 +02:00
README.md pyln: Make the grpcio dependencies optional 2023-07-21 15:12:03 +09:30
pyproject.toml pyln-client, pyln-proto, pyln-testing: update to new versions. 2023-08-03 09:05:59 +09:30

README.md

pyln-testing: A library to write tests against Core Lightning

This library implements a number of utilities that help building tests for Core Lightning nodes. In particular it provides a number of pytest fixtures that allow the management of a test network of a given topology and then execute a test scenarion.

pyln-testing is used by Core Lightning for its internal tests, and by the community plugin directory to exercise the plugins.

Installation

pyln-testing is available on pip:

pip install pyln-testing

Alternatively you can also install the development version to get access to currently unreleased features by checking out the Core Lightning source code and installing into your python3 environment:

git clone https://github.com/ElementsProject/lightning.git
cd lightning/contrib/pyln-testing
poetry install

This will add links to the library into your environment so changing the checked out source code will also result in the environment picking up these changes. Notice however that unreleased versions may change API without warning, so test thoroughly with the released version.

Testing GRPC Bindings

The grpc bindings can be tested by setting the CLN_TEST_GRPC=1 environment variable. This will cause the testing framework to use a grpc client to talk to the cln-grpc plugin, rather than talking directly to the node's JSON-RPC interface. Since the GRPC related dependencies are guarded behind a feature flag in pyln-testing you'll need to install it with the grpc feature enabled in order to be able to run in this mode.

Below is a diagram of how the normal JSON-RPC interaction looks like, followed by one that display the grpc interaction:

CLN -- JSON-RPC -- LightningRpc -- pytest
\_____CLN_____/    \_______pytest_______/
CLN -- JSON-RPC -- cln-rpc -- rpc2grpc converters -- grpc interface -- python grpc client -- python grpc2json converter -- pytest
\_____CLN_____/    \___________cln-grpc-plugin____________________/    \__________________________pytest________________________/

As you can see the grpc mode attempts to emulate the simple JSON-RPC mode by passing the call through a number of conversions. The last step grpc2json is rather incomplete, and will cause quite a few tests to fail for now, until the conversion is completed and we reach feature parity between the interaction modes.