Commit Graph

54 Commits

Author SHA1 Message Date
Thomas Eizinger
8d76607343
Refactor monero-harness containers
1. Split up image::Monero into Monerod and MoneroWalletRpc
2. Don't use `bash` to run the internal command. Instead we disable
the entrypoint script as per https://github.com/XMRto/monero#raw-commands
3. Remove the start up delay by listening for the correct log message.
To make this more resilient, we make the log level NOT configurable and
instead always log verbosely.
2021-04-26 18:12:57 +10:00
Thomas Eizinger
64729ffecc
Don't make tag configurable if we never use that 2021-04-26 18:12:56 +10:00
Thomas Eizinger
0970c2bc72
Initialize reqwest clients with verbose logging 2021-04-26 18:12:56 +10:00
Thomas Eizinger
7e688eb7e8
Don't reinvent the wheel
`Alphanumeric` includes uppercase letters and digits as well but
for our usecase, that doesn't matter.
2021-04-26 12:45:41 +10:00
Thomas Eizinger
dc840e1562
Take wallet names by reference
We are always passing constants here. Make that more ergonomic.
2021-04-26 12:45:40 +10:00
Thomas Eizinger
6d06db3259
Use macro-based JSON-RPC client 2021-04-26 12:45:35 +10:00
Daniel Karzel
c976358c37
Multiple swaps with the same peer
- Swap-id is exchanged during execution setup. CLI (Bob) sends the swap-id to be used in his first message.
- Transfer poof and encryption signature messages include the swap-id so it can be properly associated with the correct swap.
- ASB: Encryption signatures are associated with swaps by swap-id, not peer-id.
- ASB: Transfer proofs are still associated to peer-ids (because they have to be sent to the respective peer), but the ASB can buffer multiple
- CLI: Incoming transfer proofs are checked for matching swap-id. If a transfer proof with a different swap-id than the current executing swap is received it will be ignored. We can change this to saving into the database.

Includes concurrent swap tests with the same Bob.

- One test that pauses and starts an additional swap after the transfer proof was received. Results in both swaps being redeemed after resuming the first swap.
- One test that pauses and starts an additional swap before the transfer proof is sent (just after BTC locked). Results in the second swap redeeming and the first swap being refunded (because the transfer proof on Bob's side is lost). Once we store transfer proofs that we receive during executing a different swap into the database both swaps should redeem.

Note that the monero harness was adapted to allow creating wallets with multiple outputs, which is needed for Alice.
2021-04-13 18:16:19 +10:00
Daniel Karzel
ecebbb76b1
Prefix for wallet-rpc container name for concurrent tests
Past prefix cleanup removed too much.
The container name needs prefix, but the wallet names within the container do not!
2021-04-13 16:35:27 +10:00
Daniel Karzel
3fd77cbfb5
Upgrade to latest monero version 2021-04-13 16:35:27 +10:00
Thomas Eizinger
908dae3442
Inline tracing initialization
This code snippet is so short, it might as well be inlined to give
the test more control over what it wants to log.
2021-03-29 12:15:51 +11:00
Thomas Eizinger
96c87bca71
Avoid local variables if not necessary
We can initialize the env filter without `format!` when the variables
are not used anywhere else.
2021-03-29 12:15:51 +11:00
Thomas Eizinger
c01cccb288
Use tracing-log feature flag instead of manual initialization
This also formats `log` events more nicely. Instead of

```
Mar 29 09:46:16.775  INFO log: Found message after comparing 82 lines log.target="testcontainers::core::wait_for_message" log.module_path="testcontainers::core::wait_for_message" log.file="/home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/testcontainers-0.12.0/src/core/wait_for_message.rs" log.line=35
```

We now have

```
Mar 29 09:57:15.860  INFO testcontainers::core::wait_for_message: Found message after comparing 81 lines
```
2021-03-29 12:15:50 +11:00
Thomas Eizinger
febc68c780
Enforce consistent formatting of Markdown files 2021-03-25 11:11:57 +11:00
Thomas Eizinger
a228349d8b
Bump dependency versions
Otherwise it will take a long time for dependabot to update all of
these.
2021-03-22 14:48:39 +11:00
dependabot[bot]
47544764d9
Bump tokio from 1.0.2 to 1.3.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.0.2 to 1.3.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.0.2...tokio-1.3.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-17 10:53:55 +00:00
Daniel Karzel
2bb1c1e177 No prefix for wallets in monero harness
Prefixing docker-containers and -networks is a necessity to be able to spin up multiple containers and networks.
However, there is no reason to prefix the wallet names that live inside a container. One cannot add a wallet with
the same name twice, so the prefixing of wallets does not bring any advantage. When re-opening a wallet by name
the wallet name prefix is cumbersome and was thus removed.
2021-03-03 17:03:34 +11:00
Daniel Karzel
31c23a24ac use tokio::time::sleep instead of std:🧵:sleep 2021-03-02 13:13:52 +11:00
Daniel Karzel
96115da039 Wait for wallet to catch up instead of block generation
The monero harness wallet always starts a miner that mines new blocks every second.
This can conflict with additionally triggering block generation  and cause this error:

```
monero_rpc::rpc::monerod: generate blocks response: {
  "error": {
    "code": -7,
    "message": "Block not accepted"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
```

Since the miner is generating blocks anyway we can wait for the wallet to catch up.
Refresh is done upon querying the balance, thus the refresh calls were removed.
2021-03-01 17:17:02 +11:00
Daniel Karzel
570832cd37 Add monero rpc log filter to harness tracing
This allows us to see the response from the monerod client on debug.
When the monero-harness was split up into harness and rpc this was overlooked.
We need the debug logs to investigate the monero harness CI fail bug.
2021-02-26 11:43:41 +11:00
Thomas Eizinger
03078f328c
Split monero-harness into harness and rpc
This allows us to move `monero-harness` and `bitcoin-harness` into
`[dev-dependencies]` of `swap`.
2021-02-23 14:30:20 +11:00
Daniel Karzel
7e25c4ad4f Debug log level in monero harness tests to see RPC responses
CI keeps failing when generating blocks, but response is only printed on debug level.
To investigate what is the problem change monero-harness log levels to debug.
2021-02-22 11:03:21 +11:00
Thomas Eizinger
8c83f7e2e1
Upgrade to testcontainers v0.12 2021-02-16 17:11:25 +11:00
Daniel Karzel
56a59bc41c Remove newline in use statements 2021-02-10 15:07:37 +11:00
Daniel Karzel
dac4443bbd Add functionality to open monero wallet through rpc 2021-02-09 16:34:50 +11:00
Daniel Karzel
62605a318a Add CreateWallet trait to expose create_wallet 2021-02-09 16:34:50 +11:00
Franck Royer
c316ea5244
Upgrade toolchain
Needed to use libp2p-async-await
2021-02-04 15:18:33 +11:00
rishflab
77fc5743a2
Upgrade tokio to 1.0
Upgrade bitcoin harness dependency to latest commit

Upgrade backoff to fix failing tests. The previous version of backoff had a broken version of the retry function. Upgraded to a newer comit which fixes this problem.

Upgrade hyper to 0.14 as the 0.13 was bringing in tokio 0.2.24

Upgraded bitcoin harness to version that uses tokio 1.0 and reqwest 0.11

Upgrade reqwest to 0.11. Reqwest 0.11 uses tokio 1.0

Upgrade libp2p to 0.34 in preparation for tokio 1.0 upgrade
2021-01-29 11:36:10 +11:00
Daniel Karzel
3593f5323a Bob saves lock proof after received so he can resume swap 2021-01-21 23:35:54 +11:00
Daniel Karzel
433704e48c Top to bottom pub mod then mod then pub use then use (incl. use crate and use self) 2021-01-21 19:10:51 +11:00
Daniel Karzel
44c4b5dcea Remove newlines from import statements to avoid problems
Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.
2021-01-21 19:10:51 +11:00
Daniel Karzel
d4316f0cfe Print each monero confirmation for Bob
This is to provide more context to the user.
2021-01-18 14:50:59 +11:00
Daniel Karzel
af45206fde Remember the block-height before XMR lock for generated monero wallet restore height
Speeds up wallet creation, because only the blocks after the recorded height will be scanned.
2021-01-12 13:18:49 +11:00
Daniel Karzel
bfc388d264 Enable tracing in monero-harness 2021-01-11 12:55:19 +11:00
Franck Royer
989d9d08d3
Reduce verbosity of monero block generate trace 2020-12-10 13:39:12 +11:00
rishflab
fcec465bdb Revert "No need to send Monero transfer proof from Alice to Bob" 2020-12-01 14:52:05 +11:00
Lucas Soriano del Pino
620216a596 Remove need to send Monero transfer proof from Alice to Bob 2020-11-13 13:15:02 +11:00
Lucas Soriano del Pino
7371dfb055 Test that a watch only wallet can be loaded from address + view key 2020-11-13 13:09:16 +11:00
Philipp Hoenisch
bca439ada5
Use random prefix 2020-11-03 16:52:00 +11:00
Philipp Hoenisch
1a38bf57f2
Rename inner to client 2020-11-03 16:51:26 +11:00
Philipp Hoenisch
f0fbe785c8
Remove Alice and Bob from utility struct 2020-11-03 16:51:26 +11:00
Philipp Hoenisch
306176b3e6
PR feedback:
Removed network prefix and use the same for container and network.
Add sentence explaining prefix
2020-11-03 16:51:26 +11:00
Philipp Hoenisch
a04f04f1a5
Fix failing test due to uninitialized miner 2020-11-03 16:51:26 +11:00
Philipp Hoenisch
0b9e8c145e
Update xmr-btc lib to use new monero-harness 2020-11-03 16:51:26 +11:00
Philipp Hoenisch
3cc32002b0
Refactor out some helper functions to generate blocks after funding 2020-11-03 16:51:26 +11:00
Philipp Hoenisch
3a34800311
Refactor into monero helper struct 2020-11-03 16:51:25 +11:00
Philipp Hoenisch
738c67a421
Simple fund and send in test 2020-11-03 16:51:25 +11:00
Philipp Hoenisch
f5643a4ea4
Miner working 2020-11-03 16:51:25 +11:00
Philipp Hoenisch
0dcb4e56be
Have monerod running in own container 2020-11-03 16:51:25 +11:00
Philipp Hoenisch
7b101a9c98
upgrade testcontainers 2020-11-03 16:51:25 +11:00
Tobin C. Harding
be37725303 monero-harness: Use tracing 2020-10-30 14:04:27 +11:00