2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-09 19:10:47 +00:00
loop/liquidity
Boris Nagaev 3be5a37cd3
liquidity: fix flaky autoloop test
This failure became normal recently:

=== RUN   TestAutoLoopInEnabled
    autoloop_testcontext_test.go:318:
        	Error Trace:	/home/runner/work/loop/loop/liquidity/autoloop_testcontext_test.go:318
        	            				/home/runner/work/loop/loop/liquidity/autoloop_test.go:804
        	Error:      	Not equal:
        	            	expected: 80000
        	            	actual  : 160000
        	Test:       	TestAutoLoopInEnabled
    autoloop_testcontext_test.go:318:
        	Error Trace:	/home/runner/work/loop/loop/liquidity/autoloop_testcontext_test.go:318
        	            				/home/runner/work/loop/loop/liquidity/autoloop_test.go:804
        	Error:      	Not equal:
        	            	expected: 160000
        	            	actual  : 80000
        	Test:       	TestAutoLoopInEnabled
    autoloop_testcontext_test.go:343:
        	Error Trace:	/home/runner/work/loop/loop/liquidity/autoloop_testcontext_test.go:343
        	            				/home/runner/work/loop/loop/liquidity/autoloop_test.go:804
        	Error:      	Should be true
        	Test:       	TestAutoLoopInEnabled

The root cause is them the order of items in c.quoteRequestIn depends on the
order of loopInBuilder.buildSwap calls, which depends on the order of channel
handling in Manager.SuggestSwaps, which depends on the order of map traversal,
which is not determitistic.

Since in the test all the amounts are different, I used amount as a key and
put the expected calls into a map using amount as a key. When I extract an
item from c.quoteRequestIn channel, I find the corresponding item in the map
and remove it. All other logic is preserved.
2024-05-30 15:41:51 -03:00
..
autoloop_test.go multi: use isExternalAddr flag 2024-01-23 20:38:07 +02:00
autoloop_testcontext_test.go liquidity: fix flaky autoloop test 2024-05-30 15:41:51 -03:00
balances.go multi: bump btcec/v2 and btcutil to new versions 2022-03-25 11:00:16 +01:00
fees.go multi: update linter, fix issues 2023-10-03 19:36:40 +02:00
interface.go liquidity: get autoloop flag directly from params 2023-05-29 13:24:16 +03:00
liquidity_test.go multi: add initiator to mocked interfaces for tests 2023-07-28 14:43:19 +03:00
liquidity.go multi: apply make fmt 2024-04-23 15:18:15 -03:00
log.go liquidity: make swap suggestions aware of ongoing swaps 2020-09-30 12:46:32 +02:00
loopin_builder_test.go multi: add initiator to mocked interfaces for tests 2023-07-28 14:43:19 +03:00
loopin_builder.go multi: integrate initiator string to various calls 2023-07-28 14:43:18 +03:00
loopin.go build: fixup new linter issues 2023-03-29 15:56:40 +02:00
loopout_builder.go multi: use isExternalAddr flag 2024-01-23 20:38:07 +02:00
loopout.go liquidity: exclude prepay from total swap fees 2023-04-12 19:02:13 +03:00
mock.go multi: add loop in swap builder implementation 2021-12-15 09:01:20 +02:00
parameters_test.go liquidity: move parameters into a new file 2022-06-07 19:19:52 +08:00
parameters.go multi: apply make fmt 2024-04-23 15:18:15 -03:00
reasons.go multi: add loop in swap builder implementation 2021-12-15 09:01:20 +02:00
restrictions.go multi: bump btcec/v2 and btcutil to new versions 2022-03-25 11:00:16 +01:00
threshold_rule_test.go multi: bump btcec/v2 and btcutil to new versions 2022-03-25 11:00:16 +01:00
threshold_rule.go multi: update linter, fix issues 2023-10-03 19:36:40 +02:00