AthanorLabs / atomic-swap

💫 ETH-XMR atomic swap implementation
GNU Lesser General Public License v3.0
341 stars 44 forks source link

ensure that the status channel is always initialized #471

Closed dimalinux closed 1 year ago

dimalinux commented 1 year ago

This PR adds a new test case, TestXMRNotLockedAndETHRefundedAfterAliceRestarts, that was initially broken before the rest of the PR. The taker's status subscribe channel was not getting the refund status change after restart.

I decided to remove the status channel from both the OfferExtra and swap.Info struct types. Both of those types are designed for serialization (and deserialization on restart), but status channels are ephemeral to a single run of swapd. Instead of trying to keep the status channels synchronized across two different data structures, I made management of the channel part of swap.Manager.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 81.04% and project coverage change: +0.02 :tada:

Comparison is base (53a5c97) 58.11% compared to head (0917f24) 58.14%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #471 +/- ## ========================================== + Coverage 58.11% 58.14% +0.02% ========================================== Files 127 128 +1 Lines 12223 12307 +84 ========================================== + Hits 7104 7156 +52 - Misses 4377 4406 +29 - Partials 742 745 +3 ``` | [Impacted Files](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [rpc/prometheus.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cnBjL3Byb21ldGhldXMuZ28=) | `24.27% <0.00%> (ø)` | | | [rpc/server.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cnBjL3NlcnZlci5nbw==) | `75.96% <ø> (ø)` | | | [rpc/swap.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cnBjL3N3YXAuZ28=) | `22.74% <20.00%> (ø)` | | | [protocol/xmrtaker/instance.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cHJvdG9jb2wveG1ydGFrZXIvaW5zdGFuY2UuZ28=) | `41.55% <50.00%> (-0.45%)` | :arrow_down: | | [protocol/xmrmaker/instance.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cHJvdG9jb2wveG1ybWFrZXIvaW5zdGFuY2UuZ28=) | `48.61% <57.14%> (-0.54%)` | :arrow_down: | | [rpc/net.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cnBjL25ldC5nbw==) | `54.83% <57.14%> (+0.75%)` | :arrow_up: | | [protocol/swap/swap\_manager.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cHJvdG9jb2wvc3dhcC9zd2FwX21hbmFnZXIuZ28=) | `77.53% <73.80%> (ø)` | | | [protocol/swap/types.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cHJvdG9jb2wvc3dhcC90eXBlcy5nbw==) | `85.00% <79.24%> (-3.24%)` | :arrow_down: | | [protocol/xmrmaker/swap\_state.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-cHJvdG9jb2wveG1ybWFrZXIvc3dhcF9zdGF0ZS5nbw==) | `67.48% <83.33%> (-0.08%)` | :arrow_down: | | [common/types/offer.go](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29tbW9uL3R5cGVzL29mZmVyLmdv) | `82.25% <100.00%> (+0.59%)` | :arrow_up: | | ... and [10 more](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | | ... and [8 files with indirect coverage changes](https://app.codecov.io/gh/AthanorLabs/atomic-swap/pull/471/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.