AthanorLabs / atomic-swap

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

TestXMRTakerCancelOrRefundAfterKeyExchange flaky #479

Closed dimalinux closed 1 year ago

dimalinux commented 1 year ago

The recently added test, TestXMRTakerCancelOrRefundAfterKeyExchange, is flaky. The problem is this code:

            count, err := ec.PendingTransactionCount(ctx) //nolint:govet
            if err != nil {
                t.Errorf("failed to get pending tx count: %s", err)
                return
            }

            if count > 0 {
                // the newSwap tx is in the mempool, shut down the nodes
                cancel()
                t.Log("cancelling context of Alice's and Bob's servers")
                return
            }

Multiple packages are being tested concurrently and the pending transaction that is found is sometimes an unrelated transaction that happens before the newSwap transaction that it is looking for is created. Then the newSwap transaction never gets created because the context is cancelled first. The swap ends up with the status of aborted.

noot commented 1 year ago

closed by #480 ?